解决了渲染TCP推送数据,在切换功能后不稳定问题,保证了APP端的稳定性。
This commit is contained in:
@@ -88,6 +88,27 @@ class NetMessageDispatcher {
|
||||
}
|
||||
});
|
||||
}
|
||||
//机器状态页面专用
|
||||
Stream<String> onStringMessageOfdeviceStatus() {
|
||||
//print("0x02--TCP拦截推送解析开始");
|
||||
_logger.log('0x02--TCP拦截推送解析开始');
|
||||
// 🔥 关键修复:使用asBroadcastStream()确保多个监听者都能收到数据
|
||||
return onCommand(0x02).map((p) {
|
||||
try {
|
||||
// 尝试解码
|
||||
final result = utf8.decode(p.payload, allowMalformed: true); // 允许乱码,防止报错中断流
|
||||
//print('✅ 解码 0x02 成功:$result'); // 🔥 关键日志:看这里打印了吗?
|
||||
_logger.log('✅ 解码 0x02 成功:$result');
|
||||
return result;
|
||||
} catch (e) {
|
||||
// print('❌ 解码 0x02 失败:$e, 原始字节:${p.payload}');
|
||||
_logger.log('❌ 解码 0x02 失败:$e, 原始字节:${p.payload}');
|
||||
return ''; // 返回空字符串,避免流中断
|
||||
}
|
||||
}).asBroadcastStream();
|
||||
/* ///return onCommand(0x02).map((p) => utf8.decode(p.payload));*/
|
||||
}
|
||||
|
||||
|
||||
//监听路径规划的开始作业的指令的应答
|
||||
|
||||
|
||||
Reference in New Issue
Block a user