extractMessageBlock method

int extractMessageBlock(
  1. int start,
  2. int expectedBlockLength
)

Implementation

int extractMessageBlock(int start, int expectedBlockLength) {
  //   output.writeUint32(8 + message.lengthInBytes);
  // output.writeUint32(algoId);
  // output.writeUint32(message.lengthInBytes);
  // output.writeBytes(message);
  var current = start;
  _input.offset = current;
  var blockLength = _input.readUint32();
  assert(blockLength + 4 == expectedBlockLength,
      'Message Blocklength is not correct');
  current = current + 4;
  _input.offset = current;
  var algoId = _input.readUint32();
  _algoIds.add(algoId);
  current = current + 4;
  _input.offset = current;
  var messageLength = _input.readUint32();

  current = current + 4;
  _input.offset = current;

  var messageBytes = _input.readBytes(messageLength);

  _messages.add(messageBytes.toUint8List());

  return current + messageLength;
}