48 #ifndef NDN_UTIL_NOTIFICATION_SUBSCRIBER_HPP 49 #define NDN_UTIL_NOTIFICATION_SUBSCRIBER_HPP 51 #include "../face.hpp" 54 #include <boost/concept_check.hpp> 63 template<
typename Notification>
67 BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<Notification>));
75 const time::milliseconds& interestLifetime = time::milliseconds(60000))
79 , m_lastSequenceNo(
std::numeric_limits<uint64_t>::max())
81 , m_interestLifetime(interestLifetime)
97 return m_interestLifetime;
117 this->sendInitialInterest();
129 if (m_lastInterestId != 0)
131 m_lastInterestId = 0;
150 sendInitialInterest()
152 if (this->shouldStop())
155 shared_ptr<Interest> interest = make_shared<Interest>(m_prefix);
156 interest->setMustBeFresh(
true);
157 interest->setChildSelector(1);
168 if (this->shouldStop())
171 BOOST_ASSERT(m_lastSequenceNo !=
172 std::numeric_limits<uint64_t>::max());
174 Name nextName = m_prefix;
177 shared_ptr<Interest> interest = make_shared<Interest>(nextName);
193 if (onNotification.isEmpty()) {
201 afterReceiveData(
const Data& data)
203 if (this->shouldStop())
206 Notification notification;
213 this->sendInitialInterest();
219 this->sendNextInterest();
225 if (this->shouldStop())
230 this->sendInitialInterest();
237 uint64_t m_lastSequenceNo;
238 const PendingInterestId* m_lastInterestId;
239 time::milliseconds m_interestLifetime;
245 #endif // NDN_UTIL_NOTIFICATION_SUBSCRIBER_HPP Copyright (c) 2011-2015 Regents of the University of California.
NotificationSubscriber(Face &face, const Name &prefix, const time::milliseconds &interestLifetime=time::milliseconds(60000))
construct a NotificationSubscriber
time::milliseconds getInterestLifetime() const
void start()
start or resume receiving notifications
provides a lightweight signal / event system
signal::Signal< NotificationSubscriber > onTimeout
fires when no Notification is received within .getInterestLifetime period
signal::Signal< NotificationSubscriber, Notification > onNotification
fires when a Notification is received
virtual ~NotificationSubscriber()
Name & appendSequenceNumber(uint64_t seqNo)
Append sequence number using NDN naming conventions.
const Name & getName() const
Get name of the Data packet.
signal::Signal< NotificationSubscriber, Data > onDecodeError
fires when a Data packet in the Notification Stream cannot be decoded as Notification ...
Block blockFromValue() const
Abstraction to communicate with local or remote NDN forwarder.
provides a subscriber of Notification Stream
Name abstraction to represent an absolute name.
void stop()
stop receiving notifications
const PendingInterestId * expressInterest(const Interest &interest, const OnData &onData, const OnTimeout &onTimeout=OnTimeout())
Express Interest.
const Block & getContent() const
Get content Block.
uint64_t toSequenceNumber() const
Interpret as sequence number component using NDN naming conventions.
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
const Component & get(ssize_t i) const
Get the component at the given index.
void removePendingInterest(const PendingInterestId *pendingInterestId)
Cancel previously expressed Interest.
represents an error in TLV encoding or decoding