ndn::util::NotificationSubscriber< Notification > Class Template Reference

Provides the subscriber side of a Notification Stream. More...

#include <ndn-cxx/util/notification-subscriber.hpp>

+ Inheritance diagram for ndn::util::NotificationSubscriber< Notification >:
+ Collaboration diagram for ndn::util::NotificationSubscriber< Notification >:

Public Member Functions

 NotificationSubscriber (Face &face, const Name &prefix, time::milliseconds interestLifetime=1_min)
 Construct a NotificationSubscriber. More...
 
time::milliseconds getInterestLifetime () const
 
bool isRunning () const
 
void start ()
 Start or resume receiving notifications. More...
 
void stop ()
 Stop receiving notifications. More...
 

Public Attributes

ndn::signal::Signal< NotificationSubscriberBase, DataonDecodeError
 Fires when a Data packet in the notification stream cannot be decoded as a Notification. More...
 
ndn::signal::Signal< NotificationSubscriberBase, lp::NackonNack
 Fires when a Nack is received. More...
 
ndn::signal::Signal< NotificationSubscriber, Notification > onNotification
 Fires when a Notification is received. More...
 
ndn::signal::Signal< NotificationSubscriberBaseonTimeout
 Fires when no Notification is received within getInterestLifetime() period. More...
 

Detailed Description

template<typename Notification>
class ndn::util::NotificationSubscriber< Notification >

Provides the subscriber side of a Notification Stream.

Template Parameters
Notificationtype of Notification item, appears in payload of Data packets.
See also
https://redmine.named-data.net/projects/nfd/wiki/Notification

Definition at line 149 of file notification-subscriber.hpp.

Constructor & Destructor Documentation

◆ NotificationSubscriber()

template<typename Notification >
ndn::util::NotificationSubscriber< Notification >::NotificationSubscriber ( Face face,
const Name prefix,
time::milliseconds  interestLifetime = 1_min 
)
inline

Construct a NotificationSubscriber.

Note
The subscriber is not started after construction. User should add one or more handlers to onNotification, and invoke .start().

Definition at line 159 of file notification-subscriber.hpp.

Member Function Documentation

◆ getInterestLifetime()

time::milliseconds ndn::util::NotificationSubscriberBase::getInterestLifetime ( ) const
inlineinherited
Returns
InterestLifetime of Interests to retrieve notifications.

This must be greater than FreshnessPeriod of Notification Data packets, to ensure correct operation of this subscriber implementation.

Definition at line 51 of file notification-subscriber.hpp.

◆ isRunning()

bool ndn::util::NotificationSubscriberBase::isRunning ( ) const
inlineinherited

Definition at line 57 of file notification-subscriber.hpp.

◆ start()

void ndn::util::NotificationSubscriberBase::start ( )
inherited

Start or resume receiving notifications.

Note
onNotification must have at least one listener, otherwise this operation has no effect.

Definition at line 47 of file notification-subscriber.cpp.

◆ stop()

void ndn::util::NotificationSubscriberBase::stop ( )
inherited

Stop receiving notifications.

Definition at line 57 of file notification-subscriber.cpp.

Member Data Documentation

◆ onDecodeError

ndn::signal::Signal<NotificationSubscriberBase, Data> ndn::util::NotificationSubscriberBase::onDecodeError
inherited

Fires when a Data packet in the notification stream cannot be decoded as a Notification.

Definition at line 128 of file notification-subscriber.hpp.

◆ onNack

ndn::signal::Signal<NotificationSubscriberBase, lp::Nack> ndn::util::NotificationSubscriberBase::onNack
inherited

Fires when a Nack is received.

Definition at line 122 of file notification-subscriber.hpp.

◆ onNotification

template<typename Notification >
ndn::signal::Signal<NotificationSubscriber, Notification> ndn::util::NotificationSubscriber< Notification >::onNotification

Fires when a Notification is received.

Note
Removing all handlers will cause the subscriber to stop.

Definition at line 170 of file notification-subscriber.hpp.

◆ onTimeout

ndn::signal::Signal<NotificationSubscriberBase> ndn::util::NotificationSubscriberBase::onTimeout
inherited

Fires when no Notification is received within getInterestLifetime() period.

Definition at line 125 of file notification-subscriber.hpp.