Subscriber Listener
SubscriberListener is an abstract class defining the callbacks that will be triggered in response to state changes on the Subscriber.
By default, all these callbacks are empty and do nothing.
Implementations of this class shall override the callbacks that are needed on the application.
Callbacks that are not overridden will maintain their empty implementation.
SubscriberListener inherits from DataReader Listener.
Therefore, it has the ability to react to all events that are reported to the DataReader.
Since events are always notified to the most specific Entity Listener that can handle the event, callbacks that SubscriberListener inherits from DataReaderListener will only be called if the triggering DataReader has no Listener attached, or if the callback is disabled by the StatusMask on the DataReader.
Additionally, SubscriberListener adds the following callback:
SubscriberListener::on_data_on_readersNew data is available on any DataReader belonging to this Subscriber. There is no queuing of invocations to this callback, meaning that if several new data changes are received at once, only one callback invocation may be issued for all of them, instead of one per change. If the application is retrieving the received data on this callback, it must keep reading data until no new changes are left.
Example
class CustomSubscriberListener :
public SubscriberListener
{
void on_data_on_readers(
Subscriber& /* subscriber */) noexcept override
{
std::cout << "Data on readers" << std::endl;
}
void on_data_available(
DataReader& /* reader */) noexcept override
{
std::cout << "Data available on datareader" << std::endl;
}
void on_subscription_matched(
DataReader& /* reader */,
const SubscriptionMatchedStatus& /* info */) noexcept override
{
std::cout << "Subscription matched" << std::endl;
}
void on_requested_deadline_missed(
DataReader& /* reader */,
const RequestedDeadlineMissedStatus& /* status */) noexcept override
{
std::cout << "Requested deadline missed in datareader" << std::endl;
}
void on_liveliness_changed(
DataReader& /* reader */,
const LivelinessChangedStatus& /* status */) noexcept override
{
std::cout << "Liveliness changed in datareader" << std::endl;
}
void on_sample_rejected(
DataReader& /* reader */,
const SampleRejectedStatus& /* status */) noexcept override
{
std::cout << "Sample rejected in datareader" << std::endl;
}
void on_requested_incompatible_qos(
DataReader& /* reader */,
const RequestedIncompatibleQosStatus& /* status */) noexcept override
{
std::cout << "Requested incompatible QoS in datareader" << std::endl;
}
void on_sample_lost(
DataReader& /* reader */,
const SampleLostStatus& /* status */) noexcept override
{
std::cout << "Sample lost in datareader" << std::endl;
}
};