fix:修复数据类型转换导致的分包组包问题

This commit is contained in:
“DaisyWu” 2024-12-23 18:25:18 +08:00
parent 6147b86e8b
commit 7437add645
3 changed files with 26 additions and 18 deletions

File diff suppressed because one or more lines are too long

View File

@ -171,11 +171,11 @@ class ScpMessage {
final message = ScpMessage(); final message = ScpMessage();
int offset = 0; int offset = 0;
// Convert byte array to hex string with zero padding and without spaces // Convert byte array to hex string with zero padding and without spaces
// String hexString = String hexString =
// bytes.map((b) => b.toRadixString(16).padLeft(2, '0')).join(); bytes.map((b) => b.toRadixString(16).padLeft(2, '0')).join();
//
// // Log the hex string // Log the hex string
// _log(text: '原始字节数组: $hexString'); _log(text: '原始字节数组: $hexString');
// ProtocolFlag (4 bytes) // ProtocolFlag (4 bytes)
if (bytes.length - offset >= 4) { if (bytes.length - offset >= 4) {
message.ProtocolFlag = utf8.decode(bytes.sublist(offset, offset + 4)); message.ProtocolFlag = utf8.decode(bytes.sublist(offset, offset + 4));

View File

@ -285,7 +285,7 @@ class StartChartManage {
// //
void sendEchoMessage({required List<int> payload}) async { void sendEchoMessage({required List<int> payload}) async {
String toPeerId = '2vzXdjdzipJBpWpJxhiRzCFXrDKk54t3YJ7EjYPSRuij'; String toPeerId = '7SDLN3XMNAQvVAJ2yrbLFfJkKQdgfBrpa8wV7s7TXYcu';
// //
final int totalPackets = (payload.length / _maxPayloadSize).ceil(); final int totalPackets = (payload.length / _maxPayloadSize).ceil();
@ -763,7 +763,8 @@ class StartChartManage {
_handleUdpResultData(deserialize); _handleUdpResultData(deserialize);
} }
if (deserialize.PayloadType != PayloadTypeConstant.heartbeat) { if (deserialize.PayloadType != PayloadTypeConstant.heartbeat) {
// _log(text: 'Udp收到结构体数据---》$deserialize'); _log(text: 'Udp收到结构体数据---》$deserialize');
// _log(text: 'text---》${utf8.decode(deserialize.Payload)}');
} }
} }
} catch (e, stackTrace) { } catch (e, stackTrace) {