grizzly v0.8.5 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 received 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

Types

The topics that are allowed for Grizzly notifications

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

Link to this type

topic() View Source
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

Link to this function

broadcast(topic) View Source
broadcast(topic()) :: :ok

Broadcast a topic to the processes that are subscribed

Link to this function

broadcast(topic, data) View Source
broadcast(topic(), data :: any()) :: :ok

Broadcast a topic and some data with the topic. This will send the subscriber a tuple in the shape of {topic, data}

Link to this function

subscribe(topic) View Source
subscribe(topic()) :: :ok | {:error, :already_subscribed}

Subscribe to a topic to receive messages

Link to this function

subscribe_all(topics) View Source
subscribe_all([topic()]) :: :ok

Subscribe to a list of topics

Link to this function

unsubscribe(topic) View Source
unsubscribe(topic()) :: :ok

Unsubscribe from a topic