20 #ifndef PSYNC_CONSUMER_HPP 21 #define PSYNC_CONSUMER_HPP 27 #include <ndn-cxx/face.hpp> 28 #include <ndn-cxx/util/random.hpp> 29 #include <ndn-cxx/util/scheduler.hpp> 30 #include <ndn-cxx/util/segment-fetcher.hpp> 31 #include <ndn-cxx/util/time.hpp> 76 Consumer(
const ndn::Name& syncPrefix,
81 double false_positive,
82 ndn::time::milliseconds helloInterestLifetime = HELLO_INTEREST_LIFETIME,
83 ndn::time::milliseconds syncInterestLifetime = SYNC_INTEREST_LIFETIME);
114 addSubscription(
const ndn::Name& prefix, uint64_t seqNo,
bool callSyncDataCb =
true);
119 return m_subscriptionList;
125 return m_subscriptionList.find(prefix) != m_subscriptionList.end();
128 ndn::optional<uint64_t>
131 auto it = m_prefixes.find(prefix);
132 if (it == m_prefixes.end()) {
158 onHelloData(
const ndn::ConstBufferPtr& bufferPtr);
171 onSyncData(
const ndn::ConstBufferPtr& bufferPtr);
175 ndn::Scheduler m_scheduler;
177 ndn::Name m_syncPrefix;
178 ndn::Name m_helloInterestPrefix;
179 ndn::Name m_syncInterestPrefix;
181 ndn::Name m_helloDataName;
182 ndn::Name m_syncDataName;
183 uint32_t m_syncDataContentType;
193 ndn::time::milliseconds m_helloInterestLifetime;
194 ndn::time::milliseconds m_syncInterestLifetime;
197 std::map<ndn::Name, uint64_t> m_prefixes;
198 std::set<ndn::Name> m_subscriptionList;
200 ndn::random::RandomNumberEngine& m_rng;
201 std::uniform_int_distribution<> m_rangeUniformRandom;
202 std::shared_ptr<ndn::util::SegmentFetcher> m_helloFetcher;
203 std::shared_ptr<ndn::util::SegmentFetcher> m_syncFetcher;
208 #endif // PSYNC_CONSUMER_HPP Consumer logic to subscribe to producer's data.
std::function< void(const std::map< ndn::Name, uint64_t > &)> ReceiveHelloCallback
std::set< ndn::Name > getSubscriptionList() const
bool isSubscribed(const ndn::Name &prefix) const
const ndn::time::milliseconds SYNC_INTEREST_LIFETIME
std::function< void(const std::vector< MissingDataInfo > &)> UpdateCallback
#define PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE
ndn::optional< uint64_t > getSeqNo(const ndn::Name &prefix) const
const ndn::time::milliseconds HELLO_INTEREST_LIFETIME