serializePayload method
Call to serialize only the payload, no header, returns a int with a serialized size
Implementation
@override
int serializePayload(
imc.TrexObservation? message, ByteData byteData, int offset) {
if (message == null) return 0;
var byteOffset = offset;
// field timeline
var timelineEncoded = utf8.encode(message.timeline);
var timelineSSize = timelineEncoded.length;
byteData.setUint16(byteOffset, timelineSSize, imc.endianSer);
byteOffset += 2;
for (var b in timelineEncoded) {
byteData.setUint8(byteOffset++, b);
}
// field predicate
var predicateEncoded = utf8.encode(message.predicate);
var predicateSSize = predicateEncoded.length;
byteData.setUint16(byteOffset, predicateSSize, imc.endianSer);
byteOffset += 2;
for (var b in predicateEncoded) {
byteData.setUint8(byteOffset++, b);
}
// field attributes
var attributesEncoded = utf8.encode(message.attributes);
var attributesSSize = attributesEncoded.length;
byteData.setUint16(byteOffset, attributesSSize, imc.endianSer);
byteOffset += 2;
for (var b in attributesEncoded) {
byteData.setUint8(byteOffset++, b);
}
return byteOffset - offset;
}