Wobserver v0.1.7 Wobserver.Web.Client

Modules handles WebSocket connects to the client.

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

Functions

client_handle(command, state)
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.

client_info(do, state)
client_info(any, state :: map) :: {:noreply, map}

Handles process messages.

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

client_init()
client_init() :: {:ok, map}

Starts the websocket client.

Returns a map as state.

init(, req, options)
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.

websocket_handle(message, req, state)
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.

websocket_info(message, req, state)
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.

websocket_init(type, req, options)
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.

websocket_terminate(reason, req, state)
websocket_terminate({atom, any}, :cowboy_req.req, any) :: :ok

Gracefully handles websocked terminate.

The reason, req and state are ignored.