5 #ifndef __DDS__BaseChannelImpl__ 6 #define __DDS__BaseChannelImpl__ 14 #include <boost/noncopyable.hpp> 15 #pragma clang diagnostic push 16 #pragma clang diagnostic ignored "-Wunused-local-typedef" 17 #pragma clang diagnostic ignored "-Wdeprecated-declarations" 18 #include <boost/asio.hpp> 19 #pragma clang diagnostic pop 21 #pragma clang diagnostic push 22 #pragma clang diagnostic ignored "-Wdeprecated-register" 23 #include <boost/uuid/uuid.hpp> 24 #include <boost/uuid/uuid_generators.hpp> 25 #include <boost/uuid/uuid_io.hpp> 26 #pragma clang diagnostic pop 38 namespace protocol_api
49 #define BEGIN_MSG_MAP(theClass) \ 51 friend protocol_api::CBaseChannelImpl<theClass>; \ 52 friend protocol_api::CClientChannelImpl<theClass>; \ 53 friend protocol_api::CServerChannelImpl<theClass>; \ 54 void processMessage(protocol_api::CProtocolMessage::protocolMessagePtr_t _currentMsg) \ 56 using namespace dds; \ 57 using namespace dds::protocol_api; \ 58 CMonitoringThread::instance().updateIdle(); \ 59 bool processed = true; \ 60 ECmdType currentCmd = static_cast<ECmdType>(_currentMsg->header().m_cmd); \ 62 sender.m_ID = _currentMsg->header().m_ID; \ 68 case cmdBINARY_ATTACHMENT: \ 70 typedef typename SCommandAttachmentImpl<cmdBINARY_ATTACHMENT>::ptr_t attahcmentPtr_t; \ 71 attahcmentPtr_t attachmentPtr = SCommandAttachmentImpl<cmdBINARY_ATTACHMENT>::decode(_currentMsg); \ 72 processBinaryAttachmentCmd(sender, attachmentPtr); \ 75 case cmdBINARY_ATTACHMENT_START: \ 77 typedef typename SCommandAttachmentImpl<cmdBINARY_ATTACHMENT_START>::ptr_t attahcmentPtr_t; \ 78 attahcmentPtr_t attachmentPtr = \ 79 SCommandAttachmentImpl<cmdBINARY_ATTACHMENT_START>::decode(_currentMsg); \ 80 processBinaryAttachmentStartCmd(sender, attachmentPtr); \ 85 SCommandAttachmentImpl<cmdHANDSHAKE>::ptr_t attachmentPtr = \ 86 SCommandAttachmentImpl<cmdHANDSHAKE>::decode(_currentMsg); \ 87 dispatchHandlers<>(currentCmd, sender, attachmentPtr); \ 90 case cmdLOBBY_MEMBER_HANDSHAKE: \ 92 SCommandAttachmentImpl<cmdLOBBY_MEMBER_HANDSHAKE>::ptr_t attachmentPtr = \ 93 SCommandAttachmentImpl<cmdLOBBY_MEMBER_HANDSHAKE>::decode(_currentMsg); \ 94 dispatchHandlers<>(currentCmd, sender, attachmentPtr); \ 97 case cmdREPLY_HANDSHAKE_OK: \ 99 SCommandAttachmentImpl<cmdREPLY_HANDSHAKE_OK>::ptr_t attachmentPtr = \ 100 SCommandAttachmentImpl<cmdREPLY_HANDSHAKE_OK>::decode(_currentMsg); \ 101 dispatchHandlers<>(currentCmd, sender, attachmentPtr); \ 104 case cmdREPLY_HANDSHAKE_ERR: \ 106 SCommandAttachmentImpl<cmdREPLY_HANDSHAKE_ERR>::ptr_t attachmentPtr = \ 107 SCommandAttachmentImpl<cmdREPLY_HANDSHAKE_ERR>::decode(_currentMsg); \ 108 dispatchHandlers<>(currentCmd, sender, attachmentPtr); \ 112 #define MESSAGE_HANDLER(msg, func) \ 115 typedef typename SCommandAttachmentImpl<msg>::ptr_t attahcmentPtr_t; \ 116 attahcmentPtr_t attachmentPtr = SCommandAttachmentImpl<msg>::decode(_currentMsg); \ 117 LOG(MiscCommon::debug) << "Processing " << g_cmdToString[msg] << " received from " << remoteEndIDString(); \ 118 processed = func(attachmentPtr, sender); \ 121 if (!handlerExists(msg)) \ 123 LOG(MiscCommon::error) << "The received message was not processed and has no registered handler: " \ 124 << _currentMsg->toString(); \ 128 dispatchHandlers<>(msg, sender, attachmentPtr); \ 134 #define END_MSG_MAP() \ 136 LOG(MiscCommon::error) << "The received message doesn't have a handler: " << _currentMsg->toString(); \ 139 catch (std::exception & _e) \ 141 LOG(MiscCommon::error) << "Channel processMessage: " << _e.what(); \ 146 #define RAW_MESSAGE_HANDLER(theClass, func) \ 147 BEGIN_MSG_MAP(theClass) \ 151 processed = func(_currentMsg); \ 154 if (!handlerExists(ECmdType::cmdRAW_MSG)) \ 156 LOG(MiscCommon::error) << "The received message was not processed and has no registered handler: " \ 157 << _currentMsg->toString(); \ 161 dispatchHandlers(ECmdType::cmdRAW_MSG, sender, _currentMsg); \ 165 catch (std::exception & _e) \ 167 LOG(MiscCommon::error) << "Channel processMessage: " << _e.what(); \ 171 #define REGISTER_DEFAULT_REMOTE_ID_STRING \ 172 std::string _remoteEndIDString() \ 174 return "DDS Server"; \ 179 namespace protocol_api
208 public std::enable_shared_from_this<T>,
211 typedef std::deque<CProtocolMessage::protocolMessagePtr_t> protocolMessagePtrQueue_t;
212 typedef std::vector<boost::asio::mutable_buffer> protocolMessageBuffer_t;
213 typedef std::shared_ptr<boost::asio::deadline_timer> deadlineTimerPtr_t;
231 , m_isHandshakeOK(
false)
233 , m_protocolHeaderID(_protocolHeaderID)
234 , m_io_service(_service)
237 , m_currentMsg(std::make_shared<CProtocolMessage>())
238 , m_binaryAttachmentMap()
239 , m_binaryAttachmentMutex()
241 std::make_shared<boost::asio::deadline_timer>(_service, boost::posix_time::milliseconds(1000)))
242 , m_isShuttingDown(
false)
249 catch (std::runtime_error& _error)
262 static connectionPtr_t
makeNew(boost::asio::io_service& _service, uint64_t _protocolHeaderID)
264 connectionPtr_t newObject(
new T(_service, _protocolHeaderID));
271 return m_isHandshakeOK;
276 return m_channelType;
281 m_channelType = _channelType;
292 ::fcntl(m_socket.native_handle(), F_SETFD, FD_CLOEXEC);
309 template <ECmdType _cmd>
312 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
313 m_writeQueue.erase(std::remove_if(std::begin(m_writeQueue),
314 std::end(m_writeQueue),
316 return (_msg->header().m_cmd == _cmd);
318 std::end(m_writeQueue));
323 static const size_t maxAccumulativeWriteQueueSize = 10000;
326 bool copyMessages =
false;
328 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
330 m_deadlineTimer->cancel();
333 m_accumulativeWriteQueue.push_back(_msg);
335 copyMessages = m_accumulativeWriteQueue.size() > maxAccumulativeWriteQueueSize;
339 <<
"copy accumulated queue to write queue " 340 "m_accumulativeWriteQueue.size=" 341 << m_accumulativeWriteQueue.size() <<
" m_writeQueue.size=" << m_writeQueue.size();
344 std::copy(m_accumulativeWriteQueue.begin(),
345 m_accumulativeWriteQueue.end(),
346 back_inserter((m_isHandshakeOK) ? m_writeQueue : m_writeQueueBeforeHandShake));
347 m_accumulativeWriteQueue.clear();
350 auto self(this->shared_from_this());
351 m_deadlineTimer->async_wait([
this,
self](
const boost::system::error_code& error) {
354 bool copyMessages =
false;
356 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
357 copyMessages = !m_accumulativeWriteQueue.empty();
362 <<
"deadline_timer called: copy accumulated queue to write queue " 363 "m_accumulativeWriteQueue.size=" 364 << m_accumulativeWriteQueue.size()
365 <<
" m_writeQueue.size=" << m_writeQueue.size();
366 std::copy(m_accumulativeWriteQueue.begin(),
367 m_accumulativeWriteQueue.end(),
368 back_inserter((m_isHandshakeOK) ? m_writeQueue
369 : m_writeQueueBeforeHandShake));
370 m_accumulativeWriteQueue.clear();
374 pushMsg<cmdUNKNOWN>();
379 <<
" WriteQueueBeforeHandShake = " << m_writeQueueBeforeHandShake.size()
380 <<
" accumulativeWriteQueue size = " << m_accumulativeWriteQueue.size()
381 <<
" msg = " << _msg->toString();
384 pushMsg<cmdUNKNOWN>();
386 catch (std::exception& ex)
392 template <ECmdType _cmd,
class A>
399 accumulativePushMsg(msg, _cmd);
401 catch (std::exception& ex)
407 template <ECmdType _cmd>
411 accumulativePushMsg<_cmd>(cmd, _protocolHeaderID);
418 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
419 if (!m_isHandshakeOK)
421 if (isCmdAllowedWithoutHandshake(_cmd))
422 m_writeQueue.push_back(_msg);
424 m_writeQueueBeforeHandShake.push_back(_msg);
429 if (!m_writeQueueBeforeHandShake.empty())
431 std::copy(m_writeQueueBeforeHandShake.begin(),
432 m_writeQueueBeforeHandShake.end(),
433 back_inserter(m_writeQueue));
434 m_writeQueueBeforeHandShake.clear();
439 m_writeQueue.push_back(_msg);
443 <<
" WriteQueueBeforeHandShake = " << m_writeQueueBeforeHandShake.size();
445 catch (std::exception& ex)
451 auto self(this->shared_from_this());
452 m_io_service.post([
this,
self] {
457 catch (std::exception& ex)
464 template <ECmdType _cmd,
class A>
465 void pushMsg(
const A& _attachment, uint64_t _protocolHeaderID = 0)
471 pushMsg(msg, _cmd, _protocolHeaderID);
473 catch (std::exception& ex)
479 template <ECmdType _cmd>
483 pushMsg<_cmd>(cmd, adjustProtocolHeaderID(_protocolHeaderID));
486 template <ECmdType _cmd,
class A>
487 void sendYourself(
const A& _attachment, uint64_t _protocolHeaderID = 0)
492 T* pThis =
static_cast<T*
>(
this);
493 pThis->processMessage(msg);
496 template <ECmdType _cmd>
500 sendYourself<_cmd>(cmd, adjustProtocolHeaderID(_protocolHeaderID));
504 const std::string& _fileName,
506 uint64_t _protocolHeaderID)
510 std::string srcFilePath(_srcFilePath);
514 std::ifstream f(srcFilePath);
515 if (!f.is_open() || !f.good())
517 throw std::runtime_error(
"Could not open the source file: " + srcFilePath);
519 f.seekg(0, std::ios::end);
520 data.reserve(f.tellg());
521 f.seekg(0, std::ios::beg);
522 data.assign((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
524 pushBinaryAttachmentCmd(data, _fileName, _cmdSource, _protocolHeaderID);
528 const std::string& _fileName,
530 uint64_t _protocolHeaderID)
532 static const int maxCommandSize = 65536;
533 int nofParts = (_data.size() % maxCommandSize == 0) ? (_data.size() / maxCommandSize)
534 : (_data.size() / maxCommandSize + 1);
535 boost::crc_32_type fileCrc32;
536 fileCrc32.process_bytes(&_data[0], _data.size());
538 boost::uuids::uuid fileId = boost::uuids::random_generator()();
547 pushMsg<cmdBINARY_ATTACHMENT_START>(start_cmd, _protocolHeaderID);
549 for (
size_t i = 0; i < nofParts; ++i)
554 size_t offset = i * maxCommandSize;
555 size_t size = (i != (nofParts - 1)) ? maxCommandSize : (_data.size() - offset);
557 auto iter_begin = _data.begin() + offset;
558 auto iter_end = iter_begin + size;
559 std::copy(iter_begin, iter_end, std::back_inserter(cmd.
m_data));
564 boost::crc_32_type crc32;
565 crc32.process_bytes(&(*iter_begin), size);
567 cmd.
m_crc32 = crc32.checksum();
569 pushMsg<cmdBINARY_ATTACHMENT>(cmd, _protocolHeaderID);
576 boost::uuids::uuid fileId = _attachment->m_fileId;
580 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
582 binaryAttachmentMap_t::iterator iter_info = m_binaryAttachmentMap.find(fileId);
583 bool exists = iter_info != m_binaryAttachmentMap.end();
587 m_binaryAttachmentMap[fileId] = std::make_shared<SBinaryAttachmentInfo>();
588 iter_info = m_binaryAttachmentMap.find(fileId);
589 iter_info->second->m_startTime = std::chrono::steady_clock::now();
590 iter_info->second->m_fileName = _attachment->m_fileName;
591 iter_info->second->m_fileSize = _attachment->m_fileSize;
592 iter_info->second->m_fileCrc32 = _attachment->m_fileCrc32;
593 iter_info->second->m_srcCommand = _attachment->m_srcCommand;
594 iter_info->second->m_data.resize(_attachment->m_fileSize);
602 boost::uuids::uuid fileId = _attachment->m_fileId;
603 binaryAttachmentInfoPtr_t info;
604 binaryAttachmentMap_t::iterator iter_info;
608 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
610 iter_info = m_binaryAttachmentMap.find(fileId);
611 bool exists = iter_info != m_binaryAttachmentMap.end();
616 <<
"Received binary attachment [" << fileId <<
"] which does not exist. Skip this message.";
619 info = iter_info->second;
622 boost::crc_32_type crc32;
623 crc32.process_bytes(&_attachment->m_data[0], _attachment->m_data.size());
625 if (crc32.checksum() != _attachment->m_crc32)
629 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
631 m_binaryAttachmentMap.erase(iter_info);
633 std::stringstream ss;
634 ss <<
"Received binary attachment [" << fileId <<
"] has wrong CRC32 checksum: " << crc32.checksum()
635 <<
" instead of " << _attachment->m_crc32 <<
"offset=" << _attachment->m_offset
636 <<
" size=" << _attachment->m_size;
643 bool allBytesReceived =
false;
646 std::lock_guard<std::mutex> lock(info->m_mutex);
648 info->m_bytesReceived += _attachment->m_size;
650 std::copy(_attachment->m_data.begin(),
651 _attachment->m_data.end(),
652 info->m_data.begin() + _attachment->m_offset);
654 allBytesReceived = info->m_bytesReceived == info->m_fileSize;
655 if (allBytesReceived)
658 boost::crc_32_type crc32;
659 crc32.process_bytes(&info->m_data[0], info->m_data.size());
661 if (crc32.checksum() != info->m_fileCrc32)
665 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
667 m_binaryAttachmentMap.erase(iter_info);
669 std::stringstream ss;
670 ss <<
"Received binary file [" << fileId
671 <<
"] has wrong CRC32 checksum: " << crc32.checksum() <<
" instead of " 672 << _attachment->m_crc32;
680 const std::string fileName(dir + to_string(fileId));
681 std::ofstream f(fileName.c_str());
682 if (!f.is_open() || !f.good())
686 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
688 m_binaryAttachmentMap.erase(iter_info);
690 std::stringstream ss;
691 ss <<
"Could not open file: " << fileName;
698 for (
const auto& v : info->m_data)
704 std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
705 std::chrono::microseconds downloadTime =
706 std::chrono::duration_cast<std::chrono::microseconds>(now - info->m_startTime);
711 reply_cmd.m_requestedFileName = info->m_fileName;
712 reply_cmd.m_srcCommand = info->m_srcCommand;
713 reply_cmd.m_downloadTime = downloadTime.count();
714 reply_cmd.m_receivedFileSize = info->m_fileSize;
715 sendYourself<cmdBINARY_ATTACHMENT_RECEIVED>(reply_cmd, _sender.
m_ID);
719 if (allBytesReceived)
722 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
724 m_binaryAttachmentMap.erase(iter_info);
738 T* pThis =
static_cast<T*
>(
this);
739 std::stringstream ss;
740 ss << pThis->_remoteEndIDString() <<
" [" << socket().remote_endpoint().address().to_string()
746 return std::string();
752 return m_protocolHeaderID;
756 uint64_t adjustProtocolHeaderID(uint64_t _protocolHeaderID)
const 758 return _protocolHeaderID != 0 ? _protocolHeaderID : m_protocolHeaderID;
763 auto self(this->shared_from_this());
764 boost::asio::async_read(
767 [
this,
self](boost::system::error_code ec, std::size_t length) {
773 if (!ec && m_currentMsg->decode_header())
778 else if ((boost::asio::error::eof == ec) || (boost::asio::error::connection_reset == ec))
781 <<
"Disconnect is detected while on read msg header: " << ec.message();
790 "closing the connection: " 800 if (m_currentMsg->body_length() == 0)
803 <<
": no attachment: " << m_currentMsg->toString();
805 T* pThis =
static_cast<T*
>(
this);
806 pThis->processMessage(m_currentMsg);
809 this->logReadMessage(m_currentMsg);
812 m_currentMsg = std::make_shared<CProtocolMessage>();
817 auto self(this->shared_from_this());
818 boost::asio::async_read(
820 boost::asio::buffer(m_currentMsg->body(), m_currentMsg->body_length()),
821 [
this,
self](boost::system::error_code ec, std::size_t length) {
825 << length <<
" bytes): " << m_currentMsg->toString();
828 T* pThis =
static_cast<T*
>(
this);
829 pThis->processMessage(m_currentMsg);
832 this->logReadMessage(m_currentMsg);
835 m_currentMsg = std::make_shared<CProtocolMessage>();
838 else if ((boost::asio::error::eof == ec) || (boost::asio::error::connection_reset == ec))
850 "closing the connection: " 864 std::lock_guard<std::mutex> lockWriteBuffer(m_mutexWriteBuffer);
865 if (!m_writeBuffer.empty())
868 if (m_writeQueue.empty())
871 for (
auto i : m_writeQueue)
874 <<
"Sending to " << remoteEndIDString() <<
" a message: " << i->toString();
876 m_isShuttingDown =
true;
877 m_writeBuffer.push_back(boost::asio::buffer(i->data(), i->length()));
878 m_writeBufferQueue.push_back(i);
880 m_writeQueue.clear();
883 auto self(this->shared_from_this());
884 boost::asio::async_write(
887 [
this,
self](boost::system::error_code _ec, std::size_t _bytesTransferred) {
893 << _bytesTransferred <<
" bytes)";
895 if (m_isShuttingDown)
898 <<
"Shutdown signal has been successfully sent to " << remoteEndIDString();
904 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
907 this->logWriteMessages(m_writeBufferQueue);
909 m_writeBuffer.clear();
910 m_writeBufferQueue.clear();
915 else if ((boost::asio::error::eof == _ec) || (boost::asio::error::connection_reset == _ec))
918 <<
"Disconnect is detected while on write message: " << _ec.message();
926 <<
"Error sending to " << remoteEndIDString() <<
": " << _ec.message();
929 <<
"The stop signal is received, aborting current operation and " 930 "closing the connection: " 935 catch (std::exception& ex)
944 LOG(
MiscCommon::debug) <<
"The session was disconnected by the remote end: " << remoteEndIDString();
952 bool isCmdAllowedWithoutHandshake(
ECmdType _cmd)
972 boost::asio::io_service& m_io_service;
973 boost::asio::ip::tcp::socket m_socket;
977 protocolMessagePtrQueue_t m_writeQueue;
978 protocolMessagePtrQueue_t m_writeQueueBeforeHandShake;
980 std::mutex m_mutexWriteBuffer;
981 protocolMessageBuffer_t m_writeBuffer;
982 protocolMessagePtrQueue_t m_writeBufferQueue;
985 typedef std::map<boost::uuids::uuid, binaryAttachmentInfoPtr_t> binaryAttachmentMap_t;
986 binaryAttachmentMap_t m_binaryAttachmentMap;
987 std::mutex m_binaryAttachmentMutex;
989 protocolMessagePtrQueue_t m_accumulativeWriteQueue;
990 deadlineTimerPtr_t m_deadlineTimer;
992 bool m_isShuttingDown;
bool m_isHandshakeOK
Definition: BaseChannelImpl.h:966
std::shared_ptr< T > connectionPtr_t
Definition: BaseChannelImpl.h:216
std::string m_receivedFilePath
Path to the received file.
Definition: BinaryAttachmentReceivedCmd.h:23
void processBinaryAttachmentCmd(const SSenderInfo &_sender, SCommandAttachmentImpl< cmdBINARY_ATTACHMENT >::ptr_t _attachment)
Definition: BaseChannelImpl.h:599
Definition: BaseEventHandlersImpl.h:48
boost::uuids::uuid m_fileId
Unique ID of the file.
Definition: BinaryAttachmentCmd.h:29
EChannelType
Definition: ProtocolDef.h:15
Definition: BaseChannelImpl.h:181
Definition: ProtocolCommands.h:34
void accumulativePushMsg(CProtocolMessage::protocolMessagePtr_t _msg, ECmdType _cmd)
Definition: BaseChannelImpl.h:321
EChannelType m_channelType
Definition: BaseChannelImpl.h:967
DDS_DECLARE_EVENT_HANDLER_CLASS(CChannelEventHandlersImpl) DDS_DECLARE_EVENT_HANDLER_CLASS(CChannelMessageHandlersImpl) protected
Definition: BaseChannelImpl.h:223
void pushBinaryAttachmentCmd(const std::string &_srcFilePath, const std::string &_fileName, uint16_t _cmdSource, uint64_t _protocolHeaderID)
Definition: BaseChannelImpl.h:503
Definition: ChannelEventHandlersImpl.h:29
uint32_t m_fileSize
File size in bytes.
Definition: BinaryAttachmentStartCmd.h:31
Definition: BinaryAttachmentReceivedCmd.h:15
static connectionPtr_t makeNew(boost::asio::io_service &_service, uint64_t _protocolHeaderID)
Definition: BaseChannelImpl.h:262
static std::string getDDSPath()
Definition: UserDefaults.cpp:251
Definition: CommandAttachmentImpl.h:56
bool started()
Definition: BaseChannelImpl.h:728
bool isHanshakeOK() const
Definition: BaseChannelImpl.h:269
uint32_t m_fileCrc32
File checksum.
Definition: BinaryAttachmentStartCmd.h:32
std::string getLockedSID() const
Definition: UserDefaults.cpp:476
std::shared_ptr< SEmptyCmd > ptr_t
Definition: CommandAttachmentImpl.h:66
void pushMsg(CProtocolMessage::protocolMessagePtr_t _msg, ECmdType _cmd, uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:414
Definition: BinaryAttachmentStartCmd.h:21
void accumulativePushMsg(const A &_attachment, uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:393
std::chrono::steady_clock::time_point m_startTime
Definition: BaseChannelImpl.h:199
Definition: ProtocolCommands.h:30
std::string m_sessionID
Definition: BaseChannelImpl.h:968
static CProtocolMessage::protocolMessagePtr_t encode(const SEmptyCmd &, uint64_t _ID)
Definition: CommandAttachmentImpl.h:73
#define DDS_DECLARE_EVENT_HANDLER_CLASS(theClass)
Definition: BaseEventHandlersImpl.h:39
MiscCommon::BYTEVector_t m_data
Definition: BaseChannelImpl.h:192
const std::array< std::string, 5 > gChannelTypeName
Definition: ProtocolDef.h:23
void pushMsg(uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:480
#define LOG(severity)
Definition: Logger.h:54
std::weak_ptr< T > weakConnectionPtr_t
Definition: BaseChannelImpl.h:217
Definition: SimpleMsgCmd.h:16
Definition: ProtocolCommands.h:35
uint32_t m_size
Size of this piece of binary data.
Definition: BinaryAttachmentCmd.h:31
Definition: BinaryAttachmentCmd.h:21
EChannelType getChannelType() const
Definition: BaseChannelImpl.h:274
void start()
Definition: BaseChannelImpl.h:285
uint32_t m_fileSize
Definition: BaseChannelImpl.h:197
Definition: dds-agent/src/AgentConnectionManager.h:18
std::string remoteEndIDString()
Definition: BaseChannelImpl.h:733
Definition: ProtocolMessage.h:88
uint32_t m_crc32
CRC checksum of this piece of binary data.
Definition: BinaryAttachmentCmd.h:32
uint32_t m_offset
Offset for this piece of binary data.
Definition: BinaryAttachmentCmd.h:30
Definition: BaseChannelImpl.h:205
void pushMsg(const A &_attachment, uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:465
std::string m_fileName
Name of the file.
Definition: BinaryAttachmentStartCmd.h:30
void processBinaryAttachmentStartCmd(const SSenderInfo &_sender, SCommandAttachmentImpl< cmdBINARY_ATTACHMENT_START >::ptr_t _attachment)
Definition: BaseChannelImpl.h:573
Definition: BaseChannelImpl.h:43
void dequeueMsg()
Definition: BaseChannelImpl.h:310
void accumulativePushMsg(uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:408
SBinaryAttachmentInfo()
Definition: BaseChannelImpl.h:183
Definition: BaseChannelImpl.h:41
static CUserDefaults & instance(const boost::uuids::uuid &_sid=CUserDefaults::getInitialSID())
Return singleton instance.
Definition: UserDefaults.cpp:45
uint32_t m_fileCrc32
Definition: BaseChannelImpl.h:195
void pushBinaryAttachmentCmd(const MiscCommon::BYTEVector_t &_data, const std::string &_fileName, uint16_t _cmdSource, uint64_t _protocolHeaderID)
Definition: BaseChannelImpl.h:527
std::vector< weakConnectionPtr_t > weakConnectionPtrVector_t
Definition: BaseChannelImpl.h:219
void smart_path(_T *_Path)
The function extends any environment variable found in the give path to its value.
Definition: SysHelper.h:93
Definition: StatImpl.h:112
std::shared_ptr< SBinaryAttachmentInfo > binaryAttachmentInfoPtr_t
Definition: BaseChannelImpl.h:202
void sendYourself(const A &_attachment, uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:487
void sendYourself(uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:497
MiscCommon::BYTEVector_t m_data
Piece of binary data.
Definition: BinaryAttachmentCmd.h:33
std::vector< unsigned char > BYTEVector_t
An STL vector of bytes.
Definition: def.h:127
std::mutex m_mutex
Definition: BaseChannelImpl.h:198
boost::asio::ip::tcp::socket & socket()
Definition: BaseChannelImpl.h:304
boost::uuids::uuid m_fileId
Unique ID of the file.
Definition: BinaryAttachmentStartCmd.h:29
uint32_t m_bytesReceived
Definition: BaseChannelImpl.h:193
uint64_t m_ID
Definition: BaseEventHandlersImpl.h:55
uint16_t m_srcCommand
Source command which initiated file transport.
Definition: BinaryAttachmentStartCmd.h:33
std::string m_fileName
Definition: BaseChannelImpl.h:194
uint64_t getProtocolHeaderID() const
Definition: BaseChannelImpl.h:750
Definition: ProtocolCommands.h:31
std::vector< connectionPtr_t > connectionPtrVector_t
Definition: BaseChannelImpl.h:218
void setChannelType(EChannelType _channelType)
Definition: BaseChannelImpl.h:279
Definition: ChannelMessageHandlersImpl.h:20
uint16_t m_srcCommand
Definition: BaseChannelImpl.h:196
ECmdType
Definition: ProtocolCommands.h:25
Definition: ProtocolCommands.h:28
void stop()
Definition: BaseChannelImpl.h:296
uint64_t m_protocolHeaderID
Definition: BaseChannelImpl.h:969
std::shared_ptr< CProtocolMessage > protocolMessagePtr_t
Definition: ProtocolMessage.h:80