From 9f0c81ea82af30d82b9db7ec9b9668f444ba62b5 Mon Sep 17 00:00:00 2001 From: haosicheng Date: Wed, 22 Oct 2025 17:45:06 +0800 Subject: [PATCH] =?UTF-8?q?[patch]=20=E9=87=8D=E8=BF=9E=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=E6=96=B0=E5=A2=9Eis=5Freconnect=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebSocket/BackendClient.py | 10 +++++++--- config.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/WebSocket/BackendClient.py b/WebSocket/BackendClient.py index 5d54c8c..5666d9b 100644 --- a/WebSocket/BackendClient.py +++ b/WebSocket/BackendClient.py @@ -143,7 +143,7 @@ class BackendClient: await asyncio.sleep(0.5) # 发送连接状态通知给后端 - self._notify_connection_status(True) + self._notify_connection_status(True, is_reconnect=was_reconnecting) self.on_connected(was_reconnecting) @@ -389,7 +389,7 @@ class BackendClient: import traceback self._log(f"详细错误: {traceback.format_exc()}", "DEBUG") - def _notify_connection_status(self, connected: bool): + def _notify_connection_status(self, connected: bool, is_reconnect: bool = False): """通知后端连接状态变化""" try: if not self.loop: @@ -415,11 +415,15 @@ class BackendClient: self._log(f"获取活跃平台信息失败: {e}", "DEBUG") status_message = { - "type": "connection_status", + "type": "connection_status", "status": connected, "timestamp": int(time.time()), "client_uuid": self.uuid } + + # 🔥 新增:如果是重连,添加重连标识 + if is_reconnect: + status_message["is_reconnect"] = True # 如果有活跃平台,添加store_id if active_store_id: diff --git a/config.py b/config.py index 69bce96..bff0ac2 100644 --- a/config.py +++ b/config.py @@ -10,7 +10,7 @@ import json # 用于将令牌保存为 JSON 格式 # 后端服务器配置 # BACKEND_HOST = "192.168.5.233" # BACKEND_HOST = "192.168.5.106" -BACKEND_HOST = "192.168.5.140" +BACKEND_HOST = "192.168.5.12" # BACKEND_HOST = "shuidrop.com" # BACKEND_HOST = "test.shuidrop.com" BACKEND_PORT = "8000"