in src/Proton/Codec/Decoders/Transport/BeginTypeDecoder.cs [67:133]
private static Begin ReadBegin(IProtonBuffer buffer, IDecoderState state, IListTypeDecoder listDecoder)
{
Begin result = new();
_ = listDecoder.ReadSize(buffer, state);
int count = listDecoder.ReadCount(buffer, state);
if (count < MinBeginListEntries)
{
throw new DecodeException(ErrorForMissingRequiredFields(count));
}
if (count > MaxBeginListEntries)
{
throw new DecodeException("To many entries in Begin list encoding: " + count);
}
for (int index = 0; index < count; ++index)
{
// Peek ahead and see if there is a null in the next slot, if so we don't call
// the setter for that entry to ensure the returned type reflects the encoded
// state in the modification entry.
bool nullValue = buffer.GetByte(buffer.ReadOffset) == (byte)EncodingCodes.Null;
if (nullValue)
{
// Ensure mandatory fields are set, channel is not mandatory so it can
// be null an so we have to account for that here.
if (index > 0 && index < MinBeginListEntries)
{
throw new DecodeException(ErrorForMissingRequiredFields(index));
}
buffer.ReadByte();
continue;
}
switch (index)
{
case 0:
result.RemoteChannel = state.Decoder.ReadUnsignedShort(buffer, state) ?? 0;
break;
case 1:
result.NextOutgoingId = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
break;
case 2:
result.IncomingWindow = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
break;
case 3:
result.OutgoingWindow = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
break;
case 4:
result.HandleMax = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
break;
case 5:
result.OfferedCapabilities = state.Decoder.ReadMultiple<Symbol>(buffer, state);
break;
case 6:
result.DesiredCapabilities = state.Decoder.ReadMultiple<Symbol>(buffer, state);
break;
case 7:
result.Properties = state.Decoder.ReadMap<Symbol, object>(buffer, state);
break;
}
}
return result;
}