Example #1
0
std::shared_ptr<ndn::Data>
Publisher::createData(const ndn::Name& name)
{
  static ndn::KeyChain keyChain;
  static std::vector<uint8_t> content(1500, '-');

  auto data = std::make_shared<ndn::Data>();
  data->setName(name);
  data->setContent(content.data(), content.size());
  keyChain.sign(*data);
  return data;
}
Example #2
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 #3
0
	shared_ptr<Data>  createDatePacket(Interest& interest){
		Name dataName(interest.getName());
		dataName.append("-data-").appendVersion();
		std::ifstream fin;
		fin.open("/home/hult/acg.mkv");
		fin.seekg(0, fin.end);
		size_t length = fin.tellg();
		fin.seekg(0, fin.beg);
	
		uint8_t *buffer = new uint8_t[length];
		fin.read((char*)buffer, length);
		
		shared_ptr<Data> data = make_shared<Data>();
		data->setName(dataName);
		data->setFreshnessPeriod(time::seconds(10));
		data->setContent(buffer, length);
		m_keyChain.sign(*data);
		std::cout << "\n\n======================\n";
		std::cout << ">> D: " << *data << std::endl;
		std::cout << "\n\n======================\n";
		return data;
	}