Backend-agnostic WebTransport session state machine driving a
Phoenix.Socket.Transport.
PhoenixWebTransport.Quic.Session delegates routing, origin validation, dev
code reloading, connect_info & auth_token bridging, inbound frame
decoding, and outbound push/close normalization to this module.
Functions return {engine, actions} (or {:ok | :error, ...} on connect)
where actions are backend-neutral effect tuples:
{:push, lane, {:text | :binary, binary()}}{:push_barrier, 0, {:text, binary()}, [pos_integer()]}{:push_datagram, {:text | :binary, binary()}}:drain_session{:close_session, close_code :: non_neg_integer(), reason :: binary()}
Summary
Functions
Returns true when socket.connect/1 succeeded or a pre-join :auth frame is pending.
Returns true when a new inbound client stream can be admitted without
exceeding max_client_streams.
Returns true while awaiting a pre-join :auth frame before socket.connect/1.
Drops state and byte accounting for a closed inbound stream.
Validates an incoming WebTransport CONNECT request against routes, checks
origin, runs dev code reloading if configured, and either invokes
socket.connect/1 or defers until the client sends its pre-join :auth frame.
Initiates a graceful shutdown drain (1012 + :drain_session), invoking
socket.handle_info(:socket_drain, ...) when initialized.
Routes an inbound RFC 9297 WebTransport datagram through socket.handle_in/2.
Decodes inbound stream bytes into Phoenix frames (handling any pre-join
:auth frame first) and dispatches them through socket.handle_in/2.
Routes an Erlang message through socket.handle_info/2 and normalizes
pushes and 3/4/5-tuple :stop returns.
Initializes the Phoenix socket inside the session-owning process.
Builds a new session engine from listener or router options.
Registers an inbound client stream.
Calls socket.terminate/2 idempotently when the session stops.
Types
@type action() :: {:push, non_neg_integer(), {:text | :binary, binary()}} | {:push_barrier, 0, {:text, binary()}, [pos_integer()]} | {:push_datagram, {:text | :binary, binary()}} | :drain_session | {:close_session, close_code(), binary()}
@type close_code() :: non_neg_integer()
@type t() :: %PhoenixWebTransport.SessionEngine{ closing: boolean(), endpoint: module() | nil, in_buf: %{optional(term()) => binary()}, in_buf_bytes: non_neg_integer(), max_client_streams: pos_integer(), max_frame_size: non_neg_integer(), max_in_buf_bytes: non_neg_integer(), max_lanes: pos_integer(), path: String.t(), pending_connect: map() | nil, routes: [PhoenixWebTransport.Router.route()], socket: module() | nil, socket_opts: keyword(), socket_state: term() | nil, terminated?: boolean() }
Functions
Returns true when socket.connect/1 succeeded or a pre-join :auth frame is pending.
Returns true when a new inbound client stream can be admitted without
exceeding max_client_streams.
Returns true while awaiting a pre-join :auth frame before socket.connect/1.
Drops state and byte accounting for a closed inbound stream.
@spec connect(t(), connect_request()) :: {:ok, t()} | {:error, pos_integer(), term()}
Validates an incoming WebTransport CONNECT request against routes, checks
origin, runs dev code reloading if configured, and either invokes
socket.connect/1 or defers until the client sends its pre-join :auth frame.
Initiates a graceful shutdown drain (1012 + :drain_session), invoking
socket.handle_info(:socket_drain, ...) when initialized.
Routes an inbound RFC 9297 WebTransport datagram through socket.handle_in/2.
Decodes inbound stream bytes into Phoenix frames (handling any pre-join
:auth frame first) and dispatches them through socket.handle_in/2.
Routes an Erlang message through socket.handle_info/2 and normalizes
pushes and 3/4/5-tuple :stop returns.
Initializes the Phoenix socket inside the session-owning process.
If pre-join auth is still pending, returns {:ok, engine} and initializes
automatically as soon as the :auth frame arrives.
Builds a new session engine from listener or router options.
Registers an inbound client stream.
Calls socket.terminate/2 idempotently when the session stops.