Buckaroo.Socket behaviour (buckaroo v0.3.2) View Source

A simple websocket implementation.

Link to this section Summary

Types

Websocket frames.

Websocket callback result.

Callbacks

Incoming frames.

Incoming process messages.

Initialize the websocket.

Websocket termination.

Link to this section Types

Specs

frame() :: :ping | :pong | {:text | :binary | :ping | :pong, binary()}

Websocket frames.

Note that there is no need to send pong frames back as Cowboy does it automatically for you.

Specs

result(state) ::
  {:ok, state}
  | {:ok, state, :hibernate}
  | {:reply, frame() | [frame()], state}
  | {:reply, frame() | [frame()], state, :hibernate}
  | {:stop, state}

Websocket callback result.

Link to this section Callbacks

Specs

handle(frame(), state) :: result(state) when state: any()

Incoming frames.

Specs

info(any(), state) :: result(state) when state: any()

Incoming process messages.

Specs

init(conn :: Plug.Conn.t(), state :: state) :: result(state) when state: any()

Initialize the websocket.

Passes the connection and the given state.

Link to this callback

terminate(reason, req, state)

View Source

Specs

terminate(reason :: any(), req :: map(), state) :: :ok when state: any()

Websocket termination.