优化切换设备机器状态的实时接受和UI实时刷新

This commit is contained in:
2026-03-05 21:25:58 +08:00
parent 83a5dc7f32
commit bfc16447c3

View File

@@ -426,7 +426,14 @@ class TcpClient {
onDone: (){
// TODO: 断线重连
debugPrint('onDone❌ 被动[TCP] 连接已断开!');
_handleDisconnectBySwitch(deviceName);
if (!_isSwitching) {
_handleDisconnectBySwitch(deviceName);
} else {
debugPrint('🚫 [TCP] 检测到切换过程中的断开,忽略重连调度,防止死循环');
// 可选:如果是因为切换导致的断开,这里不需要做任何事,因为主流程已经在运行了
// 但为了安全,可以重置一下标志位,防止后续逻辑误判
_isSwitching = false;
}
},
onError: (e) {
debugPrint('❌ 被动[TCP] 发生错误:$e');