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

Copy Markdown View Source

Examples of subscription management with WebSocket connections.

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.