decodePacketHeader static method
Decode the package head, returning (payloadLength, sequenceID).
Implementation
static Tuple2<int, int> decodePacketHeader(Uint8List buffer) {
final byteData = ByteData.sublistView(buffer);
// The first 3 bytes are for payloadLength.
var header = ByteData(4)
..setUint8(0, buffer[0])
..setUint8(1, buffer[1])
..setUint8(2, buffer[2])
..setUint8(3, 0);
final payloadLength = header.getUint32(0, Endian.little);
// The 4th byte is the sequenceNumber.
final sequenceNumber = byteData.getUint8(3);
return Tuple2(payloadLength, sequenceNumber);
}