Basic WebSocket client supervision example.
Shows minimal setup for supervised connections. For advanced patterns, see the supervision documentation.
Summary
Functions
Lists all supervised connections.
Starts a supervised WebSocket connection.
Starts multiple supervised connections.
Stops a supervised connection.
Functions
@spec list_connections() :: [pid()]
Lists all supervised connections.
@spec start_connection( String.t(), keyword() ) :: {:ok, ZenWebsocket.Client.t()} | {:error, term()}
Starts a supervised WebSocket connection.
Example
{:ok, client} = SupervisedClient.start_connection("wss://echo.websocket.org")
@spec start_multiple([{String.t(), keyword()}]) :: [ {String.t(), {:ok, ZenWebsocket.Client.t()} | {:error, term()}} ]
Starts multiple supervised connections.
Example
clients = SupervisedClient.start_multiple([
{"wss://api1.example.com", retry_count: 5},
{"wss://api2.example.com", heartbeat_interval: 20_000}
])
@spec stop_connection(pid()) :: :ok | {:error, :not_found}
Stops a supervised connection.