22 #ifndef NDN_CHANNEL_DISCOVERY_HPP
23 #define NDN_CHANNEL_DISCOVERY_HPP
26 #include <ndn-cpp/sync/chrono-sync2013.hpp>
44 typedef ndn::func_lib::function<void
46 const ndn::ptr_lib::shared_ptr<ndn::Name>& userPrefix)> OnReceivedChannelList;
48 typedef ndn::func_lib::function<void
49 (ErrorCode errorCode,
const std::string& message)> OnError;
87 const std::string& channelListFilePath,
91 const OnReceivedChannelList& onReceivedChannelList,
const OnError& onError)
93 (*
this, applicationDataPrefix, channelListFilePath, face, keyChain,
94 certificateName, syncLifetime, onReceivedChannelList, onError))
96 impl_->initialize(applicationBroadcastPrefix);
107 impl_->addChannel(channel);
119 impl_->removeChannel(channel);
135 ndn::ptr_lib::shared_ptr<std::vector<ndn::Name>>
138 return impl_->getOtherUserPrefixes();
148 ndn::ptr_lib::shared_ptr<std::vector<std::string>>
151 return impl_->getChannelList(userPrefix);
162 class Impl :
public ndn::ptr_lib::enable_shared_from_this<Impl> {
171 const std::string& channelListFilePath,
ndn::Face& face,
174 const OnReceivedChannelList& onReceivedChannelList,
const OnError& onError);
183 initialize(
const ndn::Name& applicationBroadcastPrefix);
194 ndn::ptr_lib::shared_ptr<std::vector<ndn::Name>>
197 ndn::ptr_lib::shared_ptr<std::vector<std::string>>
209 onRegisterApplicationPrefixSuccess
210 (
const ndn::ptr_lib::shared_ptr<const ndn::Name>& prefix,
211 uint64_t registeredPrefixId,
const ndn::Name& applicationBroadcastPrefix,
212 int previousSequenceNumber);
225 (
const std::vector<ndn::ChronoSync2013::SyncState>& syncStates,
233 (
const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest,
234 const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
239 onApplicationInterest
240 (
const ndn::ptr_lib::shared_ptr<const ndn::Name>& prefix,
241 const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest,
242 ndn::Face& face, uint64_t interestFilterId,
243 const ndn::ptr_lib::shared_ptr<const ndn::InterestFilter>& filter);
251 onRegisterFailed(
const ndn::ptr_lib::shared_ptr<const ndn::Name>& prefix);
259 onTimeout(
const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest);
267 publishChannelListData();
276 ndn::ptr_lib::shared_ptr<ndn::Data>
277 makeChannelListData(
int sequenceNo);
288 (
const ndn::Blob& blob, std::vector<std::string>& channelList);
296 readBase64Blob(
const std::string& filePath);
304 writeBase64Blob(
const ndn::Blob& blob,
const std::string& filePath);
310 std::string channelListFilePath_;
315 OnReceivedChannelList onReceivedChannelList_;
317 ndn::ptr_lib::shared_ptr<ndn::ChronoSync2013> sync_;
318 std::vector<std::string> myChannelList_;
320 std::map<std::string, std::vector<std::string>> otherUserChannelList_;
321 ndn::ptr_lib::shared_ptr<ndn::Data> channelListData_;
327 ndn::ptr_lib::shared_ptr<Impl> impl_;
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:114
The Face class provides the main methods for NDN communication.
Definition: face.hpp:86
KeyChain is the main class of the security library.
Definition: key-chain.hpp:53
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
Definition: blob.hpp:42