Example #1
0
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(); });
}
Example #2
0
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);
      });
    }
  });
}
Example #3
0
	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);
		
	}
Example #4
0
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(); });
}