⚲
Project
General
Profile
Sign in
Register
Home
Projects
Search
:
NFD
All Projects
NFD
Overview
Activity
Roadmap
Issues
Wiki
Download (1.17 KB)
Bug #3608
» consumer.cpp
The consumer -
Michael Sweatt, 04/25/2016 02:59 PM
#include
<ndn-cxx/face.hpp>
#include
<ndn-cxx/security/key-chain.hpp>
namespace
ndn
{
class
Consumer
:
noncopyable
{
public:
void
run
()
{
Interest
interest
(
Name
(
"/NTORRENT/foo/bar.txt/%FE%00/%FE%00/sha256digest=f4446686f2c9fd94d0d24b26eae465600547c1b37afdfca6abf026849dad0cda"
));
interest
.
setInterestLifetime
(
time
::
milliseconds
(
1000
));
interest
.
setMustBeFresh
(
true
);
m_face
.
expressInterest
(
interest
,
bind
(
&
Consumer
::
onData
,
this
,
_1
,
_2
),
bind
(
&
Consumer
::
onTimeout
,
this
,
_1
));
std
::
cout
<<
"Sending "
<<
interest
<<
std
::
endl
;
// processEvents will block until the requested data received or timeout occurs
m_face
.
processEvents
();
}
private:
void
onData
(
const
Interest
&
interest
,
const
Data
&
data
)
{
std
::
cout
<<
data
<<
std
::
endl
;
}
void
onTimeout
(
const
Interest
&
interest
)
{
std
::
cout
<<
"Timeout "
<<
interest
<<
std
::
endl
;
}
private:
Face
m_face
;
};
}
// namespace ndn
int
main
(
int
argc
,
char
**
argv
)
{
ndn
::
Consumer
consumer
;
try
{
consumer
.
run
();
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cerr
<<
"ERROR: "
<<
e
.
what
()
<<
std
::
endl
;
}
return
0
;
}
« Previous
1
2
3
Next »
(1-1/3)
Loading...