virtual void onDigest(const Feature & input) { if (_noPrint) { publish(input); return; } if (_eachStep) { #ifdef __ANDROID_API__ std::stringstream ss; ss << _label.c_str() << ": "; for (int j=0;j<input.size(); ++j) ss << input[j] << " "; LOGE("<Sample id=%d label=%s>%s</sample>", _onlySample, _label, ss.str().c_str()); #else print("<sample id=", _onlySample, " label=", _label ,">", input, "</sample>"); #endif } else { _bundle.push_back(input.data(), input.size()); } publish(input); }
void EchoWorker::callbackBundleReceived(const Bundle &b) { try { const PayloadBlock &payload = b.find<PayloadBlock>(); // generate a echo Bundle echo; // make a copy of the payload block ibrcommon::BLOB::Reference ref = payload.getBLOB(); echo.push_back(ref); // set destination and mark the bundle as singleton destination echo.destination = b.source; echo.set(dtn::data::PrimaryBlock::DESTINATION_IS_SINGLETON, true); // set the source of the bundle echo.source = getWorkerURI(); // set the lifetime to the same value as the received bundle echo.lifetime = b.lifetime; // sign the reply if the echo-request was signed too if (b.get(dtn::data::PrimaryBlock::DTNSEC_STATUS_VERIFIED)) echo.set(dtn::data::PrimaryBlock::DTNSEC_REQUEST_SIGN, true); // encrypt the reply if the echo-request was encrypt too if (b.get(dtn::data::PrimaryBlock::DTNSEC_STATUS_CONFIDENTIAL)) echo.set(dtn::data::PrimaryBlock::DTNSEC_REQUEST_ENCRYPT, true); try { const dtn::data::TrackingBlock &tracking = b.find<dtn::data::TrackingBlock>(); dtn::data::TrackingBlock &target = echo.push_back<dtn::data::TrackingBlock>(); // copy tracking block target = tracking; } catch (const dtn::data::Bundle::NoSuchBlockFoundException&) { }; IBRCOMMON_LOGGER_DEBUG_TAG("EchoWorker", 5) << "echo request received, replying!" << IBRCOMMON_LOGGER_ENDL; // send it transmit( echo ); } catch (const dtn::data::Bundle::NoSuchBlockFoundException&) { } }