View Source Tulle.Websocket behaviour (tulle v0.7.2)

Websocket client, implemented as a Genserver.

use'ing this module defines a child_spec functions, and defines @behaviour Tulle.Websocket.

Summary

Types

Must have :url, optionally can have :headers and :extensions. (defaults to PerMessageDeflate).

Types

@type code() :: 1000..4999
@type conn_opts() :: Access.t()

Must have :url, optionally can have :headers and :extensions. (defaults to PerMessageDeflate).

@type handle_result() ::
  {:ok, state :: any()}
  | {:push, message() | [message()], state :: any()}
  | {:close, code() | {code(), binary()}, state :: any()}
@type message() :: {:text | :binary, binary()}

Callbacks

@callback handle_connect(state :: any()) :: handle_result()
Link to this callback

handle_in(message, state)

View Source
@callback handle_in(message(), state :: any()) :: handle_result()
Link to this callback

handle_remote_close(arg1, reason, state)

View Source
@callback handle_remote_close(code() | nil, reason :: binary() | nil, state :: any()) ::
  any()

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec close(GenServer.server(), 1000..4999) ::
  :ok | {:unclean, term()} | {:error, term()}
@spec send(GenServer.server(), :binary | :text, binary() | String.t()) ::
  :ok | {:error, term()}
Link to this function

start_link(module, init_args, conn_opts, opts \\ [])

View Source
@spec start_link(WebSock.impl(), any(), conn_opts(), GenServer.options()) ::
  GenServer.on_start()