Message constructor

Message(
  1. Uint8List data
)

constructor from Uint8List(receive data).

Implementation

Message(Uint8List data) {
  header = MessageHeader(data);
  // body start position is the header size + the header size char count + LF
  final int headerEndPosition =
      header.headerSize + header.headerSize.toString().length + 1;
  int bodyEndPosition = headerEndPosition + header.bodySize;
  if (bodyEndPosition > data.length) {
    bodyEndPosition = data.length;
  }
  body = utf8.decode(data.sublist(headerEndPosition, bodyEndPosition));
}