5 #ifndef __DDS__BaseChannelImpl__ 6 #define __DDS__BaseChannelImpl__ 14 #include <boost/asio.hpp> 15 #include <boost/filesystem.hpp> 16 #include <boost/noncopyable.hpp> 17 #include <boost/uuid/uuid.hpp> 18 #include <boost/uuid/uuid_generators.hpp> 19 #include <boost/uuid/uuid_io.hpp> 28 namespace fs = boost::filesystem;
32 namespace protocol_api
43 #define BEGIN_MSG_MAP(theClass) \ 45 friend protocol_api::CBaseChannelImpl<theClass>; \ 46 friend protocol_api::CClientChannelImpl<theClass>; \ 47 friend protocol_api::CServerChannelImpl<theClass>; \ 48 void processMessage(protocol_api::CProtocolMessage::protocolMessagePtr_t _currentMsg) \ 50 using namespace dds; \ 51 using namespace dds::protocol_api; \ 52 CMonitoringThread::instance().updateIdle(); \ 53 bool processed = true; \ 55 ECmdType currentCmd = static_cast<ECmdType>(_currentMsg->header().m_cmd); \ 57 sender.m_ID = _currentMsg->header().m_ID; \ 63 case cmdBINARY_ATTACHMENT: \ 65 typedef typename SCommandAttachmentImpl<cmdBINARY_ATTACHMENT>::ptr_t attahcmentPtr_t; \ 66 attahcmentPtr_t attachmentPtr = SCommandAttachmentImpl<cmdBINARY_ATTACHMENT>::decode(_currentMsg); \ 67 processBinaryAttachmentCmd(sender, attachmentPtr); \ 70 case cmdBINARY_ATTACHMENT_START: \ 72 typedef typename SCommandAttachmentImpl<cmdBINARY_ATTACHMENT_START>::ptr_t attahcmentPtr_t; \ 73 attahcmentPtr_t attachmentPtr = \ 74 SCommandAttachmentImpl<cmdBINARY_ATTACHMENT_START>::decode(_currentMsg); \ 75 processBinaryAttachmentStartCmd(sender, attachmentPtr); \ 80 SCommandAttachmentImpl<cmdHANDSHAKE>::ptr_t attachmentPtr = \ 81 SCommandAttachmentImpl<cmdHANDSHAKE>::decode(_currentMsg); \ 82 dispatchHandlers<>(currentCmd, sender, attachmentPtr); \ 85 case cmdLOBBY_MEMBER_HANDSHAKE: \ 87 SCommandAttachmentImpl<cmdLOBBY_MEMBER_HANDSHAKE>::ptr_t attachmentPtr = \ 88 SCommandAttachmentImpl<cmdLOBBY_MEMBER_HANDSHAKE>::decode(_currentMsg); \ 89 dispatchHandlers<>(currentCmd, sender, attachmentPtr); \ 92 case cmdREPLY_HANDSHAKE_OK: \ 94 SCommandAttachmentImpl<cmdREPLY_HANDSHAKE_OK>::ptr_t attachmentPtr = \ 95 SCommandAttachmentImpl<cmdREPLY_HANDSHAKE_OK>::decode(_currentMsg); \ 96 dispatchHandlers<>(currentCmd, sender, attachmentPtr); \ 99 case cmdREPLY_HANDSHAKE_ERR: \ 101 SCommandAttachmentImpl<cmdREPLY_HANDSHAKE_ERR>::ptr_t attachmentPtr = \ 102 SCommandAttachmentImpl<cmdREPLY_HANDSHAKE_ERR>::decode(_currentMsg); \ 103 dispatchHandlers<>(currentCmd, sender, attachmentPtr); \ 107 #define MESSAGE_HANDLER(msg, func) \ 110 typedef typename SCommandAttachmentImpl<msg>::ptr_t attahcmentPtr_t; \ 111 attahcmentPtr_t attachmentPtr = SCommandAttachmentImpl<msg>::decode(_currentMsg); \ 112 LOG(dds::misc::debug) << "Processing " << g_cmdToString[msg] << " received from " << remoteEndIDString(); \ 113 processed = func(attachmentPtr, sender); \ 116 if (!handlerExists(msg)) \ 118 LOG(dds::misc::error) << "The received message was not processed and has no registered handler: " \ 119 << _currentMsg->toString(); \ 123 dispatchHandlers<>(msg, sender, attachmentPtr); \ 129 #define MESSAGE_HANDLER_DISPATCH(msg) \ 133 typedef typename SCommandAttachmentImpl<msg>::ptr_t attahcmentPtr_t; \ 134 attahcmentPtr_t attachmentPtr = SCommandAttachmentImpl<msg>::decode(_currentMsg); \ 135 LOG(dds::misc::debug) << "Dispatching " << g_cmdToString[msg] << " received from " << remoteEndIDString(); \ 136 if (!handlerExists(msg)) \ 138 LOG(dds::misc::error) << "The received message can't be dispatched, it has no registered handler: " \ 139 << _currentMsg->toString(); \ 143 dispatchHandlers<>(msg, sender, attachmentPtr); \ 148 #define END_MSG_MAP() \ 150 LOG(dds::misc::error) << "The received message doesn't have a handler: " << _currentMsg->toString(); \ 153 catch (std::exception & _e) \ 155 LOG(dds::misc::error) << "Channel processMessage (" << _currentMsg->toString() << "): " << _e.what(); \ 160 #define RAW_MESSAGE_HANDLER(theClass, func) \ 161 BEGIN_MSG_MAP(theClass) \ 165 processed = func(_currentMsg); \ 168 if (!handlerExists(ECmdType::cmdRAW_MSG)) \ 170 LOG(dds::misc::error) << "The received message was not processed and has no registered handler: " \ 171 << _currentMsg->toString(); \ 175 dispatchHandlers(ECmdType::cmdRAW_MSG, sender, _currentMsg); \ 179 catch (std::exception & _e) \ 181 LOG(dds::misc::error) << "Channel processMessage: " << _e.what(); \ 185 #define REGISTER_DEFAULT_REMOTE_ID_STRING \ 186 std::string _remoteEndIDString() \ 188 return "DDS Server"; \ 193 namespace protocol_api
222 public std::enable_shared_from_this<T>
224 typedef std::deque<CProtocolMessage::protocolMessagePtr_t> protocolMessagePtrQueue_t;
225 typedef std::vector<boost::asio::mutable_buffer> protocolMessageBuffer_t;
226 typedef std::shared_ptr<boost::asio::deadline_timer> deadlineTimerPtr_t;
250 , m_binaryAttachmentMap()
251 , m_binaryAttachmentMutex()
253 std::make_shared<boost::asio::deadline_timer>(_service, boost::posix_time::milliseconds(1000)))
254 , m_isShuttingDown(false)
261 catch (std::runtime_error& _error)
274 template <
class... Args>
276 uint64_t _protocolHeaderID,
279 connectionPtr_t newObject(
new T(_service, _protocolHeaderID, args...));
307 ::fcntl(m_socket.native_handle(), F_SETFD, FD_CLOEXEC);
324 template <ECmdType _cmd>
327 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
328 m_writeQueue.erase(std::remove_if(std::begin(m_writeQueue),
329 std::end(m_writeQueue),
331 {
return (_msg->header().m_cmd == _cmd); }),
332 std::end(m_writeQueue));
337 static const size_t maxAccumulativeWriteQueueSize = 10000;
340 bool copyMessages =
false;
342 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
344 m_deadlineTimer->cancel();
347 m_accumulativeWriteQueue.push_back(_msg);
349 copyMessages = m_accumulativeWriteQueue.size() > maxAccumulativeWriteQueueSize;
353 <<
"copy accumulated queue to write queue " 354 "m_accumulativeWriteQueue.size=" 355 << m_accumulativeWriteQueue.size() <<
" m_writeQueue.size=" << m_writeQueue.size();
358 std::copy(m_accumulativeWriteQueue.begin(),
359 m_accumulativeWriteQueue.end(),
360 back_inserter((
m_isHandshakeOK) ? m_writeQueue : m_writeQueueBeforeHandShake));
361 m_accumulativeWriteQueue.clear();
364 auto self(this->shared_from_this());
365 m_deadlineTimer->async_wait(
366 [
this,
self](
const boost::system::error_code& error)
370 bool copyMessages =
false;
372 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
373 copyMessages = !m_accumulativeWriteQueue.empty();
378 <<
"deadline_timer called: copy accumulated queue to write queue " 379 "m_accumulativeWriteQueue.size=" 380 << m_accumulativeWriteQueue.size()
381 <<
" m_writeQueue.size=" << m_writeQueue.size();
382 std::copy(m_accumulativeWriteQueue.begin(),
383 m_accumulativeWriteQueue.end(),
385 : m_writeQueueBeforeHandShake));
386 m_accumulativeWriteQueue.clear();
390 pushMsg<cmdUNKNOWN>();
395 <<
" WriteQueueBeforeHandShake = " << m_writeQueueBeforeHandShake.size()
396 <<
" accumulativeWriteQueue size = " << m_accumulativeWriteQueue.size()
397 <<
" msg = " << _msg->toString();
400 pushMsg<cmdUNKNOWN>();
402 catch (std::exception& ex)
408 template <ECmdType _cmd,
class A>
417 catch (std::exception& ex)
423 template <ECmdType _cmd>
427 accumulativePushMsg<_cmd>(cmd, _protocolHeaderID);
434 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
437 if (isCmdAllowedWithoutHandshake(_cmd))
438 m_writeQueue.push_back(_msg);
440 m_writeQueueBeforeHandShake.push_back(_msg);
445 if (!m_writeQueueBeforeHandShake.empty())
447 std::copy(m_writeQueueBeforeHandShake.begin(),
448 m_writeQueueBeforeHandShake.end(),
449 back_inserter(m_writeQueue));
450 m_writeQueueBeforeHandShake.clear();
455 m_writeQueue.push_back(_msg);
459 <<
" WriteQueueBeforeHandShake = " << m_writeQueueBeforeHandShake.size();
461 catch (std::exception& ex)
467 auto self(this->shared_from_this());
475 catch (std::exception& ex)
482 template <ECmdType _cmd,
class A>
483 void pushMsg(
const A& _attachment, uint64_t _protocolHeaderID = 0)
489 pushMsg(msg, _cmd, _protocolHeaderID);
491 catch (std::exception& ex)
497 template <ECmdType _cmd>
501 pushMsg<_cmd>(cmd, adjustProtocolHeaderID(_protocolHeaderID));
504 template <ECmdType _cmd,
class A>
505 void sendYourself(
const A& _attachment, uint64_t _protocolHeaderID = 0)
510 T* pThis = static_cast<T*>(
this);
511 pThis->processMessage(msg);
514 template <ECmdType _cmd>
518 sendYourself<_cmd>(cmd, adjustProtocolHeaderID(_protocolHeaderID));
522 const std::string& _fileName,
524 uint64_t _protocolHeaderID)
528 std::string srcFilePath(_srcFilePath);
532 std::ifstream f(srcFilePath);
533 if (!f.is_open() || !f.good())
535 throw std::runtime_error(
"Could not open the source file: " + srcFilePath);
537 f.seekg(0, std::ios::end);
538 data.reserve(f.tellg());
539 f.seekg(0, std::ios::beg);
540 data.assign((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
546 const std::string& _fileName,
548 uint64_t _protocolHeaderID)
550 static const int maxCommandSize = 65536;
551 int nofParts = (_data.size() % maxCommandSize == 0) ? (_data.size() / maxCommandSize)
552 : (_data.size() / maxCommandSize + 1);
553 boost::crc_32_type fileCrc32;
554 fileCrc32.process_bytes(&_data[0], _data.size());
556 boost::uuids::uuid fileId = boost::uuids::random_generator()();
565 pushMsg<cmdBINARY_ATTACHMENT_START>(start_cmd, _protocolHeaderID);
567 for (
int i = 0; i < nofParts; ++i)
572 size_t offset = i * maxCommandSize;
573 size_t size = (i != (nofParts - 1)) ? maxCommandSize : (_data.size() - offset);
575 auto iter_begin = _data.begin() + offset;
576 auto iter_end = iter_begin + size;
577 std::copy(iter_begin, iter_end, std::back_inserter(cmd.
m_data));
582 boost::crc_32_type
crc32;
583 crc32.process_bytes(&(*iter_begin), size);
587 pushMsg<cmdBINARY_ATTACHMENT>(cmd, _protocolHeaderID);
594 boost::uuids::uuid fileId = _attachment->m_fileId;
598 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
600 binaryAttachmentMap_t::iterator iter_info = m_binaryAttachmentMap.find(fileId);
601 bool exists = iter_info != m_binaryAttachmentMap.end();
605 m_binaryAttachmentMap[fileId] = std::make_shared<SBinaryAttachmentInfo>();
606 iter_info = m_binaryAttachmentMap.find(fileId);
607 iter_info->second->m_startTime = std::chrono::steady_clock::now();
608 iter_info->second->m_fileName = _attachment->m_fileName;
609 iter_info->second->m_fileSize = _attachment->m_fileSize;
610 iter_info->second->m_fileCrc32 = _attachment->m_fileCrc32;
611 iter_info->second->m_srcCommand = _attachment->m_srcCommand;
612 iter_info->second->m_data.resize(_attachment->m_fileSize);
620 boost::uuids::uuid fileId = _attachment->m_fileId;
622 binaryAttachmentMap_t::iterator iter_info;
626 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
628 iter_info = m_binaryAttachmentMap.find(fileId);
629 bool exists = iter_info != m_binaryAttachmentMap.end();
634 <<
"Received binary attachment [" << fileId <<
"] which does not exist. Skip this message.";
637 info = iter_info->second;
640 boost::crc_32_type
crc32;
641 crc32.process_bytes(&_attachment->m_data[0], _attachment->m_data.size());
643 if (
crc32.checksum() != _attachment->m_crc32)
647 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
649 m_binaryAttachmentMap.erase(iter_info);
651 std::stringstream ss;
652 ss <<
"Received binary attachment [" << fileId <<
"] has wrong CRC32 checksum: " <<
crc32.checksum()
653 <<
" instead of " << _attachment->m_crc32 <<
"offset=" << _attachment->m_offset
654 <<
" size=" << _attachment->m_size;
661 bool allBytesReceived =
false;
664 std::lock_guard<std::mutex> lock(info->m_mutex);
666 info->m_bytesReceived += _attachment->m_size;
668 std::copy(_attachment->m_data.begin(),
669 _attachment->m_data.end(),
670 info->m_data.begin() + _attachment->m_offset);
672 allBytesReceived = info->m_bytesReceived == info->m_fileSize;
673 if (allBytesReceived)
676 boost::crc_32_type
crc32;
677 crc32.process_bytes(&info->m_data[0], info->m_data.size());
679 if (
crc32.checksum() != info->m_fileCrc32)
683 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
685 m_binaryAttachmentMap.erase(iter_info);
687 std::stringstream ss;
688 ss <<
"Received binary file [" << fileId
689 <<
"] has wrong CRC32 checksum: " <<
crc32.checksum() <<
" instead of " 690 << _attachment->m_crc32;
698 const std::string filePath(dir.append(to_string(fileId)).string());
699 std::ofstream f(filePath.c_str());
700 if (!f.is_open() || !f.good())
704 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
706 m_binaryAttachmentMap.erase(iter_info);
708 std::stringstream ss;
709 ss <<
"Could not open file: " << filePath;
716 for (
const auto& v : info->m_data)
722 std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
723 std::chrono::microseconds downloadTime =
724 std::chrono::duration_cast<std::chrono::microseconds>(now - info->m_startTime);
733 sendYourself<cmdBINARY_ATTACHMENT_RECEIVED>(reply_cmd, _sender.
m_ID);
737 if (allBytesReceived)
740 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
742 m_binaryAttachmentMap.erase(iter_info);
756 T* pThis = static_cast<T*>(
this);
757 std::stringstream ss;
758 ss << pThis->_remoteEndIDString() <<
" [" <<
socket().remote_endpoint().address().to_string()
764 return std::string();
774 uint64_t adjustProtocolHeaderID(uint64_t _protocolHeaderID)
const 781 auto self(this->shared_from_this());
782 boost::asio::async_read(
785 [
this,
self](boost::system::error_code ec, std::size_t length)
792 if (!ec && m_currentMsg->decode_header())
797 else if ((boost::asio::error::eof == ec) || (boost::asio::error::connection_reset == ec))
800 <<
"Disconnect is detected while on read msg header: " << ec.message();
808 LOG(
dds::misc::info) <<
"The stop signal is received, aborting current operation and " 809 "closing the connection: " 819 if (m_currentMsg->body_length() == 0)
822 <<
": no attachment: " << m_currentMsg->toString();
824 T* pThis = static_cast<T*>(
this);
825 pThis->processMessage(m_currentMsg);
828 m_currentMsg = std::make_shared<CProtocolMessage>();
833 auto self(this->shared_from_this());
834 boost::asio::async_read(
836 boost::asio::buffer(m_currentMsg->body(), m_currentMsg->body_length()),
837 [
this,
self](boost::system::error_code ec, std::size_t length)
842 << length <<
" bytes): " << m_currentMsg->toString();
845 T* pThis = static_cast<T*>(
this);
846 pThis->processMessage(m_currentMsg);
849 m_currentMsg = std::make_shared<CProtocolMessage>();
852 else if ((boost::asio::error::eof == ec) || (boost::asio::error::connection_reset == ec))
854 LOG(
dds::misc::debug) <<
"Disconnect is detected while on read msg body: " << ec.message();
863 LOG(
dds::misc::info) <<
"The stop signal is received, aborting current operation and " 864 "closing the connection: " 878 std::lock_guard<std::mutex> lockWriteBuffer(m_mutexWriteBuffer);
879 if (!m_writeBuffer.empty())
882 if (m_writeQueue.empty())
885 for (
auto i : m_writeQueue)
890 m_isShuttingDown =
true;
891 m_writeBuffer.push_back(boost::asio::buffer(i->data(), i->length()));
892 m_writeBufferQueue.push_back(i);
894 m_writeQueue.clear();
897 auto self(this->shared_from_this());
898 boost::asio::async_write(
901 [
this,
self](boost::system::error_code _ec, std::size_t _bytesTransferred)
908 << _bytesTransferred <<
" bytes)";
910 if (m_isShuttingDown)
919 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
921 m_writeBuffer.clear();
922 m_writeBufferQueue.clear();
927 else if ((boost::asio::error::eof == _ec) || (boost::asio::error::connection_reset == _ec))
930 <<
"Disconnect is detected while on write message: " << _ec.message();
941 <<
"The stop signal is received, aborting current operation and " 942 "closing the connection: " 947 catch (std::exception& ex)
964 bool isCmdAllowedWithoutHandshake(
ECmdType _cmd)
985 boost::asio::ip::tcp::socket m_socket;
989 protocolMessagePtrQueue_t m_writeQueue;
990 protocolMessagePtrQueue_t m_writeQueueBeforeHandShake;
992 std::mutex m_mutexWriteBuffer;
993 protocolMessageBuffer_t m_writeBuffer;
994 protocolMessagePtrQueue_t m_writeBufferQueue;
997 typedef std::map<boost::uuids::uuid, binaryAttachmentInfoPtr_t> binaryAttachmentMap_t;
998 binaryAttachmentMap_t m_binaryAttachmentMap;
999 std::mutex m_binaryAttachmentMutex;
1001 protocolMessagePtrQueue_t m_accumulativeWriteQueue;
1002 deadlineTimerPtr_t m_deadlineTimer;
1004 bool m_isShuttingDown;
bool m_isHandshakeOK
Definition: BaseChannelImpl.h:978
std::shared_ptr< T > connectionPtr_t
Definition: BaseChannelImpl.h:229
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:617
Definition: BaseEventHandlersImpl.h:48
boost::uuids::uuid m_fileId
Unique ID of the file.
Definition: BinaryAttachmentCmd.h:26
EChannelType
Definition: ProtocolDef.h:15
Definition: BaseChannelImpl.h:195
Definition: ProtocolCommands.h:34
void accumulativePushMsg(CProtocolMessage::protocolMessagePtr_t _msg, ECmdType _cmd)
Definition: BaseChannelImpl.h:335
uint32_t crc32(const std::string &_str)
Definition: CRC.h:26
EChannelType m_channelType
Definition: BaseChannelImpl.h:979
DDS_DECLARE_EVENT_HANDLER_CLASS(CChannelEventHandlersImpl) DDS_DECLARE_EVENT_HANDLER_CLASS(CChannelMessageHandlersImpl) protected
Definition: BaseChannelImpl.h:236
void pushBinaryAttachmentCmd(const std::string &_srcFilePath, const std::string &_fileName, uint16_t _cmdSource, uint64_t _protocolHeaderID)
Definition: BaseChannelImpl.h:521
Definition: ChannelEventHandlersImpl.h:26
uint16_t m_srcCommand
Source command which initiated file transport.
Definition: BinaryAttachmentReceivedCmd.h:25
const std::array< std::string, 3 > gChannelTypeName
Definition: ProtocolDef.h:22
uint32_t m_fileSize
File size in bytes.
Definition: BinaryAttachmentStartCmd.h:28
Definition: BinaryAttachmentReceivedCmd.h:15
Definition: CommandAttachmentImpl.h:54
bool started()
Definition: BaseChannelImpl.h:746
bool isHanshakeOK() const
Definition: BaseChannelImpl.h:284
uint32_t m_receivedFileSize
Number of recieved bytes.
Definition: BinaryAttachmentReceivedCmd.h:26
uint32_t m_fileCrc32
File checksum.
Definition: BinaryAttachmentStartCmd.h:29
std::string getLockedSID() const
Definition: UserDefaults.cpp:559
std::shared_ptr< SEmptyCmd > ptr_t
Definition: CommandAttachmentImpl.h:64
Definition: BinaryAttachmentStartCmd.h:18
void accumulativePushMsg(const A &_attachment, uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:409
std::chrono::steady_clock::time_point m_startTime
Definition: BaseChannelImpl.h:213
Definition: ProtocolCommands.h:30
std::string m_sessionID
Definition: BaseChannelImpl.h:980
static CProtocolMessage::protocolMessagePtr_t encode(const SEmptyCmd &, uint64_t _ID)
Definition: CommandAttachmentImpl.h:71
void pushMsg(uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:498
#define LOG(severity)
Definition: Logger.h:34
std::weak_ptr< T > weakConnectionPtr_t
Definition: BaseChannelImpl.h:230
boost::asio::io_context & m_ioContext
Definition: BaseChannelImpl.h:982
Definition: ProtocolMessage.h:76
Definition: SimpleMsgCmd.h:16
Definition: ProtocolCommands.h:35
uint32_t m_size
Size of this piece of binary data.
Definition: BinaryAttachmentCmd.h:28
Definition: BinaryAttachmentCmd.h:18
EChannelType getChannelType() const
Definition: BaseChannelImpl.h:289
void start()
Definition: BaseChannelImpl.h:300
uint32_t m_fileSize
Definition: BaseChannelImpl.h:211
std::vector< unsigned char > BYTEVector_t
An STL vector of bytes.
Definition: def.h:124
Definition: ProtocolDef.h:17
std::string m_requestedFileName
Requested name of the file.
Definition: BinaryAttachmentReceivedCmd.h:24
Miscellaneous functions and helpers are located here.
Definition: AgentConnectionManager.h:13
void processBinaryAttachmentStartCmd(const SSenderInfo &, SCommandAttachmentImpl< cmdBINARY_ATTACHMENT_START >::ptr_t _attachment)
Definition: BaseChannelImpl.h:591
std::string remoteEndIDString()
Definition: BaseChannelImpl.h:751
Definition: ProtocolMessage.h:89
uint32_t m_crc32
CRC checksum of this piece of binary data.
Definition: BinaryAttachmentCmd.h:29
uint32_t m_offset
Offset for this piece of binary data.
Definition: BinaryAttachmentCmd.h:27
static connectionPtr_t makeNew(boost::asio::io_context &_service, uint64_t _protocolHeaderID, Args &(... args))
Definition: BaseChannelImpl.h:275
Definition: BaseChannelImpl.h:219
void pushMsg(const A &_attachment, uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:483
std::string m_fileName
Name of the file.
Definition: BinaryAttachmentStartCmd.h:27
Definition: BaseChannelImpl.h:37
void dequeueMsg()
Definition: BaseChannelImpl.h:325
void accumulativePushMsg(uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:424
SBinaryAttachmentInfo()
Definition: BaseChannelImpl.h:197
Definition: BaseChannelImpl.h:35
uint32_t m_downloadTime
Time spent to download file [microseconds].
Definition: BinaryAttachmentReceivedCmd.h:27
static CUserDefaults & instance(const boost::uuids::uuid &_sid=CUserDefaults::getInitialSID())
Return singleton instance.
Definition: UserDefaults.cpp:37
uint32_t m_fileCrc32
Definition: BaseChannelImpl.h:209
std::vector< weakConnectionPtr_t > weakConnectionPtrVector_t
Definition: BaseChannelImpl.h:232
void pushBinaryAttachmentCmd(const dds::misc::BYTEVector_t &_data, const std::string &_fileName, uint16_t _cmdSource, uint64_t _protocolHeaderID)
Definition: BaseChannelImpl.h:545
void smart_path(_T *_Path)
The function extends any environment variable found in the give path to its value.
Definition: SysHelper.h:95
std::shared_ptr< SBinaryAttachmentInfo > binaryAttachmentInfoPtr_t
Definition: BaseChannelImpl.h:216
void sendYourself(const A &_attachment, uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:505
void sendYourself(uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:515
std::mutex m_mutex
Definition: BaseChannelImpl.h:212
dds::misc::BYTEVector_t m_data
Piece of binary data.
Definition: BinaryAttachmentCmd.h:30
boost::asio::ip::tcp::socket & socket()
Definition: BaseChannelImpl.h:319
boost::uuids::uuid m_fileId
Unique ID of the file.
Definition: BinaryAttachmentStartCmd.h:26
uint32_t m_bytesReceived
Definition: BaseChannelImpl.h:207
uint64_t m_ID
Definition: BaseEventHandlersImpl.h:50
uint16_t m_srcCommand
Source command which initiated file transport.
Definition: BinaryAttachmentStartCmd.h:30
std::string m_fileName
Definition: BaseChannelImpl.h:208
uint64_t getProtocolHeaderID() const
Definition: BaseChannelImpl.h:768
Definition: ProtocolCommands.h:31
std::vector< connectionPtr_t > connectionPtrVector_t
Definition: BaseChannelImpl.h:231
void setChannelType(EChannelType _channelType)
Definition: BaseChannelImpl.h:294
Definition: ChannelMessageHandlersImpl.h:20
dds::misc::BYTEVector_t m_data
Definition: BaseChannelImpl.h:206
uint16_t m_srcCommand
Definition: BaseChannelImpl.h:210
ECmdType
Definition: ProtocolCommands.h:25
Definition: ProtocolCommands.h:28
void stop()
Definition: BaseChannelImpl.h:311
void pushMsg(CProtocolMessage::protocolMessagePtr_t _msg, ECmdType _cmd, uint64_t=0)
Definition: BaseChannelImpl.h:430
uint64_t m_protocolHeaderID
Definition: BaseChannelImpl.h:981
std::shared_ptr< CProtocolMessage > protocolMessagePtr_t
Definition: ProtocolMessage.h:81