完成优化登录的优化
完成切换和切回APP数据的及时响应 完成服务下发退出账号的命令
This commit is contained in:
@@ -51,16 +51,16 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
);
|
||||
|
||||
// 订阅 JSON 流 (0x12)
|
||||
_jsonSub = _dispatcher.onJsonMessage(0x12).listen(
|
||||
(jsonData) {
|
||||
debugPrint('📩 [Bloc] 收到 JSON 数据事件:$jsonData');
|
||||
if (!isClosed) {
|
||||
add(PushMessageReceived(jsonData));
|
||||
}
|
||||
},
|
||||
onDone: () => debugPrint('⚠️ [Bloc] JSON 流已结束 (onDone)'),
|
||||
onError: (e) => debugPrint('❌ [Bloc] JSON 流发生错误:$e'),
|
||||
);
|
||||
// _jsonSub = _dispatcher.onJsonMessage(0x12).listen(
|
||||
// (jsonData) {
|
||||
// debugPrint('📩 [Bloc] 收到 JSON 数据事件:$jsonData');
|
||||
// if (!isClosed) {
|
||||
// add(PushMessageReceived(jsonData));
|
||||
// }
|
||||
// },
|
||||
// onDone: () => debugPrint('⚠️ [Bloc] JSON 流已结束 (onDone)'),
|
||||
// onError: (e) => debugPrint('❌ [Bloc] JSON 流发生错误:$e'),
|
||||
// );
|
||||
|
||||
_isSubscribed = true;
|
||||
debugPrint('✅ [DeviceStatusBloc] 订阅建立完成,将持续监听数据流');
|
||||
|
||||
@@ -221,7 +221,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
debugPrint('🛑 检测到已连接,先断开旧 TCP 连接...');
|
||||
_tcpClient.disconnects(forSwitch: true);
|
||||
// 稍微等待一下,确保底层 Socket 资源释放 (可选,但推荐)
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
// await Future.delayed(const Duration(milliseconds: 100));
|
||||
}
|
||||
|
||||
// 🔥 关键修复 2:发起新连接
|
||||
|
||||
Reference in New Issue
Block a user