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> 41 typedef std::function<void(const std::vector<MissingDataInfo>&)>
UpdateCallback;
78 Consumer(
const ndn::Name& syncPrefix,
83 double false_positive,
84 ndn::time::milliseconds helloInterestLifetime = HELLO_INTEREST_LIFETIME,
85 ndn::time::milliseconds syncInterestLifetime = SYNC_INTEREST_LIFETIME);
110 addSubscription(
const ndn::Name& prefix);
115 return m_subscriptionList;
121 return m_subscriptionList.find(prefix) != m_subscriptionList.end();
124 ndn::optional<uint64_t>
127 auto it = m_prefixes.find(prefix);
128 if (it == m_prefixes.end()) {
154 onHelloData(
const ndn::ConstBufferPtr& bufferPtr);
167 onSyncData(
const ndn::ConstBufferPtr& bufferPtr);
171 ndn::Scheduler m_scheduler;
173 ndn::Name m_syncPrefix;
174 ndn::Name m_helloInterestPrefix;
175 ndn::Name m_syncInterestPrefix;
177 ndn::Name m_helloDataName;
178 ndn::Name m_syncDataName;
179 uint32_t m_syncDataContentType;
189 ndn::time::milliseconds m_helloInterestLifetime;
190 ndn::time::milliseconds m_syncInterestLifetime;
193 std::map<ndn::Name, uint64_t> m_prefixes;
194 std::set<ndn::Name> m_subscriptionList;
196 ndn::random::RandomNumberEngine& m_rng;
197 std::uniform_int_distribution<> m_rangeUniformRandom;
198 std::shared_ptr<ndn::util::SegmentFetcher> m_helloFetcher;
199 std::shared_ptr<ndn::util::SegmentFetcher> m_syncFetcher;
204 #endif // PSYNC_CONSUMER_HPP Consumer logic to subscribe to producer's data.
std::set< ndn::Name > getSubscriptionList() const
bool isSubscribed(const ndn::Name &prefix) const
const ndn::time::milliseconds SYNC_INTEREST_LIFETIME
#define PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE
ndn::optional< uint64_t > getSeqNo(const ndn::Name &prefix) const
const ndn::time::milliseconds HELLO_INTEREST_LIFETIME
std::function< void(const std::vector< MissingDataInfo > &)> UpdateCallback
std::function< void(const std::vector< ndn::Name > &)> ReceiveHelloCallback