Subscribe to Alarm Active
In many cases, a requestor needs to know when property values have changed. The subscribe operation allows a requestor to be notified when a provider changes a property value. The DOFSubscription is a tool that creates and maintains a subscribe operation to a provider.
Subscribing to a Property
If all of the following conditions are true, the provider does not need to do any additional work to implement subscribe operations:
- You have already implemented the get callback for the property.
- You are extending the DefaultProvider class (meaning the subscribe callback from the Provider interface has been implemented). The default behavior is to automatically accept subscribe requests. Note: The subscribe method is for the provider’s internal use. For example, you could use it if you want the provider to track the requestors that are subscribed to a property. If you do override this method, you must ensure that you call DOFRequest.respond. Returning an exception in the respond method causes the requestor’s subscription to fail.
- There is no way for the property value to change other than through set operations from requestors. The library automatically notifies subscribed requestors if the property value changes through a set operation. If, however, the property can be changed by the invoke callback or you have internal application logic that can cause a property value to change, you must call the changed method.
How It Works
A subscribe operation is initiated by the requestor to receive notifications when a property is changed.