[patch] 重连机制新增is_reconnect参数

This commit is contained in:
2025-10-22 17:45:06 +08:00
parent df7f38bbd8
commit 9f0c81ea82
2 changed files with 8 additions and 4 deletions

View File

@@ -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:

View File

@@ -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"