send method
Implementation
Message send(Message msg, [int offset = 0, int? count]) {
tcpSocket.write(msg.assemble(), offset, count);
Uint8List out = Uint8List.fromList([]);
Stopwatch time = Stopwatch();
while (time.elapsed < Duration(milliseconds: 250)) {
Uint8List? packet = tcpSocket.read();
if (packet == null) continue;
if (out.isEmpty) {
out = packet;
time.start();
continue;
}
out = Uint8List.fromList(out.toList().sublist(0, out.length - 2) +
Message.getPayload(packet) +
[0, 0]);
}
return Message.fromByteList(out);
}