ZenWebsocket.Examples.Docs.SubscriptionManagement (ZenWebsocket v0.8.0)

Copy Markdown View Source

Channel subscription flows over a WebSocket connection.

Sends multi-channel subscribe payloads with Client.send_message/2 and consumes the resulting {:websocket_message, _} frames the default handler forwards to the calling process, both one at a time and in a collect-N loop.

Summary

Functions

Process market data updates with pattern matching.

Subscribe to multiple data streams using echo server.

Subscribe and process messages in a loop.

Functions

handle_market_data(timeout \\ 5000)

@spec handle_market_data(timeout()) ::
  {:market_update, String.t(), term()}
  | {:message, map()}
  | {:text_message, String.t()}
  | {:closed, term()}
  | {:error, :timeout}

Process market data updates with pattern matching.

multi_channel_subscription()

@spec multi_channel_subscription() :: {:ok, ZenWebsocket.Client.t(), [String.t()]}

Subscribe to multiple data streams using echo server.

subscription_loop(client, channels, message_count \\ 5)

@spec subscription_loop(ZenWebsocket.Client.t(), [String.t()], non_neg_integer()) ::
  {:ok, [term()]} | {:error, :timeout, [term()]}

Subscribe and process messages in a loop.