Publisher Listener¶
PublisherListener is an abstract class defining the callbacks that will be triggered in response to state changes on the Publisher.
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.
PublisherListener inherits from DataWriter Listener.
Therefore, it has the ability to react to all events that are reported to the DataWriter.
Since events are always notified to the most specific Entity Listener that can handle the event, callbacks that PublisherListener inherits from DataWriter Listener will only be called if the triggered DataWriter has no Listener attached, or if the callback is disabled by the StatusMask on the DataWriter.
PublisherListener does not add any new callback.
Please, refer to the DataWriter Listener for the list of inherited callbacks.
Example¶
class CustomPublisherListener :
public PublisherListener
{
void on_publication_matched(
DataWriter& /* writer */,
const PublicationMatchedStatus& /* info */) noexcept override
{
std::cout << "Publication matched" << std::endl;
}
void on_offered_deadline_missed(
DataWriter& /* writer */,
const OfferedDeadlineMissedStatus& /* status */) noexcept override
{
std::cout << "Offered deadline missed in datawriter" << std::endl;
}
void on_offered_incompatible_qos(
DataWriter& /* writer */,
const OfferedIncompatibleQosStatus& /* status */) noexcept override
{
std::cout << "Offered incompatible QoS in datawriter" << std::endl;
}
void on_liveliness_lost(
DataWriter& /* writer */,
const LivelinessLostStatus& /* status */) noexcept override
{
std::cout << "Liveliness lost in datawriter" << std::endl;
}
};