From 12da2b4414412d5e1727d3c9d9b0fe44087766eb Mon Sep 17 00:00:00 2001 From: DZY Date: Sat, 7 Jun 2025 11:52:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2chat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CS3.1.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CS3.1.py b/CS3.1.py index dc72543..4c08f84 100644 --- a/CS3.1.py +++ b/CS3.1.py @@ -142,7 +142,7 @@ def handle_socket_message(data, addr, conn): "message": data['message'] } broadcast_message(message) - return {"type": "chat", "status": "success"} + #return {"type": "chat", "status": "success"} return {"type": "chat", "status": "error", "message": "Not logged in"} except Exception as e: return {"status": "error", "message": str(e)} @@ -165,7 +165,8 @@ def run_socket_server(): try: json_data = json.loads(data.decode()) response = handle_socket_message(json_data, addr, conn) - conn.sendall(json.dumps(response).encode()) + if response != None: + conn.sendall(json.dumps(response).encode()) except json.JSONDecodeError: conn.sendall(json.dumps( {"type": "register_0", "status": "error", "message": "Invalid JSON"}