Wobserver v0.1.8 Wobserver.Web.Client View Source

Modules handles WebSocket connects to the client.

Link to this section Summary

Functions

Handles the command given by the websocket interface

Handles process messages

Starts the websocket client

Initialize the websocket connection

Handles incoming messages from the websocket client

Handles incoming messages from processes

Initialize the websocket connection by calling the implementing client

Gracefully handles websocked terminate

Link to this section Functions

Link to this function client_handle(command, state) View Source
client_handle(atom | [atom], state :: map) ::
  {:reply, atom | [atom], map, map} |
  {:reply, atom | [atom], map} |
  {:noreply, map}

Handles the command given by the websocket interface.

The current state is passed and can be modified.

Returns a map as state.

Link to this function client_info(do, state) View Source
client_info(any, state :: map) :: {:noreply, map}

Handles process messages.

Should not be used, the do is ignored and the state is returned unmodified.

Link to this function client_init() View Source
client_init() :: {:ok, map}

Starts the websocket client.

Returns a map as state.

Link to this function init(_, req, options) View Source
init(any, :cowboy_req.req, any) :: {:upgrade, :protocol, :cowboy_websocket}

Initialize the websocket connection.

The req cowboy request and options are passed, but unused in the setup.

Link to this function websocket_handle(message, req, state) View Source
websocket_handle({:text, String.t}, req :: :cowboy_req.req, state :: any) ::
  {:reply, {:text, String.t}, :cowboy_req.req, any} |
  {:ok, :cowboy_req.req, any}

Handles incoming messages from the websocket client.

The message is parsed and passed on to the client, which responds with an update state and possible reply.

The req is ignored.

Link to this function websocket_info(message, req, state) View Source
websocket_info(message :: any, req :: :cowboy_req.req, state :: any) ::
  {:reply, {:text, String.t}, :cowboy_req.req, any} |
  {:ok, :cowboy_req.req, any}

Handles incoming messages from processes.

The message is passed on to the client, which responds with an update state and possible reply.

The req is ignored.

Link to this function websocket_init(type, req, options) View Source
websocket_init(any, req :: :cowboy_req.req, any) :: {:ok, :cowboy_req.req, any, non_neg_integer}

Initialize the websocket connection by calling the implementing client.

The req cowboy request is passed along to the client.

The type and options are passed, but unused in the setup.

Link to this function websocket_terminate(reason, req, state) View Source
websocket_terminate({atom, any}, :cowboy_req.req, any) :: :ok

Gracefully handles websocked terminate.

The reason, req and state are ignored.