void Publisher::generateFromFile() { if (insertStream.eof()) { m_face.getIoService().stop(); return; } std::string name; getline(insertStream, name); auto data = createData(ndn::Name(name)); m_face.put(*data); m_scheduler.schedule(timeInterval, [this] { generateFromFile(); }); }
void Publisher::autoGenerate() { ndn::Name name = dataPrefix; name.appendNumber(m_randomDist(ndn::random::getRandomNumberEngine())); auto data = createData(name); m_face.put(*data); m_scheduler.schedule(timeInterval, [this] { autoGenerate(); }); }
Nfdc::Nfdc(ndn::Face& face) : m_flags(ROUTE_FLAG_CHILD_INHERIT) , m_cost(DEFAULT_COST) , m_origin(ROUTE_ORIGIN_STATIC) , m_expires(DEFAULT_EXPIRATION_PERIOD) , m_face(face) , m_controller(face, m_keyChain) , m_ioService(face.getIoService()) { }
void TopologyTester::addEchoProducer(ndn::Face& face, const Name& prefix, time::nanoseconds replyDelay) { BOOST_ASSERT(replyDelay >= 0_ns); face.setInterestFilter(prefix, [=, &face] (const auto&, const auto& interest) { auto data = makeData(interest.getName()); if (replyDelay == 0_ns) { // reply immediately face.put(*data); } else { // delay the reply getScheduler().schedule(replyDelay, [&face, data = std::move(data)] { face.put(*data); }); } }); }
void Publisher::run() { if (mode == AUTO) { m_scheduler.schedule(timeInterval, [this] { autoGenerate(); }); } else { m_scheduler.schedule(timeInterval, [this] { generateFromFile(); }); } m_face.processEvents(duration); }
Fib(ndn::Face& face, ndn::Scheduler& scheduler, AdjacencyList& adjacencyList, ConfParameter& conf, ndn::KeyChain& keyChain) : m_scheduler(scheduler) , m_table() , m_refreshTime(0) , m_controller(face, keyChain) , m_faceController(face.getIoService(), m_controller) , m_faceMap() , m_adjacencyList(adjacencyList) , m_confParameter(conf) { }
void onInterest(const InterestFilter& filter, const Interest& interest){ std::cout << "<< I: " << interest << std::endl; Name dataName(interest.getName()); dataName.append("-data-").appendVersion(); static const std::string content = "this is the first data package i generated! "; shared_ptr<Data> data = make_shared<Data>(); data->setName(dataName); data->setFreshnessPeriod(time::seconds(10)); data->setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.size()); m_keyChain.sign(*data); std::cout << ">> D: " << *data << std::endl; m_face.put(*data); }
void TopologyTester::addIntervalConsumer(ndn::Face& face, const Name& prefix, time::nanoseconds interval, size_t n, int seq) { Name name(prefix); if (seq >= 0) { name.appendSequenceNumber(seq); ++seq; } else { name.appendTimestamp(); } auto interest = makeInterest(name); face.expressInterest(*interest, nullptr, nullptr, nullptr); if (n > 1) { getScheduler().schedule(interval, [=, &face] { addIntervalConsumer(face, prefix, interval, n - 1, seq); }); } }