diff --git a/src/socketio/admin.py b/src/socketio/admin.py index 58c8aff9..2d7042d2 100644 --- a/src/socketio/admin.py +++ b/src/socketio/admin.py @@ -216,12 +216,12 @@ def _connect(self, eio_sid, namespace): ), namespace=self.admin_namespace) return sid - def _disconnect(self, sid, namespace, **kwargs): + def _disconnect(self, sid, namespace, reason, **kwargs): del self.sio.manager._timestamps[sid] self.sio.emit('socket_disconnected', ( namespace, sid, - 'N/A', + reason or 'N/A', datetime.utcnow().isoformat() + 'Z', ), namespace=self.admin_namespace) return self.sio.manager.__disconnect(sid, namespace, **kwargs) @@ -303,9 +303,9 @@ def _handle_eio_connect(self, eio_sid, environ): self.event_buffer.push('rawConnection') return self.sio._handle_eio_connect(eio_sid, environ) - def _handle_eio_disconnect(self, eio_sid): + def _handle_eio_disconnect(self, eio_sid, reason): self.event_buffer.push('rawDisconnection') - return self.sio._handle_eio_disconnect(eio_sid) + return 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_admin.py b/src/socketio/async_admin.py index 162c5660..575d1bae 100644 --- a/src/socketio/async_admin.py +++ b/src/socketio/async_admin.py @@ -204,12 +204,12 @@ async def _connect(self, eio_sid, namespace): ), 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 @@ async def _handle_eio_connect(self, eio_sid, environ): 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,