UpdateMessage constructor

UpdateMessage(
  1. Uint8List bytes,
  2. Encoding encoding
)

Implementation

UpdateMessage(Uint8List bytes, Encoding encoding) {
  final reader = ByteDataReader()..add(bytes);
  // reading order matters
  relationID = reader.readUint32();
  var tupleType = UpdateMessageTuple.fromByte(reader.readUint8());

  if (tupleType == UpdateMessageTuple.oldType ||
      tupleType == UpdateMessageTuple.keyType) {
    oldTupleType = tupleType;
    oldTuple = TupleData(reader,encoding);
    tupleType = UpdateMessageTuple.fromByte(reader.readUint8());
  } else {
    oldTupleType = null;
    oldTuple = null;
  }

  if (tupleType == UpdateMessageTuple.newType) {
    newTuple = TupleData(reader,encoding);
  } else {
    throw Exception('Invalid Tuple Type for UpdateMessage');
  }
}