Browse Source

properly handle disconnects from ios client

pull/319/head
Miguel Grinberg 6 years ago
parent
commit
c0c1bf8d21
No known key found for this signature in database GPG Key ID: 36848B262DF5F06C
  1. 4
      socketio/asyncio_server.py
  2. 4
      socketio/server.py

4
socketio/asyncio_server.py

@ -409,8 +409,6 @@ class AsyncServer(server.Server):
if namespace == '/' and self.manager.is_connected(sid, namespace): if namespace == '/' and self.manager.is_connected(sid, namespace):
await self._trigger_event('disconnect', '/', sid) await self._trigger_event('disconnect', '/', sid)
self.manager.disconnect(sid, '/') self.manager.disconnect(sid, '/')
if sid in self.environ:
del self.environ[sid]
async def _handle_event(self, sid, namespace, id, data): async def _handle_event(self, sid, namespace, id, data):
"""Handle an incoming client event.""" """Handle an incoming client event."""
@ -505,6 +503,8 @@ class AsyncServer(server.Server):
async def _handle_eio_disconnect(self, sid): async def _handle_eio_disconnect(self, sid):
"""Handle Engine.IO disconnect event.""" """Handle Engine.IO disconnect event."""
await self._handle_disconnect(sid, '/') await self._handle_disconnect(sid, '/')
if sid in self.environ:
del self.environ[sid]
def _engineio_server_class(self): def _engineio_server_class(self):
return engineio.AsyncServer return engineio.AsyncServer

4
socketio/server.py

@ -583,8 +583,6 @@ class Server(object):
if namespace == '/' and self.manager.is_connected(sid, namespace): if namespace == '/' and self.manager.is_connected(sid, namespace):
self._trigger_event('disconnect', '/', sid) self._trigger_event('disconnect', '/', sid)
self.manager.disconnect(sid, '/') self.manager.disconnect(sid, '/')
if sid in self.environ:
del self.environ[sid]
def _handle_event(self, sid, namespace, id, data): def _handle_event(self, sid, namespace, id, data):
"""Handle an incoming client event.""" """Handle an incoming client event."""
@ -673,6 +671,8 @@ class Server(object):
def _handle_eio_disconnect(self, sid): def _handle_eio_disconnect(self, sid):
"""Handle Engine.IO disconnect event.""" """Handle Engine.IO disconnect event."""
self._handle_disconnect(sid, '/') self._handle_disconnect(sid, '/')
if sid in self.environ:
del self.environ[sid]
def _engineio_server_class(self): def _engineio_server_class(self):
return engineio.Server return engineio.Server

Loading…
Cancel
Save