eclipse-cyclonedds/cyclonedds-cxx

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

Progeny42 opened this issue · 3 comments

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.

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

#420 and eclipse-cyclonedds/cyclonedds#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.

// Subscriber events
virtual void on_data_readers(dds_entity_t subscriber);
// Reader events
void on_requested_deadline_missed(dds_entity_t reader,
org::eclipse::cyclonedds::core::RequestedDeadlineMissedStatusDelegate &sd);
void on_requested_incompatible_qos(dds_entity_t reader,
org::eclipse::cyclonedds::core::RequestedIncompatibleQosStatusDelegate &sd);
void on_sample_rejected(dds_entity_t reader,
org::eclipse::cyclonedds::core::SampleRejectedStatusDelegate &sd);
void on_liveliness_changed(dds_entity_t reader,
org::eclipse::cyclonedds::core::LivelinessChangedStatusDelegate &sd);
void on_data_available(dds_entity_t reader);
void on_subscription_matched(dds_entity_t reader,
org::eclipse::cyclonedds::core::SubscriptionMatchedStatusDelegate &sd);
void on_sample_lost(dds_entity_t reader,
org::eclipse::cyclonedds::core::SampleLostStatusDelegate &sd);

When set writer related listeners on Participant, the default implementation in EntityDelegate will be called and will cause assert.

void org::eclipse::cyclonedds::core::EntityDelegate::on_offered_deadline_missed
(dds_entity_t, org::eclipse::cyclonedds::core::OfferedDeadlineMissedStatusDelegate &)
{
assert (false);
}
void org::eclipse::cyclonedds::core::EntityDelegate::on_offered_incompatible_qos
(dds_entity_t, org::eclipse::cyclonedds::core::OfferedIncompatibleQosStatusDelegate &)
{
assert (false);
}
void org::eclipse::cyclonedds::core::EntityDelegate::on_liveliness_lost
(dds_entity_t, org::eclipse::cyclonedds::core::LivelinessLostStatusDelegate &)
{
assert (false);
}
void org::eclipse::cyclonedds::core::EntityDelegate::on_publication_matched
(dds_entity_t, org::eclipse::cyclonedds::core::PublicationMatchedStatusDelegate &)
{
assert (false);
}
void org::eclipse::cyclonedds::core::EntityDelegate::on_requested_deadline_missed
(dds_entity_t, org::eclipse::cyclonedds::core::RequestedDeadlineMissedStatusDelegate &)
{
assert (false);
}
void org::eclipse::cyclonedds::core::EntityDelegate::on_requested_incompatible_qos
(dds_entity_t, org::eclipse::cyclonedds::core::RequestedIncompatibleQosStatusDelegate &)
{
assert (false);
}
void org::eclipse::cyclonedds::core::EntityDelegate::on_sample_rejected
(dds_entity_t, org::eclipse::cyclonedds::core::SampleRejectedStatusDelegate &)
{
assert (false);
}

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 #452 that should tackle this problem, in which I also added a testcase to cover this particular scenario.