A client-side face for unit testing. More...
#include <ndn-cxx/util/dummy-client-face.hpp>
Classes | |
class | AlreadyLinkedError |
Public Types | |
using | Options = DummyClientFaceOptions |
Public Member Functions | |
DummyClientFace (boost::asio::io_context &ioCtx, const Options &options={}) | |
Create a dummy face with the provided I/O context. More... | |
DummyClientFace (boost::asio::io_context &ioCtx, KeyChain &keyChain, const Options &options={}) | |
Create a dummy face with the specified I/O context and KeyChain. More... | |
DummyClientFace (const Options &options={}) | |
Create a dummy face with an internal I/O context. More... | |
DummyClientFace (KeyChain &keyChain, const Options &options={}) | |
Create a dummy face with an internal I/O context and the specified KeyChain. More... | |
~DummyClientFace () override | |
PendingInterestHandle | expressInterest (const Interest &interest, const DataCallback &afterSatisfied, const NackCallback &afterNacked, const TimeoutCallback &afterTimeout) |
Express an Interest. More... | |
boost::asio::io_context & | getIoContext () const noexcept |
Returns a reference to the io_context used by this face. More... | |
boost::asio::io_context & | getIoService () const noexcept |
size_t | getNPendingInterests () const |
Get number of pending Interests. More... | |
void | linkTo (DummyClientFace &other) |
Link another DummyClientFace through a broadcast medium. More... | |
void | processEvents (time::milliseconds timeout=0_ms, bool keepRunning=false) |
Run the event loop to process any pending work and execute completion handlers. More... | |
void | put (const Data &data) |
Publish a Data packet. More... | |
void | put (const lp::Nack &nack) |
Send a Network Nack. More... | |
void | receive (const Data &data) |
Cause the face to receive a Data packet. More... | |
void | receive (const Interest &interest) |
Cause the face to receive an Interest packet. More... | |
void | receive (const lp::Nack &nack) |
Cause the face to receive a Nack packet. 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... | |
InterestFilterHandle | setInterestFilter (const InterestFilter &filter, const InterestCallback &onInterest) |
Set an InterestFilter to dispatch matching incoming Interests to onInterest callback. 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... | |
void | shutdown () |
Shutdown face operations. More... | |
void | unlink () |
Unlink the broadcast medium if previously linked. More... | |
Public Attributes | |
signal::Signal< DummyClientFace, Data > | onSendData |
Emitted whenever a Data packet is sent. More... | |
signal::Signal< DummyClientFace, Interest > | onSendInterest |
Emitted whenever an Interest is sent. More... | |
signal::Signal< DummyClientFace, lp::Nack > | onSendNack |
Emitted 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 | |
Transport & | getTransport () const |
Returns the underlying transport. More... | |
A client-side face for unit testing.
Definition at line 62 of file dummy-client-face.hpp.
Definition at line 71 of file dummy-client-face.hpp.
|
explicit |
Create a dummy face with an internal I/O context.
Definition at line 87 of file dummy-client-face.cpp.
|
explicit |
Create a dummy face with an internal I/O context and the specified KeyChain.
Definition at line 95 of file dummy-client-face.cpp.
|
explicit |
Create a dummy face with the provided I/O context.
Definition at line 102 of file dummy-client-face.cpp.
ndn::DummyClientFace::DummyClientFace | ( | boost::asio::io_context & | ioCtx, |
KeyChain & | keyChain, | ||
const Options & | options = {} |
||
) |
Create a dummy face with the specified I/O context and KeyChain.
Definition at line 110 of file dummy-client-face.cpp.
|
override |
Definition at line 117 of file dummy-client-face.cpp.
|
inherited |
Express an 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. |
|
inlinenoexceptinherited |
|
inlinenoexceptinherited |
|
inherited |
|
inlineprotectedinherited |
void ndn::DummyClientFace::linkTo | ( | DummyClientFace & | other | ) |
Link another DummyClientFace through a broadcast medium.
Definition at line 280 of file dummy-client-face.cpp.
|
inlineinherited |
Run the event loop to process any pending work and execute completion handlers.
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 timeout
is a positive value, then processEvents() will return after the specified duration has elapsed, unless the event loop is stopped earlier with shutdown() or runs out of work to do.
If a negative timeout
is specified, then processEvents() will not block and will process only handlers that are ready to run.
processEvents() can be called repeatedly, if desired.
timeout | Maximum amount of time to block the event loop (see above). |
keepRunning | Keep thread in a blocked state (in event processing), even when there are no outstanding events (e.g., no Interest/Data is expected). Ignored if timeout is negative. If timeout is 0 and keepRunning is true, the only way to stop processEvents() is to call shutdown(). |
OversizedPacketError | Encoded packet size exceeds MAX_NDN_PACKET_SIZE. |
|
inherited |
Publish a Data packet.
data | The Data packet; 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 |
Send a Network Nack.
nack | The Nack packet; a copy will be made, so that the caller is not required to maintain the argument unchanged. |
OversizedPacketError | Encoded Nack size exceeds MAX_NDN_PACKET_SIZE. |
void ndn::DummyClientFace::receive | ( | const Data & | data | ) |
Cause the face to receive a Data packet.
Definition at line 255 of file dummy-client-face.cpp.
void ndn::DummyClientFace::receive | ( | const Interest & | interest | ) |
Cause the face to receive an Interest packet.
Definition at line 243 of file dummy-client-face.cpp.
void ndn::DummyClientFace::receive | ( | const lp::Nack & | nack | ) |
Cause the face to receive a Nack packet.
Definition at line 266 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 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 |
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 |
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_context if it is shared between multiple Faces or with other I/O objects (e.g., Scheduler).
void ndn::DummyClientFace::unlink | ( | ) |
Unlink the broadcast medium if previously linked.
Definition at line 304 of file dummy-client-face.cpp.
signal::Signal<DummyClientFace, Data> ndn::DummyClientFace::onSendData |
Emitted whenever a Data packet is sent.
Definition at line 185 of file dummy-client-face.hpp.
signal::Signal<DummyClientFace, Interest> ndn::DummyClientFace::onSendInterest |
Emitted whenever an Interest is sent.
Definition at line 179 of file dummy-client-face.hpp.
signal::Signal<DummyClientFace, lp::Nack> ndn::DummyClientFace::onSendNack |
Emitted whenever a Nack is sent.
Definition at line 191 of file dummy-client-face.hpp.
std::vector<Data> ndn::DummyClientFace::sentData |
Data sent out of this DummyClientFace.
Sent Data are appended to this container if Options::enablePacketLogging is true. The user of this class is responsible for cleaning up the container, if necessary.
Definition at line 163 of file dummy-client-face.hpp.
std::vector<Interest> ndn::DummyClientFace::sentInterests |
Interests sent out of this DummyClientFace.
Sent Interests are appended to this container if Options::enablePacketLogging is true. The user of this class is responsible for cleaning up the container, if necessary.
Definition at line 153 of file dummy-client-face.hpp.
std::vector<lp::Nack> ndn::DummyClientFace::sentNacks |
Nacks sent out of this DummyClientFace.
Sent Nacks are appended to this container if Options::enablePacketLogging is true. The user of this class is responsible for cleaning up the container, if necessary.
Definition at line 173 of file dummy-client-face.hpp.