A GenServer that owns a connection and retries it with backoff.
Demonstrates owning a Client.connect/2 result in GenServer state, rescheduling
Client.connect/2 on failure while counting attempts, and handling the
{:websocket_message, _}, {:websocket_unmatched_response, _} and
{:websocket_protocol_error, _} messages the default handler forwards to the owning
process. Those three are the only messages ZenWebsocket.Client.CallFacade sends; a
transport error surfaces as a {:error, reason} return from Client.connect/2 or
Client.send_message/2, never as a mailbox message.
Summary
Functions
Returns a specification to start this module under a supervisor.
Returns the current state of the error handler.
Sends a message through the WebSocket connection.
Starts a GenServer that manages a WebSocket connection with automatic retry.
Types
@type state() :: %{ client: pid() | nil, url: String.t(), opts: keyword(), retry_count: non_neg_integer() }
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get_state() :: state()
Returns the current state of the error handler.
Returns
The internal state map including connection status and retry count.
Sends a message through the WebSocket connection.
Parameters
message- Message to send (must be a binary — useJason.encode!/1for maps)
Returns
:okon success{:error, :not_connected}if not connected{:error, {:not_connected, reason}}if client is disconnected or process is down
@spec start_link( String.t(), keyword() ) :: GenServer.on_start()
Starts a GenServer that manages a WebSocket connection with automatic retry.
Parameters
url- WebSocket URL to connect toopts- Connection options
Returns
{:ok, pid} on success or {:error, reason} on failure.