From d64cb32aa29b1f9e6b351c4bd5bd17af3a03ab6b Mon Sep 17 00:00:00 2001 From: gaojiangxia <1551959560@qq.com> Date: Tue, 21 Nov 2023 15:42:50 +0800 Subject: [PATCH 1/2] a --- chat.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/chat.py b/chat.py index 086bc16..18033ec 100644 --- a/chat.py +++ b/chat.py @@ -46,14 +46,12 @@ async def echo(websocket): #历史记录数量 if "history_num" in event["type"]: if room_id in history : - # h = history[room_id][start*end - end:start*end] h = len(history[room_id]) else : - # h = [] h = 0; r = {'type':'history_num','content':str(h)} message = json.dumps(r,ensure_ascii=False) - websockets.broadcast(users[room_id], message) + await websocket.send(message) #历史记录 if "history" in event["type"]: start = int(event['page']) @@ -66,7 +64,7 @@ async def echo(websocket): h = [] r = {'type':'history','content':h} message = json.dumps(r,ensure_ascii=False) - websockets.broadcast(users[room_id], message) + await websocket.send(message) #聊天 if "chat" in event['type']: chat = { -- Gitee From cb2e2073908e8abf3d6588a3427025d3b444082f Mon Sep 17 00:00:00 2001 From: gaojiangxia <1551959560@qq.com> Date: Tue, 21 Nov 2023 15:46:10 +0800 Subject: [PATCH 2/2] a --- chat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chat.py b/chat.py index 18033ec..4ed10d5 100644 --- a/chat.py +++ b/chat.py @@ -48,7 +48,7 @@ async def echo(websocket): if room_id in history : h = len(history[room_id]) else : - h = 0; + h = 0 r = {'type':'history_num','content':str(h)} message = json.dumps(r,ensure_ascii=False) await websocket.send(message) -- Gitee