ws
This commit is contained in:
parent
87ff3805c7
commit
7f0e578aa3
@ -41,12 +41,11 @@ class WebsocketUtil:
|
|||||||
def disconnect(self, ws, id):
|
def disconnect(self, ws, id):
|
||||||
# ws关闭时 移除ws对象
|
# ws关闭时 移除ws对象
|
||||||
if ws.closed:
|
if ws.closed:
|
||||||
active_connections_dist = Queue.get()
|
active_connections_dist = self.queue.get()
|
||||||
if active_connections_dist is not None:
|
if active_connections_dist is not None:
|
||||||
if ws in active_connections_dist.values():
|
if ws in active_connections_dist.values():
|
||||||
active_connections_dist[id].pop(ws)
|
active_connections_dist[id].pop(ws)
|
||||||
redis_client.get_redis().set("active_connections", json.dumps(active_connections))
|
self.queue.put(active_connections_dist)
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def send_personal_message(message: str, ws):
|
async def send_personal_message(message: str, ws):
|
||||||
@ -65,7 +64,7 @@ class WebsocketUtil:
|
|||||||
def send_message_proj_json(self, message: Union[str, int, List, Dict], id: str):
|
def send_message_proj_json(self, message: Union[str, int, List, Dict], id: str):
|
||||||
# 广播该项目的消息
|
# 广播该项目的消息
|
||||||
# global active_connections_dist
|
# global active_connections_dist
|
||||||
print(self.queue.qsize)
|
print(self.queue.qsize())
|
||||||
active_connections_dist = self.queue.get()
|
active_connections_dist = self.queue.get()
|
||||||
self.queue.put(active_connections_dist)
|
self.queue.put(active_connections_dist)
|
||||||
print(active_connections_dist)
|
print(active_connections_dist)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user