grizzly v0.8.2 Grizzly.Notifications View Source
A pubsub module for sending and receiving notifications to and from Grizzly.
Subscribing to Z-Wave messages
You can subscribe to notifications using:
Grizzly.Notifications.subscribe(topic)
or
Grizzly.Notifications.subscribe_all([topic1, topic2])
This will subscribe the calling process to the supplied topic(s). So, if you
are using iex
you can see recevied messages with flush
, although it would
be most useful from a GenServer
where you can use handle_info/2
to handle
the notifications.
The available topics are:
:controller_connected,
:connection_established,
:unsolicited_message,
:node_added,
:node_removed,
:node_updated
You can unsubscribe with:
Grizzly.Notifications.unsubscribe(topic)
Link to this section Summary
Functions
Broadcast a topic
to the processes that are subscribed
Broadcast a topic
and some data
with the topic. This will send
the subscriber a tuple in the shape of {topic, data}
Subscribe to a topic to receive messages
Subscribe to a list of topics
Unsubscribe from a topic
Link to this section Types
topic()
View Source
topic() ::
:controller_connected
| :connection_established
| :unsolicited_message
| :node_added
| :node_removed
| :node_updated
topic() :: :controller_connected | :connection_established | :unsolicited_message | :node_added | :node_removed | :node_updated
The topics that are allowed for Grizzly notifications
Link to this section Functions
broadcast(topic)
View Source
broadcast(topic()) :: :ok
broadcast(topic()) :: :ok
Broadcast a topic
to the processes that are subscribed
broadcast(topic, data) View Source
Broadcast a topic
and some data
with the topic. This will send
the subscriber a tuple in the shape of {topic, data}
child_spec(_) View Source
start_link() View Source
subscribe(topic)
View Source
subscribe(topic()) :: :ok | {:error, :already_subscribed}
subscribe(topic()) :: :ok | {:error, :already_subscribed}
Subscribe to a topic to receive messages
subscribe_all(topics)
View Source
subscribe_all([topic()]) :: :ok
subscribe_all([topic()]) :: :ok
Subscribe to a list of topics
unsubscribe(topic)
View Source
unsubscribe(topic()) :: :ok
unsubscribe(topic()) :: :ok
Unsubscribe from a topic