28 #include <ibrcommon/net/socketstream.h>
29 #include <ibrcommon/Logger.h>
38 Client::AsyncReceiver::AsyncReceiver(
Client &client)
43 Client::AsyncReceiver::~AsyncReceiver()
47 void Client::AsyncReceiver::__cancellation()
throw ()
52 void Client::AsyncReceiver::run()
throw ()
68 IBRCOMMON_LOGGER_TAG(
"Client::AsyncReceiver", error) <<
"ConnectionException: " << ex.what() << IBRCOMMON_LOGGER_ENDL;
71 IBRCOMMON_LOGGER_TAG(
"Client::AsyncReceiver", error) <<
"StreamErrorException: " << ex.what() << IBRCOMMON_LOGGER_ENDL;
73 }
catch (
const ibrcommon::IOException &ex) {
74 IBRCOMMON_LOGGER_TAG(
"Client::AsyncReceiver", error) <<
"IOException: " << ex.what() << IBRCOMMON_LOGGER_ENDL;
78 IBRCOMMON_LOGGER_TAG(
"Client::AsyncReceiver", error) <<
"InvalidDataException: " << ex.what() << IBRCOMMON_LOGGER_ENDL;
81 }
catch (
const std::exception &ex) {
82 IBRCOMMON_LOGGER_TAG(
"Client::AsyncReceiver", error) << ex.what() << IBRCOMMON_LOGGER_ENDL;
88 : StreamConnection(*this, stream), lastack(0), _stream(stream), _mode(mode), _app(app), _group(group), _receiver(*this)
93 : StreamConnection(*this, stream), lastack(0), _stream(stream), _mode(mode), _app(app), _group(), _receiver(*this)
102 }
catch (
const ibrcommon::ThreadException &ex) {
103 IBRCOMMON_LOGGER_DEBUG_TAG(
"Client", 20) <<
"ThreadException in Client destructor: " << ex.what() << IBRCOMMON_LOGGER_ENDL;
117 if (_app.length() > 0) localeid =
EID(
"api:" + _app);
130 std::getline(_stream, buffer);
136 _stream <<
"registration add " << _group.
getString() << std::endl;
139 std::getline(_stream, buffer);
143 _stream <<
"protocol tcpcl" << std::endl;
151 }
catch (
const ibrcommon::ThreadException &ex) {
152 IBRCOMMON_LOGGER_TAG(
"Client", error) <<
"failed to start Client::Receiver\n" << ex.what() << IBRCOMMON_LOGGER_ENDL;
159 shutdown(StreamConnection::CONNECTION_SHUTDOWN_SIMPLE_SHUTDOWN);
167 shutdown(StreamConnection::CONNECTION_SHUTDOWN_ERROR);
176 }
catch (
const ibrcommon::ThreadException &ex) {
177 IBRCOMMON_LOGGER_TAG(
"Client", error) << ex.what() << IBRCOMMON_LOGGER_ENDL;
212 return _inqueue.poll(timeout * 1000);
213 }
catch (
const ibrcommon::QueueUnblockedException &ex) {
214 if (ex.reason == ibrcommon::QueueUnblockedException::QUEUE_TIMEOUT)
218 else if (ex.reason == ibrcommon::QueueUnblockedException::QUEUE_ABORT)
224 }
catch (
const std::exception &ex) {
void setBit(E flag, const bool &value)
void operator<<(const dtn::data::Bundle &b)
virtual void eventConnectionDown()
Client(const std::string &app, ibrcommon::socketstream &stream, const COMMUNICATION_MODE mode=MODE_BIDIRECTIONAL)
virtual void received(const dtn::streams::StreamContactHeader &)
dtn::api::Client * _client
dtn::data::Bundle getBundle(const dtn::data::Timeout timeout=0)
void handshake(const dtn::data::EID &eid, const dtn::data::Timeout &timeout, const dtn::data::Bitset< StreamContactHeader::HEADER_BITS > &flags)
void shutdown(ConnectionShutdownCases csc=CONNECTION_SHUTDOWN_SIMPLE_SHUTDOWN)
std::string getString() const
unidirectional communication is requested, no reception of bundles
virtual void eventBundleAck(const dtn::data::Length &ack)