重构机器状态页面的数据获取设定保证数据及时显示

This commit is contained in:
2026-04-17 17:29:31 +08:00
parent 06c54ef546
commit b116e4bed3
4 changed files with 163 additions and 70 deletions

View File

@@ -47,6 +47,7 @@ class NetMessageDispatcher {
Stream<String> onStringMessage() {
//print("0x02--TCP拦截推送解析开始");
_logger.log('0x02--TCP拦截推送解析开始');
// 🔥 关键修复:使用asBroadcastStream()确保多个监听者都能收到数据
return onCommand(0x02).map((p) {
try {
// 尝试解码
@@ -59,7 +60,7 @@ class NetMessageDispatcher {
_logger.log('❌ 解码 0x02 失败:$e, 原始字节:${p.payload}');
return ''; // 返回空字符串,避免流中断
}
});
}).asBroadcastStream();
/* ///return onCommand(0x02).map((p) => utf8.decode(p.payload));*/
}