a client-side face for unit testing More...
#include <ndn-cxx/util/dummy-client-face.hpp>
Classes | |
class | AlreadyLinkedError |
class | Options |
options for DummyClientFace More... | |
Public Member Functions | |
DummyClientFace (const Options &options=Options()) | |
Create a dummy face with internal IO service. More... | |
DummyClientFace (KeyChain &keyChain, const Options &options=Options()) | |
Create a dummy face with internal IO service and the specified KeyChain. More... | |
DummyClientFace (boost::asio::io_service &ioService, const Options &options=Options()) | |
Create a dummy face with the provided IO service. More... | |
DummyClientFace (boost::asio::io_service &ioService, KeyChain &keyChain, const Options &options=Options()) | |
Create a dummy face with the provided IO service and the specified KeyChain. More... | |
~DummyClientFace () | |
PendingInterestHandle | expressInterest (const Interest &interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout) |
Express Interest. More... | |
boost::asio::io_service & | getIoService () |
Returns a reference to the io_service used by this face. More... | |
size_t | getNPendingInterests () const |
Get number of pending Interests. More... | |
void | linkTo (DummyClientFace &other) |
link another DummyClientFace through a broadcast media More... | |
void | processEvents (time::milliseconds timeout=time::milliseconds::zero(), bool keepThread=false) |
Process any data to receive or call timeout callbacks. More... | |
void | put (Data data) |
Publish data packet. More... | |
void | put (lp::Nack nack) |
Send a network NACK. More... | |
void | receive (const Interest &interest) |
cause the Face to receive an interest More... | |
void | receive (const Data &data) |
cause the Face to receive a data More... | |
void | receive (const lp::Nack &nack) |
cause the Face to receive a nack More... | |
RegisteredPrefixHandle | registerPrefix (const Name &prefix, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, const security::SigningInfo &signingInfo=security::SigningInfo(), uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT) |
Register prefix with the connected NDN forwarder. More... | |
void | removeAllPendingInterests () |
Cancel all previously expressed Interests. More... | |
RegisteredPrefixHandle | setInterestFilter (const InterestFilter &filter, const InterestCallback &onInterest, const RegisterPrefixFailureCallback &onFailure, const security::SigningInfo &signingInfo=security::SigningInfo(), uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT) |
Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder. More... | |
RegisteredPrefixHandle | setInterestFilter (const InterestFilter &filter, const InterestCallback &onInterest, const RegisterPrefixSuccessCallback &onSuccess, const RegisterPrefixFailureCallback &onFailure, const security::SigningInfo &signingInfo=security::SigningInfo(), uint64_t flags=nfd::ROUTE_FLAG_CHILD_INHERIT) |
Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder. More... | |
InterestFilterHandle | setInterestFilter (const InterestFilter &filter, const InterestCallback &onInterest) |
Set an InterestFilter to dispatch matching incoming Interests to onInterest callback. More... | |
void | shutdown () |
Shutdown face operations. More... | |
void | unlink () |
unlink the broadcast media if previously linked More... | |
Public Attributes | |
Signal< DummyClientFace, Data > | onSendData |
emits whenever a Data packet is sent More... | |
Signal< DummyClientFace, Interest > | onSendInterest |
emits whenever an Interest is sent More... | |
Signal< DummyClientFace, lp::Nack > | onSendNack |
emits whenever a Nack is sent More... | |
std::vector< Data > | sentData |
Data sent out of this DummyClientFace. More... | |
std::vector< Interest > | sentInterests |
Interests sent out of this DummyClientFace. More... | |
std::vector< lp::Nack > | sentNacks |
Nacks sent out of this DummyClientFace. More... | |
Protected Member Functions | |
shared_ptr< Transport > | getTransport () const |
Returns the underlying transport. More... | |
a client-side face for unit testing
Definition at line 34 of file dummy-client-face.hpp.
Create a dummy face with internal IO service.
Definition at line 98 of file dummy-client-face.cpp.
|
explicit |
Create a dummy face with internal IO service and the specified KeyChain.
Definition at line 106 of file dummy-client-face.cpp.
|
explicit |
Create a dummy face with the provided IO service.
Definition at line 113 of file dummy-client-face.cpp.
ndn::util::DummyClientFace::DummyClientFace | ( | boost::asio::io_service & | ioService, |
KeyChain & | keyChain, | ||
const Options & | options = Options() |
||
) |
Create a dummy face with the provided IO service and the specified KeyChain.
Definition at line 121 of file dummy-client-face.cpp.
ndn::util::DummyClientFace::~DummyClientFace | ( | ) |
Definition at line 128 of file dummy-client-face.cpp.
|
inherited |
Express Interest.
interest | the Interest; a copy will be made, so that the caller is not required to maintain the argument unchanged |
afterSatisfied | function to be invoked if Data is returned |
afterNacked | function to be invoked if Network NACK is returned |
afterTimeout | function to be invoked if neither Data nor Network NACK is returned within InterestLifetime |
OversizedPacketError | encoded Interest size exceeds MAX_NDN_PACKET_SIZE |
|
inlineinherited |
|
inherited |
|
inlineprotectedinherited |
void ndn::util::DummyClientFace::linkTo | ( | DummyClientFace & | other | ) |
link another DummyClientFace through a broadcast media
Definition at line 290 of file dummy-client-face.cpp.
|
inlineinherited |
Process any data to receive or call timeout callbacks.
This call will block forever (with the default timeout of 0) to process I/O on the face. To exit cleanly on a producer, clear any Interest filters and wait for processEvents() to return. To exit after an error, one can call shutdown(). In consumer applications, processEvents() will return when all expressed Interests have been satisfied, Nacked, or timed out. To terminate earlier, a consumer application should cancel all previously expressed and still-pending Interests.
If a positive timeout is specified, then processEvents() will exit after this timeout, provided it is not stopped earlier with shutdown() or when all active events finish. processEvents() can be called repeatedly, if desired.
If a negative timeout is specified, then processEvents will not block and will process only pending events.
timeout | maximum time to block the thread |
keepThread | Keep thread in a blocked state (in event processing), even when there are no outstanding events (e.g., no Interest/Data is expected). If timeout is zero and this parameter is true, the only way to stop processEvents() is to call shutdown(). |
OversizedPacketError | encoded packet size exceeds MAX_NDN_PACKET_SIZE |
|
inherited |
Publish data packet.
data | the Data; a copy will be made, so that the caller is not required to maintain the argument unchanged |
This method can be called to satisfy incoming Interests, or to add Data packet into the cache of the local NDN forwarder if forwarder is configured to accept unsolicited Data.
OversizedPacketError | encoded Data size exceeds MAX_NDN_PACKET_SIZE |
|
inherited |
void ndn::util::DummyClientFace::receive | ( | const Interest & | interest | ) |
cause the Face to receive an interest
Definition at line 253 of file dummy-client-face.cpp.
void ndn::util::DummyClientFace::receive | ( | const Data & | data | ) |
cause the Face to receive a data
Definition at line 265 of file dummy-client-face.cpp.
void ndn::util::DummyClientFace::receive | ( | const lp::Nack & | nack | ) |
cause the Face to receive a nack
Definition at line 276 of file dummy-client-face.cpp.
|
inherited |
Register prefix with the connected NDN forwarder.
This method only modifies forwarder's RIB and does not associate any onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to the right callbacks.
prefix | A prefix to register with the connected NDN forwarder |
onSuccess | A callback to be called when prefixRegister command succeeds |
onFailure | A callback to be called when prefixRegister command fails |
signingInfo | Signing parameters. When omitted, a default parameters used in the signature will be used. |
flags | Prefix registration flags |
|
inherited |
|
inherited |
Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder.
This version of setInterestFilter combines setInterestFilter and registerPrefix operations and is intended to be used when only one filter for the same prefix needed to be set. When multiple names sharing the same prefix should be dispatched to different callbacks, use one registerPrefix call, followed (in onSuccess callback) by a series of setInterestFilter calls.
filter | Interest filter (prefix part will be registered with the forwarder) |
onInterest | A callback to be called when a matching interest is received |
onFailure | A callback to be called when prefixRegister command fails |
signingInfo | Signing parameters. When omitted, a default parameters used in the signature will be used. |
flags | Prefix registration flags |
|
inherited |
Set InterestFilter to dispatch incoming matching interest to onInterest callback and register the filtered prefix with the connected NDN forwarder.
This version of setInterestFilter combines setInterestFilter and registerPrefix operations and is intended to be used when only one filter for the same prefix needed to be set. When multiple names sharing the same prefix should be dispatched to different callbacks, use one registerPrefix call, followed (in onSuccess callback) by a series of setInterestFilter calls.
filter | Interest filter (prefix part will be registered with the forwarder) |
onInterest | A callback to be called when a matching interest is received |
onSuccess | A callback to be called when prefixRegister command succeeds |
onFailure | A callback to be called when prefixRegister command fails |
signingInfo | Signing parameters. When omitted, a default parameters used in the signature will be used. |
flags | Prefix registration flags |
|
inherited |
Set an InterestFilter to dispatch matching incoming Interests to onInterest
callback.
filter | Interest filter |
onInterest | A callback to be called when a matching interest is received |
This method modifies library's FIB only, and does not register the prefix with the forwarder. It will always succeed. To register a prefix with the forwarder, use registerPrefix() or one of the other two setInterestFilter() overloads.
|
inherited |
Shutdown face operations.
This method cancels all pending operations and closes the connection to the NDN forwarder.
Note that this method does not stop the io_service if it is shared between multiple Faces or with other IO objects (e.g., Scheduler).
void ndn::util::DummyClientFace::unlink | ( | ) |
unlink the broadcast media if previously linked
Definition at line 314 of file dummy-client-face.cpp.
Signal<DummyClientFace, Data> ndn::util::DummyClientFace::onSendData |
emits whenever a Data packet is sent
After .put, .processEvents must be called before this signal would be emitted.
Definition at line 181 of file dummy-client-face.hpp.
Signal<DummyClientFace, Interest> ndn::util::DummyClientFace::onSendInterest |
emits whenever an Interest is sent
After .expressInterest, .processEvents must be called before this signal would be emitted.
Definition at line 175 of file dummy-client-face.hpp.
Signal<DummyClientFace, lp::Nack> ndn::util::DummyClientFace::onSendNack |
emits whenever a Nack is sent
After .put, .processEvents must be called before this signal would be emitted.
Definition at line 187 of file dummy-client-face.hpp.
std::vector<Data> ndn::util::DummyClientFace::sentData |
Data sent out of this DummyClientFace.
Sent Data are appended to this container if options.enablePacketLogger is true. User of this class is responsible for cleaning up the container, if necessary. After .put, .processEvents must be called before the Data would show up here.
Definition at line 161 of file dummy-client-face.hpp.
std::vector<Interest> ndn::util::DummyClientFace::sentInterests |
Interests sent out of this DummyClientFace.
Sent Interests are appended to this container if options.enablePacketLogger is true. User of this class is responsible for cleaning up the container, if necessary. After .expressInterest, .processEvents must be called before the Interest would show up here.
Definition at line 153 of file dummy-client-face.hpp.
std::vector<lp::Nack> ndn::util::DummyClientFace::sentNacks |
Nacks sent out of this DummyClientFace.
Sent Nacks are appended to this container if options.enablePacketLogger is true. User of this class is responsible for cleaning up the container, if necessary. After .put, .processEvents must be called before the NACK would show up here.
Definition at line 169 of file dummy-client-face.hpp.