diff --git a/server.py b/server.py index 2bb8268..f70a62f 100644 --- a/server.py +++ b/server.py @@ -1,5 +1,5 @@ import tomllib -from typing import Dict +from typing import Dict, Any from nacl.signing import SigningKey from sanic import Sanic, Request @@ -85,6 +85,27 @@ def start_sio_listener(): await app.ctx.sio.emit('auth', signature.signature) logger.info(f"{Colors.BLUE}send auth emit{Colors.END}") + @app.ctx.sio.on('auth') + async def auth(data: Dict[str, Any]): + logger.info(f"auth: {data}") + + @app.ctx.sio.on('authFailed') + async def auth_failed(): + logger.warn(f"authFailed") + await app.ctx.sio.disconnect() + + @app.ctx.sio.on('authSucceed') + def auth_succeed(): + logger.info(f"authSucceed") + + @app.ctx.sio.on('connect_error') + def connect_error(*args, **kwargs): + logger.warn(f"连接错误 {args}, {kwargs}") + + @app.ctx.sio.on('updateRoom') + def update_room(data: Dict[str, Any]): + logger.info(f"update_room: {data}") + if __name__ == "__main__": app.run(host='0.0.0.0', port=80, dev=True)