Skip to content

Commit

Permalink
reset sid after a disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Feb 12, 2019
1 parent 82f6982 commit 9aa7742
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions engineio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def create_event(self, *args, **kwargs):

def _reset(self):
self.state = 'disconnected'
self.sid = None

def _connect_polling(self, url, headers, engineio_path):
"""Establish a long-polling connection to the Engine.IO server."""
Expand Down
2 changes: 2 additions & 0 deletions tests/asyncio/test_asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ async def fake_send_packet(pkt):
def test_disconnect_not_connected(self):
c = asyncio_client.AsyncClient()
c.state = 'foo'
c.sid = 'bar'
_run(c.disconnect())
self.assertEqual(c.state, 'disconnected')
self.assertIsNone(c.sid)

def test_disconnect_polling(self):
c = asyncio_client.AsyncClient()
Expand Down
2 changes: 2 additions & 0 deletions tests/common/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ def fake_send_packet(pkt):
def test_disconnect_not_connected(self):
c = client.Client()
c.state = 'foo'
c.sid = 'bar'
c.disconnect()
self.assertEqual(c.state, 'disconnected')
self.assertIsNone(c.sid)

def test_disconnect_polling(self):
c = client.Client()
Expand Down

0 comments on commit 9aa7742

Please sign in to comment.