From b60fa43567ad9b3a8206ee14eaf56635d0945dba Mon Sep 17 00:00:00 2001 From: JIAKUNHAO Date: Thu, 24 Nov 2022 10:58:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/utils/websocket_tool.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/utils/websocket_tool.py b/app/utils/websocket_tool.py index 84a83eb..8deb533 100644 --- a/app/utils/websocket_tool.py +++ b/app/utils/websocket_tool.py @@ -1,6 +1,8 @@ """ @Time : 2022/10/12 17:55 @Auth : 东 +@File :websocket_tool.py +@IDE :PyCharm @Motto:ABC(Always Be Coding) @Desc: @@ -14,15 +16,16 @@ from configs.global_var import * class WebsocketUtil: + def connect(self, ws, id: str): # 等待连接 msg = ws.receive() # 存储ws连接对象 - # global active_connections - # active_connections = get_active_connections() + global active_connections + active_connections = get_active_connections() active_connections.append(ws) - # global active_connections_dist - # active_connections_dist = get_active_connections_dist() + global active_connections_dist + active_connections_dist = get_active_connections_dist() if id in active_connections_dist: active_connections_dist[id].append(ws) else: @@ -60,4 +63,4 @@ class WebsocketUtil: self.disconnect(ws=connection, id=id) -manager = WebsocketUtil() +manager = WebsocketUtil() \ No newline at end of file