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

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

@type 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.

@type 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

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

Incoming frames.

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

Incoming process messages.

@callback 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
@callback terminate(reason :: any(), req :: map(), state) :: :ok when state: any()

Websocket termination.