ws
This commit is contained in:
parent
00c95cca9e
commit
b178a93fdf
@ -31,7 +31,8 @@ class WebsocketUtil:
|
||||
msg = ws.receive()
|
||||
# 存储ws连接对象
|
||||
if os.path.exists(f"{id}.pkl"):
|
||||
ws_list = read(id=id)
|
||||
wsFile = read(id=id)
|
||||
ws_list = wsFile.ws
|
||||
ws_list.append(ws)
|
||||
data = WsFile(id=id, ws=ws_list)
|
||||
write(id=id, ws=data)
|
||||
@ -65,8 +66,8 @@ class WebsocketUtil:
|
||||
def send_message_proj_json(self, message: Union[str, int, List, Dict], id: str):
|
||||
# 广播该项目的消息
|
||||
active_connections = read(id=id)
|
||||
print("===================", type(active_connections), active_connections[0])
|
||||
for connection in active_connections:
|
||||
print("===================", type(active_connections.ws), active_connections.ws[0])
|
||||
for connection in active_connections.ws:
|
||||
try:
|
||||
connection.send(json.dumps(message, cls=MyEncoder, indent=4), )
|
||||
except Exception as e:
|
||||
|
Loading…
x
Reference in New Issue
Block a user