From 6cc45eff8c29b8789cdd717bbad73c0416b164a7 Mon Sep 17 00:00:00 2001 From: adk23333 <2633103794@qq.com> Date: Mon, 18 Dec 2023 23:21:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9B=B4=E5=A4=9AQQ=E7=9B=91?= =?UTF-8?q?=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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)