[patch] 重连机制新增is_reconnect参数
This commit is contained in:
@@ -143,7 +143,7 @@ class BackendClient:
|
|||||||
await asyncio.sleep(0.5)
|
await asyncio.sleep(0.5)
|
||||||
|
|
||||||
# 发送连接状态通知给后端
|
# 发送连接状态通知给后端
|
||||||
self._notify_connection_status(True)
|
self._notify_connection_status(True, is_reconnect=was_reconnecting)
|
||||||
|
|
||||||
self.on_connected(was_reconnecting)
|
self.on_connected(was_reconnecting)
|
||||||
|
|
||||||
@@ -389,7 +389,7 @@ class BackendClient:
|
|||||||
import traceback
|
import traceback
|
||||||
self._log(f"详细错误: {traceback.format_exc()}", "DEBUG")
|
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:
|
try:
|
||||||
if not self.loop:
|
if not self.loop:
|
||||||
@@ -415,11 +415,15 @@ class BackendClient:
|
|||||||
self._log(f"获取活跃平台信息失败: {e}", "DEBUG")
|
self._log(f"获取活跃平台信息失败: {e}", "DEBUG")
|
||||||
|
|
||||||
status_message = {
|
status_message = {
|
||||||
"type": "connection_status",
|
"type": "connection_status",
|
||||||
"status": connected,
|
"status": connected,
|
||||||
"timestamp": int(time.time()),
|
"timestamp": int(time.time()),
|
||||||
"client_uuid": self.uuid
|
"client_uuid": self.uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 🔥 新增:如果是重连,添加重连标识
|
||||||
|
if is_reconnect:
|
||||||
|
status_message["is_reconnect"] = True
|
||||||
|
|
||||||
# 如果有活跃平台,添加store_id
|
# 如果有活跃平台,添加store_id
|
||||||
if active_store_id:
|
if active_store_id:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import json # 用于将令牌保存为 JSON 格式
|
|||||||
# 后端服务器配置
|
# 后端服务器配置
|
||||||
# BACKEND_HOST = "192.168.5.233"
|
# BACKEND_HOST = "192.168.5.233"
|
||||||
# BACKEND_HOST = "192.168.5.106"
|
# BACKEND_HOST = "192.168.5.106"
|
||||||
BACKEND_HOST = "192.168.5.140"
|
BACKEND_HOST = "192.168.5.12"
|
||||||
# BACKEND_HOST = "shuidrop.com"
|
# BACKEND_HOST = "shuidrop.com"
|
||||||
# BACKEND_HOST = "test.shuidrop.com"
|
# BACKEND_HOST = "test.shuidrop.com"
|
||||||
BACKEND_PORT = "8000"
|
BACKEND_PORT = "8000"
|
||||||
|
|||||||
Reference in New Issue
Block a user