serializePayload method

  1. @override
int serializePayload(
  1. CommRestriction? message,
  2. ByteData byteData,
  3. int offset
)
override

Call to serialize only the payload, no header, returns a int with a serialized size

Implementation

@override
int serializePayload(
    imc.CommRestriction? message, ByteData byteData, int offset) {
  if (message == null) return 0;

  var byteOffset = offset;

  // field restriction
  byteData.setUint8(byteOffset, message.restriction.value);
  byteOffset += 1;
  // field reason
  var reasonEncoded = utf8.encode(message.reason);
  var reasonSSize = reasonEncoded.length;
  byteData.setUint16(byteOffset, reasonSSize, imc.endianSer);
  byteOffset += 2;
  for (var b in reasonEncoded) {
    byteData.setUint8(byteOffset++, b);
  }

  return byteOffset - offset;
}