Dispatch Value
Marks a property as the dispatch value within a @DispatchOn discriminator type.
The annotated property must return an Int. The generated dispatch codec reads the discriminator type, evaluates this property, and uses the result to match against @PacketType values.
Exactly one property per class may be annotated with @DispatchValue.
@JvmInline
@ProtocolMessage
value class MqttFixedHeader(val raw: UByte) {
@DispatchValue
val packetType: Int get() = raw.toUInt().shr(4).toInt()
val flags: UByte get() = (raw.toUInt() and 0x0Fu).toUByte()
}Content copied to clipboard