Fast RTPS  Version 2.14.1
Fast RTPS
Loading...
Searching...
No Matches

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.
 
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.
 
virtual void on_requested_deadline_missed (Subscriber *sub, const RequestedDeadlineMissedStatus &status)
 Virtual method to be called when a topic misses the deadline period.
 
virtual void on_liveliness_changed (Subscriber *sub, const LivelinessChangedStatus &status)
 Method called when the liveliness status associated to a subscriber changes.
 

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()
{
}
void onNewDataMessage()
{
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);
Class SubscriberListener, it should be used by the end user to implement specific callbacks to certai...
Definition SubscriberListener.h:41
SubscriberListener()
Definition SubscriberListener.h:44

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: