buckaroo v0.3.0 Buckaroo.Socket behaviour 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

Link to this type

frame()

View Source
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.

Link to this type

result(state)

View Source
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

Link to this callback

handle(frame, state)

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

Incoming frames.

Link to this callback

info(any, state)

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

Incoming process messages.

Link to this callback

init(conn, state)

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

Websocket termination.