serializePayload method
Call to serialize only the payload, no header, returns a int with a serialized size
Implementation
@override
int serializePayload(imc.Sms? message, ByteData byteData, int offset) {
if (message == null) return 0;
var byteOffset = offset;
// field number
var numberEncoded = utf8.encode(message.number);
var numberSSize = numberEncoded.length;
byteData.setUint16(byteOffset, numberSSize, imc.endianSer);
byteOffset += 2;
for (var b in numberEncoded) {
byteData.setUint8(byteOffset++, b);
}
// field timeout
byteData.setUint16(byteOffset, message.timeout, imc.endianSer);
byteOffset += 2;
// field contents
var contentsEncoded = utf8.encode(message.contents);
var contentsSSize = contentsEncoded.length;
byteData.setUint16(byteOffset, contentsSSize, imc.endianSer);
byteOffset += 2;
for (var b in contentsEncoded) {
byteData.setUint8(byteOffset++, b);
}
return byteOffset - offset;
}