eclipse-cyclonedds / cyclonedds-cxx

Other
96 stars 75 forks source link

Passing dds::domain::DomainParticipantListener to dds::domain::DomainParticipant does not listen for DataWriter events #427

Open Progeny42 opened 1 year ago

Progeny42 commented 1 year ago

I'm using tag v0.10.3.

When creating a dds::domain::DomainParticipant, passing the ExampleListener class as per the docs as the listener parameter, and a StatusMask of all(), it appears that DataWriter callbacks are not being handled.

For example, I would expect to see on_publication_matched being called.

From looking at CycloneDDS\include\ddscxx\org\eclipse\cyclonedds\domain\DomainParticipantDelegate.hpp, there appears to only be handlers for DataReaderListener events.

eboasson commented 1 year ago

@e-hndrks is currently fixing some issues with listeners (#420 and https://github.com/eclipse-cyclonedds/cyclonedds/pull/1717) and it would be good to see if this issue still exists with his work.

binbowang1987 commented 1 year ago

https://github.com/eclipse-cyclonedds/cyclonedds-cxx/pull/420 and https://github.com/eclipse-cyclonedds/cyclonedds/pull/1717 is to fix listener problem in subscriber.
This problem is in publisher and it still exists.
From DomainParticipantDelegate.hpp, we can see the writer related listener callback is not implemented. https://github.com/eclipse-cyclonedds/cyclonedds-cxx/blob/d7d2578e5c4e3ecab41963ceed175ce14899b474/src/ddscxx/include/org/eclipse/cyclonedds/domain/DomainParticipantDelegate.hpp#L150-L167

When set writer related listeners on Participant, the default implementation in EntityDelegate will be called and will cause assert. https://github.com/eclipse-cyclonedds/cyclonedds-cxx/blob/d7d2578e5c4e3ecab41963ceed175ce14899b474/src/ddscxx/src/org/eclipse/cyclonedds/core/EntityDelegate.cpp#L320-L360

e-hndrks commented 1 year ago

Hi @binbowang1987, thanks for bringing this to our attention. The fact that Writer events didn't propagate all the way to the participant wasn't caused by the fix for #420, but has already been a bug since the initial commit of the C++ API, Due to the fact we didn't have a testcase covering this use-case, it went unnoticed until you ran into it. I have created a pull request in https://github.com/eclipse-cyclonedds/cyclonedds-cxx/pull/452 that should tackle this problem, in which I also added a testcase to cover this particular scenario.