全局变量
This commit is contained in:
parent
b31867f12a
commit
12df135953
@ -43,9 +43,9 @@ class WebsocketUtil:
|
||||
# ws关闭时 移除ws对象
|
||||
if ws.closed:
|
||||
if ws in active_connections_dist.values():
|
||||
global active_connections
|
||||
# global active_connections
|
||||
active_connections.remove(ws)
|
||||
global active_connections_dist
|
||||
# global active_connections_dist
|
||||
active_connections_dist[id].pop(ws)
|
||||
|
||||
@staticmethod
|
||||
@ -55,13 +55,13 @@ class WebsocketUtil:
|
||||
|
||||
def broadcast(self, message: str):
|
||||
# 广播消息
|
||||
global active_connections
|
||||
# global active_connections
|
||||
for connection in active_connections:
|
||||
connection.send(message)
|
||||
|
||||
def send_message_proj_json(self, message: Union[str, int, List, Dict], id: str):
|
||||
# 广播该项目的消息
|
||||
global active_connections_dist
|
||||
# global active_connections_dist
|
||||
for connection in active_connections_dist[id]:
|
||||
try:
|
||||
connection.send(json.dumps(message, cls=MyEncoder, indent=4), )
|
||||
|
Loading…
x
Reference in New Issue
Block a user