View Source Tamnoon.SocketHandler (Tamnoon v1.0.0-a.1)
A default :cowboy_websocket
implementation. Usually there should not be a reason to do anything
directly with this module, as it gets its options from Tamnoon.start_link/1
and
adapts to them automatically. However, it is still documented for the sake of allowing
extensiblity.
You can replace the module with a custom one via setting it as the (drumroll..) :socket_handler
key's value in Tamnoon.start_link/1
's options.
Summary
Functions
Initiates the websocket connection.
Receives a websocket request and decodes it, sending it to the Tamnoon.MethodManager.route_request/3
function.
Handles messages from other BEAM processes. By default it is only used for handling
"pub"
requests, and as such it simply forwards the message to websocket_handle/2
.
Initiates the websocket and adds the client to the registry under the "clients"
channel.
Functions
@spec init(:cowboy_req.req(), map()) :: {:cowboy_websocket, req :: :cowboy_req.req(), initial_state :: map(), opts :: map()}
Initiates the websocket connection.
@spec websocket_handle( {:text, tuple()}, map() ) :: {:reply, {:text, return_val :: String.t()}, new_state :: map()}
Receives a websocket request and decodes it, sending it to the Tamnoon.MethodManager.route_request/3
function.
@spec websocket_info(info :: map(), map()) :: {:reply, {:text, return_val :: String.t()}, new_state :: map()}
Handles messages from other BEAM processes. By default it is only used for handling
"pub"
requests, and as such it simply forwards the message to websocket_handle/2
.
Initiates the websocket and adds the client to the registry under the "clients"
channel.