eclipse-cyclonedds / cyclonedds-cxx

Other
93 stars 74 forks source link

why Publisher events Listener annotation? #474

Open Autostone-c opened 6 months ago

Autostone-c commented 6 months ago

hi,When I read the code for ddscxx, I found that many of the Publisher events Listener APIs were commented out in PublisherListener.hpp. Why?Is it because these APIs are useless? Or other reasons

image

eboasson commented 6 months ago

That's actually part of the documentation. If you want to use a listener you have to create your own listener class that inherits from dds::pub::PublisherListener and this example hopefully helps you get started.

Autostone-c commented 6 months ago

这实际上是文档的一部分。如果您想使用侦听器,您必须创建自己的侦听器类并继承自该侦听器类dds::pub::PublisherListener,此示例希望可以帮助您入门。

i saw it. could you give me some examples for source code implementation

eboasson commented 6 months ago

I don't quite understand what you're looking for. You should be able to take that code and create a publisher that uses that listener object. That is so straightforward you surely can't be asking for it.

Whether or not those listeners will get invoked depends on whether the writers in the publisher have listeners for the same events. If a writer has a listener for on_offered_incompatible_qos, then that listener gets invoked when a reader with an incompatible QoS setting is discovered, not the one on the publisher.

Maybe that's what you were wondering about?