Packet Type
Specifies the discriminator value for a variant of a @ProtocolMessage sealed interface.
The generated dispatch codec reads one byte, matches it against each variant's value, and delegates to the correct variant codec. On encode, the type byte is written first.
@ProtocolMessage
sealed interface Command {
@ProtocolMessage
@PacketType(0x01)
data class Ping(val timestamp: Long) : Command
@ProtocolMessage
@PacketType(0x02)
data class Echo(@LengthPrefixed val message: String) : Command
}
// Generates CommandCodec that auto-dispatches by type byte
// val cmd: Command = CommandCodec.decode(buffer)Content copied to clipboard
Parameters
value
The discriminator byte value (0-255). Written/read as a single byte on the wire. Values outside 0-255 are rejected at compile time.