42 const std::string NativeSession::TAG =
"NativeSession";
45 : _receiver(*this), _session_cb(session_cb), _serializer_cb(serializer_cb)
57 : _registration(handle), _receiver(*this), _session_cb(session_cb), _serializer_cb(serializer_cb)
74 _serializer_cb = NULL;
85 _registration.
abort();
96 if (_session_cb == NULL)
return;
97 _session_cb->notifyBundle(
id);
103 if (_session_cb == NULL)
return;
104 _session_cb->notifyStatusReport(source, report);
110 if (_session_cb == NULL)
return;
111 _session_cb->notifyCustodySignal(source, custody);
117 if (suffix.length() <= 0)
124 _registration.unsubscribe(_endpoint);
127 _endpoint.setApplication(suffix);
130 _registration.subscribe(_endpoint);
148 if (suffix.length() <= 0)
156 _registration.subscribe(new_endpoint);
165 if (suffix.length() <= 0)
173 _registration.unsubscribe(old_endpoint);
188 _registration.subscribe(eid);
203 _registration.unsubscribe(eid);
214 for (std::set<dtn::data::EID>::const_iterator it = subs.begin(); it != subs.end(); ++it) {
216 if (e != _endpoint) {
227 std::vector<std::string> ret;
228 for (std::set<dtn::data::EID>::const_iterator it = subs.begin(); it != subs.end(); ++it) {
229 ret.push_back((*it).getString());
267 if (_serializer_cb == NULL)
return;
271 serializer << _bundle[ri];
280 if (_serializer_cb == NULL)
return;
284 serializer << _bundle[ri];
310 _registration.delivered(meta);
351 std::streamsize stream_size = stream.
size();
353 if ((offset > 0) || (stream_size < static_cast<std::streamsize>(offset))) {
354 (*stream).seekp(0, std::ios_base::end);
356 (*stream).seekp(offset);
359 (*stream).write(buf, len);
360 (*stream) << std::flush;
367 std::streamsize stream_size = stream.
size();
369 if ((offset > 0) || (stream_size < static_cast<std::streamsize>(offset))) {
370 (*stream).seekp(0, std::ios_base::end);
372 (*stream).seekp(offset);
374 (*stream).write(buf, len);
375 (*stream) << std::flush;
389 (*stream).seekg(offset);
390 (*stream).read(buf, len);
392 len = (*stream).gcount();
399 NativeSession::BundleReceiver::BundleReceiver(
NativeSession &session)
404 NativeSession::BundleReceiver::~BundleReceiver()
408 void NativeSession::BundleReceiver::raiseEvent(
const dtn::core::Event *evt)
throw ()
420 }
catch (
const std::bad_cast&) { };
432 fireNotificationAdministrativeRecord(
id);
440 _bundle_queue.
push(
id);
443 fireNotificationBundle(
id);
450 throw NativeSessionException(std::string(
"loop aborted - ") + ex.
what());
451 }
catch (
const std::exception &ex) {
452 throw NativeSessionException(std::string(
"loop aborted - ") + ex.what());
467 report.
read(payload);
472 fireNotificationStatusReport(b.
source, report);
480 custody.
read(payload);
485 fireNotificationCustodySignal(b.
source, custody);