readPkt method
Implementation
RawNetPacket readPkt() {
final buffer = _socket.readSync(kHeaderLength)!;
final headerData = Uint8List.fromList(buffer);
if (ascii.decode(headerData.sublist(0, 4)) != kHeaderMagic) {
throw Exception('Non-valid magic ID!');
}
final ByteData byteDataView = ByteData.sublistView(headerData, 4);
final devIndex = byteDataView.getUint32(0, Endian.little);
final commandId = byteDataView.getUint32(4, Endian.little);
final dataLength = byteDataView.getUint32(8, Endian.little);
return RawNetPacket(
deviceIndex: devIndex,
commandId: commandId,
restOfPkt: Uint8List.fromList(_socket.readSync(dataLength)!),
);
}