OffBroadwayWebSocket.Client (off_broadway_websocket v1.0.2)

Provides functions to establish and configure WebSocket connections using the gun library, with customizable timeouts and connection options.

Summary

Functions

Establishes a WebSocket connection to the specified URL and path with optional gun options, and customizable timeouts.

Functions

connect(url, path, gun_opts, await_timeout, headers \\ [])

@spec connect(
  url :: String.t(),
  path :: String.t(),
  gun_opts :: map(),
  await_timeout :: non_neg_integer(),
  headers :: [{String.t(), String.t()}]
) :: {:ok, %{conn_pid: pid(), stream_ref: reference()}} | {:error, term()}

Establishes a WebSocket connection to the specified URL and path with optional gun options, and customizable timeouts.

Parameters

  • url: The base URL for the WebSocket connection (e.g., "wss://example.com").
  • path: The WebSocket path to upgrade to (e.g., "/ws").
  • gun_opts: A map containing :gun configuration.
  • await_timeout: The timeout in milliseconds to wait for the connection to become ready.
  • connect_timeout: The timeout in milliseconds for establishing the connection.

Returns

  • } on a successful connection and upgrade.
  • if the connection or upgrade fails.