Jeff Thompson | fa30664 | 2013-06-17 15:06:57 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013, Regents of the University of California |
| 4 | * Alexander Afanasyev |
| 5 | * |
| 6 | * BSD license, See the LICENSE file for more information |
| 7 | * |
| 8 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 9 | */ |
| 10 | |
| 11 | #include <ndn.cxx.h> |
| 12 | #include <iostream> |
| 13 | |
| 14 | using namespace std; |
| 15 | |
| 16 | ndn::Name InterestBaseName; |
| 17 | |
| 18 | // create a global handler |
| 19 | ndn::Wrapper handler; |
| 20 | |
| 21 | void OnInterest (ndn::InterestPtr interest) |
| 22 | { |
| 23 | cerr << interest->getName () << endl; |
| 24 | |
| 25 | static int COUNTER = 0; |
| 26 | |
| 27 | ostringstream os; |
| 28 | os << "C++ LINE #" << (COUNTER++) << endl; |
| 29 | |
| 30 | handler.publishData (interest->getName (), os.str (), 5); |
| 31 | } |
| 32 | |
| 33 | int |
| 34 | main (int argc, char **argv) |
| 35 | { |
| 36 | InterestBaseName = ndn::Name ("ccnx:/my-local-prefix/simple-fetch/file"); |
| 37 | |
| 38 | handler.setInterestFilter (InterestBaseName, OnInterest); |
| 39 | |
| 40 | while (true) |
| 41 | { |
| 42 | sleep (1); |
| 43 | } |
| 44 | return 0; |
| 45 | } |