View Source Wobserver.Web.Client (Wobserver NG v1.14.0)

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.

Gracefully handles websocked terminate.

Handles incoming messages from the websocket client.

Handles incoming messages from processes.

Initialize the websocket connection by calling the implementing client.

Link to this section Functions

Link to this function

client_handle(command, state)

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

@spec client_info(any(), state :: map()) :: {:noreply, map()}

Handles process messages.

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

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

Starts the websocket client.

Returns a map as state.

Initialize the websocket connection.

Link to this function

terminate(reason, partial_req, state)

View Source

Gracefully handles websocked terminate.

The reason, req and state are ignored.

Link to this function

websocket_handle(message, state)

View Source
@spec websocket_handle(
  {:text, String.t()},
  state :: any()
) :: {:reply, {:text, String.t()}, any()} | {:ok, 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.

Link to this function

websocket_info(message, state)

View Source
@spec websocket_info(message :: any(), state :: any()) ::
  {:reply, {:text, String.t()}, any()} | {:ok, any()}

Handles incoming messages from processes.

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

@spec websocket_init(any()) :: {:ok, any()}

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.