Notifications
Use the following methods to subscribe to a notification, publish a notification with specified data, and unsubscribe from a notification. This allows scripts running within the same Core to communicate with each other using control wiring or Component.
Methods
Name |
Attribute/Arguments |
Comment |
---|---|---|
noteid = Notifications.Subscribe() |
name, function |
Subscribe to a notification with a given name.
|
Notifications.Publish() |
name, data |
Publish a named notification with given data. The data can be either a Lua table or a string. Note: You cannot call the Notifications.Publish() method inside a Notifications.Subscribe() callback. This will raise a Lua error. |
Notifications.Unsubscribe() |
noteid |
Unsubscribe from a notification with the specified noteid. |
In this example, two Scriptable Controls components are configured - Thing 1 and Thing 2. Control wiring connects exposed Code control pins. Thing 1 is subscribed to receive notifications from Thing 2 and vice versa. When the Send button is pushed on one component, the other receives the Send String text and the Received LED illuminates. If the Unsubscribe button is pushed, notifications are no longer received from the other component.
See the table below for the complete Lua code example from each Scriptable Controls component. All Notifications methods are used in this example.
Note: In Q-SYS Designer version 7.2 and higher, the Text Controller component replaces Scriptable Controls.
Thing 1 | Thing 2 |
---|---|
Copy
|
Copy
|