feat: 消息回调

This commit is contained in:
WLT\Eric.hu
2025-04-14 15:49:33 +08:00
parent 2c054f3c59
commit 1cbbff42f2

View File

@@ -11,7 +11,9 @@ async def ws_handler(websocket, path=None):
try: try:
async for message in websocket: async for message in websocket:
print(f"收到前端消息: {message}") print(f"收到前端消息: {message}")
await broadcast_message(f"回送消息:{message}") # 发送回客户端的消息 # await broadcast_message(f"回送消息:{message}") # 发送回客户端的消息
await broadcast_message(f"{message}") # 发送回客户端的消息
except websockets.exceptions.ConnectionClosed as e: except websockets.exceptions.ConnectionClosed as e:
print(f"连接关闭: {e}") print(f"连接关闭: {e}")
finally: finally: