Fast RTPS  Version 2.1.0
Fast RTPS

Class SubscriberListener, it should be used by the end user to implement specific callbacks to certain actions. More...

#include <SubscriberListener.h>

Public Member Functions

 SubscriberListener ()
 
virtual ~SubscriberListener ()
 
virtual void onNewDataMessage (Subscriber *sub)
 Virtual function to be implemented by the user containing the actions to be performed when a new Data Message is received. More...
 
virtual void onSubscriptionMatched (Subscriber *sub, rtps::MatchingInfo &info)
 Virtual method to be called when the subscriber is matched with a new Writer (or unmatched); i.e., when a writer publishing in the same topic is discovered. More...
 
virtual void on_requested_deadline_missed (Subscriber *sub, const RequestedDeadlineMissedStatus &status)
 Virtual method to be called when a topic misses the deadline period. More...
 
virtual void on_liveliness_changed (Subscriber *sub, const LivelinessChangedStatus &status)
 Method called when the liveliness status associated to a subscriber changes. More...
 

Detailed Description

Class SubscriberListener, it should be used by the end user to implement specific callbacks to certain actions.

using namespace eprosima::pubsub;
using namespace eprosima::rtps;
//Create a class that inherits from SubscriberListener and implement the methods you need.
class TestTypeListener: public SubscriberListener{
public:
TestTypeListener(){};
~TestTypeListener(){};
{
cout <<"New Message"<<endl;
}
void onSubscriptionMatched(Subscriber* sub,MatchingInfo& info)
{
if(info.status == MATCHED_MATCHING)
cout << "Discovery"<<endl;
else if(info.status == REMOVED_MATCHING)
cout << "Publisher removed"<<endl;
}
};
//Somewhere in the code, create an object an register assign it to the subscriber.
TestTypeListener listener;
Subscriber* sub = DomainRTPSParticipant::createSubscriber(p,Rparam,(SubscriberListener*)&listener);
//...
//You can also create it and assign it later, although this is not recommended since the onSubscriptionMatched may not be called
// (if the discovery is performed before you assign the Listener.).
TestTypeListener listener2;
sub->assignListener((SubscriberListener*)&listener2);

Constructor & Destructor Documentation

◆ SubscriberListener()

SubscriberListener ( )
inline

◆ ~SubscriberListener()

virtual ~SubscriberListener ( )
inlinevirtual

Member Function Documentation

◆ on_liveliness_changed()

virtual void on_liveliness_changed ( Subscriber sub,
const LivelinessChangedStatus status 
)
inlinevirtual

Method called when the liveliness status associated to a subscriber changes.

Parameters
subThe subscriber
statusThe liveliness changed status

◆ on_requested_deadline_missed()

virtual void on_requested_deadline_missed ( Subscriber sub,
const RequestedDeadlineMissedStatus status 
)
inlinevirtual

Virtual method to be called when a topic misses the deadline period.

Parameters
subSubscriber
statusThe requested deadline missed status

◆ onNewDataMessage()

virtual void onNewDataMessage ( Subscriber sub)
inlinevirtual

Virtual function to be implemented by the user containing the actions to be performed when a new Data Message is received.

Parameters
subSubscriber

◆ onSubscriptionMatched()

virtual void onSubscriptionMatched ( Subscriber sub,
rtps::MatchingInfo &  info 
)
inlinevirtual

Virtual method to be called when the subscriber is matched with a new Writer (or unmatched); i.e., when a writer publishing in the same topic is discovered.

Parameters
subSubscriber
infoMatching information

The documentation for this class was generated from the following file:
eprosima::fastrtps::SubscriberListener::SubscriberListener
SubscriberListener()
Definition: SubscriberListener.h:44
eprosima::fastrtps::SubscriberListener::onSubscriptionMatched
virtual void onSubscriptionMatched(Subscriber *sub, rtps::MatchingInfo &info)
Virtual method to be called when the subscriber is matched with a new Writer (or unmatched); i....
Definition: SubscriberListener.h:62
eprosima::fastrtps::SubscriberListener::onNewDataMessage
virtual void onNewDataMessage(Subscriber *sub)
Virtual function to be implemented by the user containing the actions to be performed when a new Data...
Definition: SubscriberListener.h:52