ws_session (ws v0.1.1)
View SourceWebSocket session state machine.
Owns a single stream handle (supplied by the embedder through a ws_transport callback), drives the frame codec, auto-responds to control frames, and dispatches inbound messages to the user handler module.
States: open — handshake complete, frames flowing in both directions. closing — a close frame was sent or received; the other direction may still finish. closed — both directions closed; the process is about to exit.
Inbound-byte delivery is pull-based: after consuming a chunk the session calls TransportMod:activate/1 to request the next one. The transport signals fresh bytes with {ws_data, Handle, Bin}, peer close with {ws_closed, Handle}, and socket-level errors with {ws_error, Handle, Reason}.
Summary
Functions
Tell the session the embedder has finished transport setup (ownership transfer and friends) — the session may now read bytes.
Types
Functions
-spec activate(pid()) -> ok.
Tell the session the embedder has finished transport setup (ownership transfer and friends) — the session may now read bytes.
-spec close(pid(), ws_close:code()) -> ok.
-spec close(pid(), ws_close:code(), iodata()) -> ok.
-spec send(pid(), ws_frame:frame() | [ws_frame:frame()]) -> ok.
-spec start(start_opts()) -> {ok, pid()} | {error, term()}.
-spec start_link(start_opts()) -> {ok, pid()} | {error, term()}.
-spec stop(pid()) -> ok.