diff --git a/moderation/backend-py/websocket_server.py b/moderation/backend-py/websocket_server.py index cc9a1e8..315d737 100644 --- a/moderation/backend-py/websocket_server.py +++ b/moderation/backend-py/websocket_server.py @@ -36,18 +36,15 @@ def broadcast_online(): sio.emit('online', online_list, namespace='/mod-chat') -# Create namespace for moderation chat -mod_chat = sio.namespace('/mod-chat') - - -@mod_chat.on('connect') +# Namespace handlers for /mod-chat +@sio.on('connect', namespace='/mod-chat') async def on_connect(sid, environ): """Handle client connection to /mod-chat namespace""" logger.info(f"[WebSocket] Client connected to /mod-chat: {sid}") # Don't authorize immediately - wait for 'auth' event -@mod_chat.on('disconnect') +@sio.on('disconnect', namespace='/mod-chat') async def on_disconnect(sid): """Handle client disconnection""" logger.info(f"[WebSocket] Client disconnected from /mod-chat: {sid}") @@ -57,7 +54,7 @@ async def on_disconnect(sid): broadcast_online() -@mod_chat.on('auth') +@sio.on('auth', namespace='/mod-chat') async def on_auth(sid, data): """Handle authentication for moderation chat""" try: @@ -105,7 +102,7 @@ async def on_auth(sid, data): await sio.disconnect(sid, namespace='/mod-chat') -@mod_chat.on('message') +@sio.on('message', namespace='/mod-chat') async def on_message(sid, data): """Handle moderation chat message""" try: