diff --git a/chat.py b/chat.py index 086bc162f3a10f7714d295ee8d7900601a2c588f..4ed10d56c3110eaff5e3590f6851e52e004dba93 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; + 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 = {