RoomChannel

Constants and framing helpers for Room.channel channel views.

Reserved prefix

Every channel frame begins with CHANNEL_PREFIX (0x63, ASCII 'c' for "channel"), reserved by RoomFramePrefix.Channel — the registry that owns the whole room frame-prefix byte space (#2007). It is distinct from every other claimed byte by construction.

This KDoc previously claimed 0x63 is safe because it sits "outside the CBOR major-type-7 range (0xe00xff) used by serialization". That was false. CBOR text-string headers are 0x60 or len, so a bare 3-character CBOR string begins 0x63 — and the same is true of every other prefix in the registry. The real collision band is 0x60..0x7f; see RoomFramePrefix for the full table. The codebase lives with it because room payloads are framed, not bare.

Applications must not emit raw payloads starting with 0x63 via Room.broadcast or Room.sendTo — that byte is reserved for channel framing. An application frame of 3 bytes or more starting with 0x63 is misclassified as a channel frame and routed (or silently dropped); a 1- or 2-byte one survives, on the strength of the classifier's length test alone. Do not build on that. Room.broadcast carries the whole reserved byte space and which of it is conditional.

Wire format

[0x63][hi byte of subId][lo byte of subId][application payload …]

The 2-byte sub-id is derived from the channel name via channelSubId. Both peers compute the same sub-id independently — no registration handshake is needed. The 3-byte overhead keeps the channel-frame header small.

Properties

Link copied to clipboard

First byte of every channel frame.

Functions

Link copied to clipboard

Derive a 2-byte wire sub-id from a channel name.