You are here: Part 2: Core Concepts > DDS Entities > Listeners > Types of Listeners

Types of Listeners

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:

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.

Effect of Different Combinations of Listeners and Status Bit Masks

 

No Bits Set in Mask

Some/All Bits Set in Mask

Listener is Specified

Connext DDS finds the next most relevant listener for the changed status.

For the statuses that are enabled in the mask, the most relevant listener will be called.

The 'statusChangedFlag' for the relevant status is reset.

Listener is NULL

Connext DDS behaves as if the listener is not installed and finds the next most relevant listener for that status.

Connext DDS behaves as if the listener callback is installed, but the callback is doing nothing. This is called a ‘nil’ listener.

© 2016 RTI