The Listener class is the abstract base class for all listeners. Each entity class (DomainParticipant, Topic, Publisher, DataWriter, Subscriber, and DataReader) has its own derived Listener class that add methods for handling entity-specific statuses. The hierarchy of Listener classes is presented in Figure 4. The methods are called by an internal Connext DDS thread when the corresponding status for the Entity changes value.
Figure 4 Listener Class Hierarchy
You can choose which changes in status will trigger a callback by installing a listener with a bit-mask. Bits in the mask correspond to different statuses. The bits that are true indicate that the listener will be called back when there are changes in the corresponding status.
You can specify a listener and set its bit-mask before or after you create an Entity:
DDS_StatusMask mask = DDS_REQUESTED_DEADLINE_MISSED_STATUS | DDS_DATA_AVAILABLE_STATUS; datareader = subscriber->create_datareader(topic, DDS_DATAREADER_QOS_DEFAULT, listener, mask);
DDS_StatusMask mask = DDS_REQUESTED_DEADLINE_MISSED_STATUS | DDS_DATA_AVAILABLE_STATUS; datareader->set_listener(listener, mask);
As you can see in the above examples, there are two components involved when setting up listeners: the listener itself and the mask. Both of these can be null. describes what happens when a status change occurs. See Hierarchical Processing of Listeners for more information.
© 2016 RTI