#include <Client.h>

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 () |
| 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) |
Protected Member Functions | |
| virtual void | received (const dtn::streams::StreamContactHeader &h) |
| virtual void | received (const dtn::api::Bundle &b) |
Classes | |
| class | AsyncReceiver |
For asynchronous reception of bundle this class implements a thread.
Definition at line 43 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 65 of file Client.cpp.
| dtn::api::Client::Client | ( | string | app, | |
| ibrcommon::tcpstream & | stream | |||
| ) |
Definition at line 70 of file Client.cpp.
| dtn::api::Client::~Client | ( | ) | [virtual] |
| void dtn::api::Client::connect | ( | ) |
This method starts the thread and execute the handshake with the server.
Definition at line 80 of file Client.cpp.
References dtn::streams::StreamConnection::handshake(), MODE_SENDONLY, and dtn::streams::StreamContactHeader::REQUEST_ACKNOWLEDGMENTS.
Referenced by main().
| bool dtn::api::Client::isConnected | ( | ) |
Reimplemented from dtn::streams::StreamConnection.
Definition at line 101 of file Client.cpp.
Referenced by main().
| void dtn::api::Client::close | ( | ) |
Close this stream connection
Reimplemented from dtn::streams::StreamConnection.
Definition at line 106 of file Client.cpp.
References ibrcommon::Conditional::signal(), and dtn::streams::StreamConnection::wait().
| void dtn::api::Client::eventShutdown | ( | ) | [virtual] |
this method gets called if the connection goes down
Implements dtn::streams::StreamConnection::Callback.
Definition at line 131 of file Client.cpp.
References ibrcommon::tcpstream::close(), ibrcommon::tcpstream::done(), and ibrcommon::Conditional::signal().
| 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 122 of file Client.cpp.
References ibrcommon::tcpstream::close(), ibrcommon::tcpstream::done(), and ibrcommon::Conditional::signal().
| 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 152 of file Client.cpp.
References ibrcommon::tcpstream::close(), and ibrcommon::Conditional::signal().
| 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 140 of file Client.cpp.
References received(), and ibrcommon::Conditional::signal().
| void dtn::api::Client::eventConnectionDown | ( | ) | [virtual] |
This method is called if a connection went down.
Implements dtn::streams::StreamConnection::Callback.
Definition at line 160 of file Client.cpp.
References ibrcommon::Conditional::signal().
| 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 168 of file Client.cpp.
| 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 173 of file Client.cpp.
| 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 178 of file Client.cpp.
| dtn::api::Bundle dtn::api::Client::getBundle | ( | size_t | timeout = 0 |
) |
Definition at line 190 of file Client.cpp.
References ibrcommon::ThreadSafeQueue< T >::blockingpop().
Referenced by main().
| 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 117 of file Client.cpp.
Referenced by eventConnectionUp().
| void dtn::api::Client::received | ( | const dtn::api::Bundle & | b | ) | [protected, virtual] |
Definition at line 182 of file Client.cpp.
References MODE_SENDONLY, and ibrcommon::ThreadSafeQueue< T >::push().
1.5.6