diff --git a/src/socketio/async_admin.py b/src/socketio/async_admin.py index 162c566..575d1ba 100644 --- a/src/socketio/async_admin.py +++ b/src/socketio/async_admin.py @@ -204,12 +204,12 @@ class InstrumentedAsyncServer: ), namespace=self.admin_namespace) return sid - async def _disconnect(self, sid, namespace, **kwargs): + async def _disconnect(self, sid, namespace, reason, **kwargs): del self.sio.manager._timestamps[sid] await self.sio.emit('socket_disconnected', ( namespace, sid, - 'N/A', + reason or 'N/A', datetime.utcnow().isoformat() + 'Z', ), namespace=self.admin_namespace) return await self.sio.manager.__disconnect(sid, namespace, **kwargs) @@ -292,9 +292,9 @@ class InstrumentedAsyncServer: self.event_buffer.push('rawConnection') return await self.sio._handle_eio_connect(eio_sid, environ) - async def _handle_eio_disconnect(self, eio_sid): + async def _handle_eio_disconnect(self, eio_sid, reason): self.event_buffer.push('rawDisconnection') - return await self.sio._handle_eio_disconnect(eio_sid) + return await self.sio._handle_eio_disconnect(eio_sid, reason) def _eio_http_response(self, packets=None, headers=None, jsonp_index=None): ret = self.sio.eio.__ok(packets=packets, headers=headers, diff --git a/src/socketio/async_server.py b/src/socketio/async_server.py index f10fb8a..4cd8634 100644 --- a/src/socketio/async_server.py +++ b/src/socketio/async_server.py @@ -585,7 +585,7 @@ class AsyncServer(base_server.BaseServer): self.manager.pre_disconnect(sid, namespace=namespace) await self._trigger_event('disconnect', namespace, sid, reason or self.reason.CLIENT_DISCONNECT) - await self.manager.disconnect(sid, namespace, ignore_queue=True) + await self.manager.disconnect(sid, namespace, reason=reason or self.reason.CLIENT_DISCONNECT, ignore_queue=True) async def _handle_event(self, eio_sid, namespace, id, data): """Handle an incoming client event."""