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"