From c4b8bf51d5c4767d10f03b5e562316b019a01378 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Thu, 19 Jun 2025 23:07:29 +0300 Subject: [PATCH] Fix sio disconnect event --- app/library/HttpSocket.py | 4 +++- app/routes/socket/connection.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/library/HttpSocket.py b/app/library/HttpSocket.py index 190221ec..988608de 100644 --- a/app/library/HttpSocket.py +++ b/app/library/HttpSocket.py @@ -117,7 +117,9 @@ class HttpSocket: @staticmethod def _injector(func, event: str): - async def wrapper(sid, data, **kwargs): + async def wrapper(sid, data=None, **kwargs): + if not data: + data = {} return await Services.get_instance().handle_async(func, sid=sid, data=data, event=event, **kwargs) return wrapper diff --git a/app/routes/socket/connection.py b/app/routes/socket/connection.py index d1d49f9e..7977fe06 100644 --- a/app/routes/socket/connection.py +++ b/app/routes/socket/connection.py @@ -34,11 +34,12 @@ async def connect(config: Config, queue: DownloadQueue, notify: EventBus, sid: s @route(RouteType.SOCKET, "disconnect", "socket_disconnect") -async def disconnect(sid: str, data: str = None): +async def disconnect(sio: socketio.AsyncServer, sid: str, data: str = None): """ Handle client disconnection. Args: + sio (socketio.AsyncServer): The Socket.IO server instance. sid (str): The session ID of the client. data (str): The reason for disconnection. @@ -47,7 +48,7 @@ async def disconnect(sid: str, data: str = None): for event in _Data.subscribers: if sid in _Data.subscribers[event]: - await unsubscribe(sid=sid, data=event) + await unsubscribe(sio=sio, sid=sid, data=event) @route(RouteType.SOCKET, "subscribe", "socket_subscribe")