Ircxd.WebSocket.Adapter behaviour (ircxd v1.1.0)

Copy Markdown View Source

Behaviour for host-application WebSocket adapters.

ircxd keeps WebSocket support at the IRC protocol boundary: it validates IRCv3 WebSocket payloads and asks an adapter owned by the host application to deliver those payloads over Phoenix Channels, Cowboy, Bandit, or another WebSocket stack.

Summary

Types

The WebSocket frame type.

Host-application WebSocket state.

Callbacks

Closes the host WebSocket connection.

Sends one validated IRC payload in a WebSocket frame.

Types

mode()

@type mode() :: :binary | :text

The WebSocket frame type.

state()

@type state() :: term()

Host-application WebSocket state.

Callbacks

close(state, term)

(optional)
@callback close(state(), term()) :: :ok | {:error, term()}

Closes the host WebSocket connection.

send_frame(state, mode, binary)

@callback send_frame(state(), mode(), binary()) :: :ok | {:error, term()}

Sends one validated IRC payload in a WebSocket frame.