deserializePayload method
int
deserializePayload(
- AcousticMessageBuilder builder,
- ByteData byteData,
- Endian endianness,
- int offset,
override
Call to deserialize only the payload, no header. The Builder is to allow passing the message to build into. returns a int with a serialized size
Implementation
@override
int deserializePayload(imc.AcousticMessageBuilder builder, ByteData byteData,
Endian endianness, int offset) {
var byteOffset = offset;
// field message
var messageSId = byteData.getUint16(byteOffset, endianness);
byteOffset += 2;
if (messageSId == imc.ImcId.nullId) {
builder.message = null;
} else {
var pMsgBuilder = imc.messagesBuilders[
imc.idsToMessages[messageSId] ?? imc.ImcId.nullId.toString()]
?.call()
.newInstance(builder);
var pMsgSerializer = imc.messagesSerializers[
imc.idsToMessages[messageSId] ?? imc.ImcId.nullId.toString()]
?.call();
if (pMsgBuilder != null && pMsgSerializer != null) {
var mPSize = pMsgSerializer.deserializePayload(
pMsgBuilder, byteData, endianness, byteOffset);
byteOffset += mPSize;
builder.message = pMsgBuilder.build() as imc.ImcMessage?;
}
}
return byteOffset - offset;
}