SimpleMqtt.Subscriptions (simple_mqtt v0.1.0) View Source

Represents collection of subscribed topics for multiple processes.

Link to this section Summary

Functions

Returns pids for all processes that subscribed to topics that match the given published topic.

Creates new subscriptions collection.

Adds a new subscription to the collection. If the same pid was already registered, the topics will be merged.

Removes topics from the subscription.

Link to this section Types

Specs

subscriptions() :: %{}

Link to this section Functions

Link to this function

list_matched(subscriptions, topic)

View Source

Specs

list_matched(subscriptions(), String.t()) :: :error | [pid()]

Returns pids for all processes that subscribed to topics that match the given published topic.

Specs

new() :: subscriptions()

Creates new subscriptions collection.

Link to this function

subscribe(subscriptions, pid, topics)

View Source

Specs

subscribe(subscriptions(), pid(), [String.t()]) :: :error | subscriptions()

Adds a new subscription to the collection. If the same pid was already registered, the topics will be merged.

Link to this function

unsubscribe(subscriptions, pid, topics)

View Source

Specs

unsubscribe(subscriptions(), pid(), [String.t()] | :all) ::
  :error | {:empty, subscriptions()} | {:not_empty, subscriptions()}

Removes topics from the subscription.