ZenWebsocket.Client.Frames (ZenWebsocket v0.8.0)

Copy Markdown View Source

Inbound WebSocket frame routing for ZenWebsocket.Client.

Summary

Functions

Routes a Gun WebSocket frame: heartbeat tracking, control-frame decode, then data dispatch.

Restores subscriptions after reconnection if configured.

Routes data frames to heartbeat, subscription, JSON-RPC, or the user handler.

Sends a text frame, correlating JSON-RPC requests that carry an id.

Functions

handle_ws(state, gun_pid, stream_ref, frame)

@spec handle_ws(map(), pid(), reference(), term()) ::
  {:noreply, map()} | {:stop, term(), map()}

Routes a Gun WebSocket frame: heartbeat tracking, control-frame decode, then data dispatch.

maybe_restore_subscriptions(state)

@spec maybe_restore_subscriptions(map()) :: map()

Restores subscriptions after reconnection if configured.

route_data_frame(frame, state)

@spec route_data_frame(term(), map()) :: map()

Routes data frames to heartbeat, subscription, JSON-RPC, or the user handler.

send_text(state, gun_pid, stream_ref, message, from)

@spec send_text(map(), pid(), reference(), binary(), GenServer.from()) ::
  {:noreply, map()} | {:reply, term(), map()}

Sends a text frame, correlating JSON-RPC requests that carry an id.