Wire framing shared by the server session layer and the browser transport.
QUIC streams are byte streams, so every channel message is framed as
<<length::32, type::8, payload::binary-size(length - 1)>>where type is 0 for a text (JSON) message, 1 for a binary one, and 2
for a pre-join :auth frame (base64url.bearer.phx.<token>).
The 32-bit length covers the type byte and the payload.
Each server-initiated unidirectional stream starts with a 4-byte lane id
before its first frame; see PhoenixWebTransport.Lanes.
Summary
Functions
Decodes complete frames from buffer, returning {:ok, frames, rest} or
{:error, reason}.
Bang variant of decode/2 returning {frames, rest} or raising ArgumentError.
Default maximum frame payload size in bytes (16 MiB).
Encodes a text, binary, or auth payload into a length-prefixed frame iodata.
Types
@type decode_error() :: :invalid_frame_length | {:frame_too_large, non_neg_integer(), non_neg_integer()} | {:invalid_frame_type, byte()}
@type frame() :: {frame_type(), binary()}
@type frame_type() :: :text | :binary | :auth
Functions
@spec decode(binary(), keyword()) :: {:ok, [frame()], binary()} | {:error, decode_error()}
Decodes complete frames from buffer, returning {:ok, frames, rest} or
{:error, reason}.
Validates frame lengths (len >= 1 and len - 1 <= max_frame_size) and type
bytes as soon as their header bytes arrive, before buffering oversized payloads.
Options:
:max_frame_size- maximum allowed payload bytes (default16_777_216).
Bang variant of decode/2 returning {frames, rest} or raising ArgumentError.
@spec default_max_frame_size() :: pos_integer()
Default maximum frame payload size in bytes (16 MiB).
@spec encode(frame_type(), iodata()) :: iodata()
Encodes a text, binary, or auth payload into a length-prefixed frame iodata.