#include <Client.h>
Inherits dtn::streams::StreamConnection, and dtn::streams::StreamConnection::Callback.
Inherited by CAPIGateway, EchoClient, Tracer, and TUN2BundleGateway.

Classes | |
| class | AsyncReceiver |
Public Types | |
| enum | COMMUNICATION_MODE { MODE_BIDIRECTIONAL = 0, MODE_SENDONLY = 1 } |
Public Member Functions | |
| Client (COMMUNICATION_MODE mode, string app, ibrcommon::tcpstream &stream) | |
| Client (string app, ibrcommon::tcpstream &stream) | |
| virtual | ~Client () |
| void | connect () |
| bool | isConnected () |
| void | close () |
| virtual void | eventShutdown (StreamConnection::ConnectionShutdownCases csc) |
| virtual void | eventTimeout () |
| virtual void | eventError () |
| virtual void | eventConnectionUp (const StreamContactHeader &header) |
| virtual void | eventConnectionDown () |
| virtual void | eventBundleRefused () |
| virtual void | eventBundleForwarded () |
| virtual void | eventBundleAck (size_t ack) |
| dtn::api::Bundle | getBundle (size_t timeout=0) |
Public Attributes | |
| size_t | lastack |
Protected Member Functions | |
| virtual void | received (const dtn::streams::StreamContactHeader &h) |
| virtual void | received (const dtn::api::Bundle &b) |
This is an abstract class is the base for any API connection to a IBR-DTN daemon. It uses a existing stream to communicate bidirectional with the daemon.
For asynchronous reception of bundle this class implements a thread.
Definition at line 59 of file Client.h.
| dtn::api::Client::Client | ( | COMMUNICATION_MODE | mode, | |
| string | app, | |||
| ibrcommon::tcpstream & | stream | |||
| ) |
Constructor for the API Connection. At least a application suffix and a existing stream are required. The suffix is appended to the node id of the daemon. E.g. dtn://node1/example (in this case is "example" the application id. The stream connects the daemon and this application together and will be used with the bundle protocol for TCP (draft-irtf-dtnrg-tcp-clayer-02) provided by the StreamConnection class.
Definition at line 73 of file Client.cpp.
| dtn::api::Client::Client | ( | string | app, | |
| ibrcommon::tcpstream & | stream | |||
| ) |
Definition at line 78 of file Client.cpp.
| dtn::api::Client::~Client | ( | ) | [virtual] |
Virtual destructor for this class.
Definition at line 83 of file Client.cpp.
References IBRCOMMON_LOGGER_DEBUG, and ibrcommon::Exception::what().

| void dtn::api::Client::close | ( | ) |
Definition at line 124 of file Client.cpp.
References dtn::streams::StreamConnection::shutdown().
Referenced by main(), and term().

| void dtn::api::Client::connect | ( | ) |
This method starts the thread and execute the handshake with the server.
Definition at line 94 of file Client.cpp.
References dtn::streams::StreamConnection::handshake(), IBRCOMMON_LOGGER, MODE_SENDONLY, and ibrcommon::Exception::what().
Referenced by main().

| void dtn::api::Client::eventBundleAck | ( | size_t | ack | ) | [virtual] |
This method is called if a ACK is received.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 172 of file Client.cpp.
References lastack.
| void dtn::api::Client::eventBundleForwarded | ( | ) | [virtual] |
This method is called if a bundle is refused by the peer.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 167 of file Client.cpp.
| void dtn::api::Client::eventBundleRefused | ( | ) | [virtual] |
This method is called if a bundle is refused by the peer.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 162 of file Client.cpp.
| void dtn::api::Client::eventConnectionDown | ( | ) | [virtual] |
This method is called if a connection went down.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 150 of file Client.cpp.
References ibrcommon::Queue< T >::abort(), IBRCOMMON_LOGGER_DEBUG, and ibrcommon::Exception::what().

| void dtn::api::Client::eventConnectionUp | ( | const StreamContactHeader & | header | ) | [virtual] |
This method is called if a handshake was successful.
| header |
Implements dtn::streams::StreamConnection::Callback.
Definition at line 142 of file Client.cpp.
| void dtn::api::Client::eventError | ( | ) | [virtual] |
This method is called if a error occured in the stream.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 146 of file Client.cpp.
| void dtn::api::Client::eventShutdown | ( | StreamConnection::ConnectionShutdownCases | csc | ) | [virtual] |
this method gets called if the connection goes down
Implements dtn::streams::StreamConnection::Callback.
Definition at line 138 of file Client.cpp.
| void dtn::api::Client::eventTimeout | ( | ) | [virtual] |
This method is called if the stream is closed by a TIMEOUT.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 134 of file Client.cpp.
| dtn::api::Bundle dtn::api::Client::getBundle | ( | size_t | timeout = 0 |
) |
Definition at line 185 of file Client.cpp.
References ibrcommon::Queue< T >::getnpop(), ibrcommon::QueueUnblockedException::QUEUE_ABORT, ibrcommon::QueueUnblockedException::QUEUE_TIMEOUT, ibrcommon::QueueUnblockedException::reason, and ibrcommon::Exception::what().
Referenced by main().

| bool dtn::api::Client::isConnected | ( | ) |
Definition at line 119 of file Client.cpp.
| void dtn::api::Client::received | ( | const dtn::streams::StreamContactHeader & | h | ) | [protected, virtual] |
This method is called on the receipt of the handshake of the daemon. If you like to validate your connection you could overload this method, but must call the super method.
Definition at line 129 of file Client.cpp.
| void dtn::api::Client::received | ( | const dtn::api::Bundle & | b | ) | [protected, virtual] |
Definition at line 177 of file Client.cpp.
References MODE_SENDONLY, and ibrcommon::Queue< T >::push().

| size_t dtn::api::Client::lastack |
Definition at line 131 of file Client.h.
Referenced by eventBundleAck(), and main().
1.7.1