DDS Python API - Listener assignment

4 posts / 0 new
Last post
Offline
Last seen: 2 weeks 3 days ago
Joined: 11/23/2021
Posts: 27
DDS Python API - Listener assignment

Hello @All,

I have a general question regarding the creation of listeners.
Lets assume I assign data reader listener (AnyReaderListener()) to e.g. a participant like follows:

dds.DomainParticipant(domain_id, participant_qos, AnyListener())

Does that automatically mean that every data Reader within this participant will be assigned with the AnyReaderListener()?

Best Regards,

Marc

Howard's picture
Offline
Last seen: 13 hours 52 min ago
Joined: 11/29/2012
Posts: 399

I don't believe that you can assign a DataReaderListener to a DomainParticipant.

DomainParticipants use DomainParticipantListeners, which derive from PublisherListener/SubscriberListener/TopicListener (multiple inheritance) and PublisherListener derives from DataWriterListener and SubscriberListener derives from DataReaderListener.

So, in short, you would need to create your own class derived from

class rti.connextdds.NoOpDomainParticipantListener
(recommended since you would not have to implement all of the virtual methods...only the ones that you want)
and bind it to the DomainParticipant.
BUT if you do so, then yes, all StatusEvents triggered by any contained DataReaders would be sent to the DomainParticipant and the corresponding listener method invoked to process IF AND ONLY IF the DataReader itself doesn't have a listener installed to process the event...nor the Subscriber parent object has a listener that is installed to process the event.
Offline
Last seen: 2 weeks 3 days ago
Joined: 11/23/2021
Posts: 27

Hello Howard,

Thanks for the reply!
Colud you explain me what is the difference between NoOpDataReaderListener and NoOpAnyDataReaderListener?

Regards,

Marc

Howard's picture
Offline
Last seen: 13 hours 52 min ago
Joined: 11/29/2012
Posts: 399

Don't use the NoOpAnyDataReaderListener.  The AnyDataReader is really an internal implementation detail and is being redesigned in the next version of the API to be released in 2023.  The NoOpDataReaderListener should be the way to go.