全局变量
This commit is contained in:
parent
066fb720bc
commit
b60fa43567
@ -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()
|
Loading…
x
Reference in New Issue
Block a user