Aino.WebSocket.Handler behaviour (aino v0.2.0)

Process an incoming websocket from Aino

Link to this section Summary

Callbacks

Handle incoming text data

Handle internal Erlang messages

Called during websocket initialization

Link to this section Callbacks

Link to this callback

handle(token, data)

Specs

handle(token :: map(), data :: String.t()) :: map()

Handle incoming text data

Token is a map with the state's session data, any updates in this map will be preserved. If the response key is present, it will be sent to the browser.

Link to this callback

info(token, message)

Specs

info(token :: map(), message :: any()) :: map()

Handle internal Erlang messages

Token is a map with the state's session data, any updates in this map will be preserved. If the response key is present, it will be sent to the browser.

Specs

init(state :: map()) :: {:ok, map()}

Called during websocket initialization

Chance to hook into initialization and modify the state based on data in the request. For instance, load the current user based on session data.