5 #ifndef __DDS__BaseChannelImpl__ 6 #define __DDS__BaseChannelImpl__ 14 #include <boost/asio.hpp> 15 #include <boost/filesystem.hpp> 16 #include <boost/noncopyable.hpp> 18 #pragma clang diagnostic push 19 #pragma clang diagnostic ignored "-Wdeprecated-register" 20 #include <boost/uuid/uuid.hpp> 21 #include <boost/uuid/uuid_generators.hpp> 22 #include <boost/uuid/uuid_io.hpp> 23 #pragma clang diagnostic pop 33 namespace fs = boost::filesystem;
37 namespace protocol_api
48 #define BEGIN_MSG_MAP(theClass) \ 50 friend protocol_api::CBaseChannelImpl<theClass>; \ 51 friend protocol_api::CClientChannelImpl<theClass>; \ 52 friend protocol_api::CServerChannelImpl<theClass>; \ 53 void processMessage(protocol_api::CProtocolMessage::protocolMessagePtr_t _currentMsg) \ 55 using namespace dds; \ 56 using namespace dds::protocol_api; \ 57 CMonitoringThread::instance().updateIdle(); \ 58 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 MESSAGE_HANDLER_DISPATCH(msg) \ 138 typedef typename SCommandAttachmentImpl<msg>::ptr_t attahcmentPtr_t; \ 139 attahcmentPtr_t attachmentPtr = SCommandAttachmentImpl<msg>::decode(_currentMsg); \ 140 LOG(MiscCommon::debug) << "Dispatching " << g_cmdToString[msg] << " received from " << remoteEndIDString(); \ 141 if (!handlerExists(msg)) \ 143 LOG(MiscCommon::error) << "The received message can't be dispatched, it has no registered handler: " \ 144 << _currentMsg->toString(); \ 148 dispatchHandlers<>(msg, sender, attachmentPtr); \ 153 #define END_MSG_MAP() \ 155 LOG(MiscCommon::error) << "The received message doesn't have a handler: " << _currentMsg->toString(); \ 158 catch (std::exception & _e) \ 160 LOG(MiscCommon::error) << "Channel processMessage (" << _currentMsg->toString() << "): " << _e.what(); \ 165 #define RAW_MESSAGE_HANDLER(theClass, func) \ 166 BEGIN_MSG_MAP(theClass) \ 170 processed = func(_currentMsg); \ 173 if (!handlerExists(ECmdType::cmdRAW_MSG)) \ 175 LOG(MiscCommon::error) << "The received message was not processed and has no registered handler: " \ 176 << _currentMsg->toString(); \ 180 dispatchHandlers(ECmdType::cmdRAW_MSG, sender, _currentMsg); \ 184 catch (std::exception & _e) \ 186 LOG(MiscCommon::error) << "Channel processMessage: " << _e.what(); \ 190 #define REGISTER_DEFAULT_REMOTE_ID_STRING \ 191 std::string _remoteEndIDString() \ 193 return "DDS Server"; \ 198 namespace protocol_api
227 public std::enable_shared_from_this<T>,
230 typedef std::deque<CProtocolMessage::protocolMessagePtr_t> protocolMessagePtrQueue_t;
231 typedef std::vector<boost::asio::mutable_buffer> protocolMessageBuffer_t;
232 typedef std::shared_ptr<boost::asio::deadline_timer> deadlineTimerPtr_t;
257 , m_binaryAttachmentMap()
258 , m_binaryAttachmentMutex()
260 std::make_shared<boost::asio::deadline_timer>(_service, boost::posix_time::milliseconds(1000)))
261 , m_isShuttingDown(false)
268 catch (std::runtime_error& _error)
281 template <
class... Args>
283 uint64_t _protocolHeaderID,
286 connectionPtr_t newObject(
new T(_service, _protocolHeaderID, args...));
314 ::fcntl(m_socket.native_handle(), F_SETFD, FD_CLOEXEC);
331 template <ECmdType _cmd>
334 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
335 m_writeQueue.erase(std::remove_if(std::begin(m_writeQueue),
336 std::end(m_writeQueue),
338 return (_msg->header().m_cmd == _cmd);
340 std::end(m_writeQueue));
345 static const size_t maxAccumulativeWriteQueueSize = 10000;
348 bool copyMessages =
false;
350 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
352 m_deadlineTimer->cancel();
355 m_accumulativeWriteQueue.push_back(_msg);
357 copyMessages = m_accumulativeWriteQueue.size() > maxAccumulativeWriteQueueSize;
361 <<
"copy accumulated queue to write queue " 362 "m_accumulativeWriteQueue.size=" 363 << m_accumulativeWriteQueue.size() <<
" m_writeQueue.size=" << m_writeQueue.size();
366 std::copy(m_accumulativeWriteQueue.begin(),
367 m_accumulativeWriteQueue.end(),
368 back_inserter((
m_isHandshakeOK) ? m_writeQueue : m_writeQueueBeforeHandShake));
369 m_accumulativeWriteQueue.clear();
372 auto self(this->shared_from_this());
373 m_deadlineTimer->async_wait([
this,
self](
const boost::system::error_code& error) {
376 bool copyMessages =
false;
378 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
379 copyMessages = !m_accumulativeWriteQueue.empty();
384 <<
"deadline_timer called: copy accumulated queue to write queue " 385 "m_accumulativeWriteQueue.size=" 386 << m_accumulativeWriteQueue.size()
387 <<
" m_writeQueue.size=" << m_writeQueue.size();
388 std::copy(m_accumulativeWriteQueue.begin(),
389 m_accumulativeWriteQueue.end(),
391 : m_writeQueueBeforeHandShake));
392 m_accumulativeWriteQueue.clear();
396 pushMsg<cmdUNKNOWN>();
401 <<
" WriteQueueBeforeHandShake = " << m_writeQueueBeforeHandShake.size()
402 <<
" accumulativeWriteQueue size = " << m_accumulativeWriteQueue.size()
403 <<
" msg = " << _msg->toString();
406 pushMsg<cmdUNKNOWN>();
408 catch (std::exception& ex)
414 template <ECmdType _cmd,
class A>
423 catch (std::exception& ex)
429 template <ECmdType _cmd>
433 accumulativePushMsg<_cmd>(cmd, _protocolHeaderID);
440 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
443 if (isCmdAllowedWithoutHandshake(_cmd))
444 m_writeQueue.push_back(_msg);
446 m_writeQueueBeforeHandShake.push_back(_msg);
451 if (!m_writeQueueBeforeHandShake.empty())
453 std::copy(m_writeQueueBeforeHandShake.begin(),
454 m_writeQueueBeforeHandShake.end(),
455 back_inserter(m_writeQueue));
456 m_writeQueueBeforeHandShake.clear();
461 m_writeQueue.push_back(_msg);
465 <<
" WriteQueueBeforeHandShake = " << m_writeQueueBeforeHandShake.size();
467 catch (std::exception& ex)
473 auto self(this->shared_from_this());
479 catch (std::exception& ex)
486 template <ECmdType _cmd,
class A>
487 void pushMsg(
const A& _attachment, uint64_t _protocolHeaderID = 0)
493 pushMsg(msg, _cmd, _protocolHeaderID);
495 catch (std::exception& ex)
501 template <ECmdType _cmd>
505 pushMsg<_cmd>(cmd, adjustProtocolHeaderID(_protocolHeaderID));
508 template <ECmdType _cmd,
class A>
509 void sendYourself(
const A& _attachment, uint64_t _protocolHeaderID = 0)
514 T* pThis = static_cast<T*>(
this);
515 pThis->processMessage(msg);
518 template <ECmdType _cmd>
522 sendYourself<_cmd>(cmd, adjustProtocolHeaderID(_protocolHeaderID));
526 const std::string& _fileName,
528 uint64_t _protocolHeaderID)
532 std::string srcFilePath(_srcFilePath);
536 std::ifstream f(srcFilePath);
537 if (!f.is_open() || !f.good())
539 throw std::runtime_error(
"Could not open the source file: " + srcFilePath);
541 f.seekg(0, std::ios::end);
542 data.reserve(f.tellg());
543 f.seekg(0, std::ios::beg);
544 data.assign((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
550 const std::string& _fileName,
552 uint64_t _protocolHeaderID)
554 static const int maxCommandSize = 65536;
555 int nofParts = (_data.size() % maxCommandSize == 0) ? (_data.size() / maxCommandSize)
556 : (_data.size() / maxCommandSize + 1);
557 boost::crc_32_type fileCrc32;
558 fileCrc32.process_bytes(&_data[0], _data.size());
560 boost::uuids::uuid fileId = boost::uuids::random_generator()();
569 pushMsg<cmdBINARY_ATTACHMENT_START>(start_cmd, _protocolHeaderID);
571 for (
size_t i = 0; i < nofParts; ++i)
576 size_t offset = i * maxCommandSize;
577 size_t size = (i != (nofParts - 1)) ? maxCommandSize : (_data.size() - offset);
579 auto iter_begin = _data.begin() + offset;
580 auto iter_end = iter_begin + size;
581 std::copy(iter_begin, iter_end, std::back_inserter(cmd.
m_data));
586 boost::crc_32_type
crc32;
587 crc32.process_bytes(&(*iter_begin), size);
591 pushMsg<cmdBINARY_ATTACHMENT>(cmd, _protocolHeaderID);
598 boost::uuids::uuid fileId = _attachment->m_fileId;
602 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
604 binaryAttachmentMap_t::iterator iter_info = m_binaryAttachmentMap.find(fileId);
605 bool exists = iter_info != m_binaryAttachmentMap.end();
609 m_binaryAttachmentMap[fileId] = std::make_shared<SBinaryAttachmentInfo>();
610 iter_info = m_binaryAttachmentMap.find(fileId);
611 iter_info->second->m_startTime = std::chrono::steady_clock::now();
612 iter_info->second->m_fileName = _attachment->m_fileName;
613 iter_info->second->m_fileSize = _attachment->m_fileSize;
614 iter_info->second->m_fileCrc32 = _attachment->m_fileCrc32;
615 iter_info->second->m_srcCommand = _attachment->m_srcCommand;
616 iter_info->second->m_data.resize(_attachment->m_fileSize);
624 boost::uuids::uuid fileId = _attachment->m_fileId;
626 binaryAttachmentMap_t::iterator iter_info;
630 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
632 iter_info = m_binaryAttachmentMap.find(fileId);
633 bool exists = iter_info != m_binaryAttachmentMap.end();
638 <<
"Received binary attachment [" << fileId <<
"] which does not exist. Skip this message.";
641 info = iter_info->second;
644 boost::crc_32_type
crc32;
645 crc32.process_bytes(&_attachment->m_data[0], _attachment->m_data.size());
647 if (
crc32.checksum() != _attachment->m_crc32)
651 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
653 m_binaryAttachmentMap.erase(iter_info);
655 std::stringstream ss;
656 ss <<
"Received binary attachment [" << fileId <<
"] has wrong CRC32 checksum: " <<
crc32.checksum()
657 <<
" instead of " << _attachment->m_crc32 <<
"offset=" << _attachment->m_offset
658 <<
" size=" << _attachment->m_size;
665 bool allBytesReceived =
false;
668 std::lock_guard<std::mutex> lock(info->m_mutex);
670 info->m_bytesReceived += _attachment->m_size;
672 std::copy(_attachment->m_data.begin(),
673 _attachment->m_data.end(),
674 info->m_data.begin() + _attachment->m_offset);
676 allBytesReceived = info->m_bytesReceived == info->m_fileSize;
677 if (allBytesReceived)
680 boost::crc_32_type
crc32;
681 crc32.process_bytes(&info->m_data[0], info->m_data.size());
683 if (
crc32.checksum() != info->m_fileCrc32)
687 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
689 m_binaryAttachmentMap.erase(iter_info);
691 std::stringstream ss;
692 ss <<
"Received binary file [" << fileId
693 <<
"] has wrong CRC32 checksum: " <<
crc32.checksum() <<
" instead of " 694 << _attachment->m_crc32;
702 const std::string filePath(dir.append(to_string(fileId)).string());
703 std::ofstream f(filePath.c_str());
704 if (!f.is_open() || !f.good())
708 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
710 m_binaryAttachmentMap.erase(iter_info);
712 std::stringstream ss;
713 ss <<
"Could not open file: " << filePath;
720 for (
const auto& v : info->m_data)
726 std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
727 std::chrono::microseconds downloadTime =
728 std::chrono::duration_cast<std::chrono::microseconds>(now - info->m_startTime);
737 sendYourself<cmdBINARY_ATTACHMENT_RECEIVED>(reply_cmd, _sender.
m_ID);
741 if (allBytesReceived)
744 std::lock_guard<std::mutex> lock(m_binaryAttachmentMutex);
746 m_binaryAttachmentMap.erase(iter_info);
760 T* pThis = static_cast<T*>(
this);
761 std::stringstream ss;
762 ss << pThis->_remoteEndIDString() <<
" [" <<
socket().remote_endpoint().address().to_string()
768 return std::string();
778 uint64_t adjustProtocolHeaderID(uint64_t _protocolHeaderID)
const 785 auto self(this->shared_from_this());
786 boost::asio::async_read(
789 [
this,
self](boost::system::error_code ec, std::size_t length) {
795 if (!ec && m_currentMsg->decode_header())
800 else if ((boost::asio::error::eof == ec) || (boost::asio::error::connection_reset == ec))
803 <<
"Disconnect is detected while on read msg header: " << ec.message();
812 "closing the connection: " 822 if (m_currentMsg->body_length() == 0)
825 <<
": no attachment: " << m_currentMsg->toString();
827 T* pThis = static_cast<T*>(
this);
828 pThis->processMessage(m_currentMsg);
834 m_currentMsg = std::make_shared<CProtocolMessage>();
839 auto self(this->shared_from_this());
840 boost::asio::async_read(
842 boost::asio::buffer(m_currentMsg->body(), m_currentMsg->body_length()),
843 [
this,
self](boost::system::error_code ec, std::size_t length) {
847 << length <<
" bytes): " << m_currentMsg->toString();
850 T* pThis = static_cast<T*>(
this);
851 pThis->processMessage(m_currentMsg);
857 m_currentMsg = std::make_shared<CProtocolMessage>();
860 else if ((boost::asio::error::eof == ec) || (boost::asio::error::connection_reset == ec))
872 "closing the connection: " 886 std::lock_guard<std::mutex> lockWriteBuffer(m_mutexWriteBuffer);
887 if (!m_writeBuffer.empty())
890 if (m_writeQueue.empty())
893 for (
auto i : m_writeQueue)
898 m_isShuttingDown =
true;
899 m_writeBuffer.push_back(boost::asio::buffer(i->data(), i->length()));
900 m_writeBufferQueue.push_back(i);
902 m_writeQueue.clear();
905 auto self(this->shared_from_this());
906 boost::asio::async_write(
909 [
this,
self](boost::system::error_code _ec, std::size_t _bytesTransferred) {
915 << _bytesTransferred <<
" bytes)";
917 if (m_isShuttingDown)
926 std::lock_guard<std::mutex> lock(m_mutexWriteBuffer);
931 m_writeBuffer.clear();
932 m_writeBufferQueue.clear();
937 else if ((boost::asio::error::eof == _ec) || (boost::asio::error::connection_reset == _ec))
940 <<
"Disconnect is detected while on write message: " << _ec.message();
951 <<
"The stop signal is received, aborting current operation and " 952 "closing the connection: " 957 catch (std::exception& ex)
974 bool isCmdAllowedWithoutHandshake(
ECmdType _cmd)
995 boost::asio::ip::tcp::socket m_socket;
999 protocolMessagePtrQueue_t m_writeQueue;
1000 protocolMessagePtrQueue_t m_writeQueueBeforeHandShake;
1002 std::mutex m_mutexWriteBuffer;
1003 protocolMessageBuffer_t m_writeBuffer;
1004 protocolMessagePtrQueue_t m_writeBufferQueue;
1007 typedef std::map<boost::uuids::uuid, binaryAttachmentInfoPtr_t> binaryAttachmentMap_t;
1008 binaryAttachmentMap_t m_binaryAttachmentMap;
1009 std::mutex m_binaryAttachmentMutex;
1011 protocolMessagePtrQueue_t m_accumulativeWriteQueue;
1012 deadlineTimerPtr_t m_deadlineTimer;
1014 bool m_isShuttingDown;
bool m_isHandshakeOK
Definition: BaseChannelImpl.h:988
std::shared_ptr< T > connectionPtr_t
Definition: BaseChannelImpl.h:235
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:621
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:200
Definition: ProtocolCommands.h:34
void accumulativePushMsg(CProtocolMessage::protocolMessagePtr_t _msg, ECmdType _cmd)
Definition: BaseChannelImpl.h:343
void logReadMessage(CProtocolMessage::protocolMessagePtr_t _message)
Definition: StatImpl.cpp:189
EChannelType m_channelType
Definition: BaseChannelImpl.h:989
DDS_DECLARE_EVENT_HANDLER_CLASS(CChannelEventHandlersImpl) DDS_DECLARE_EVENT_HANDLER_CLASS(CChannelMessageHandlersImpl) protected
Definition: BaseChannelImpl.h:242
void pushBinaryAttachmentCmd(const std::string &_srcFilePath, const std::string &_fileName, uint16_t _cmdSource, uint64_t _protocolHeaderID)
Definition: BaseChannelImpl.h:525
Definition: ChannelEventHandlersImpl.h:29
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:31
Definition: BinaryAttachmentReceivedCmd.h:15
Definition: CommandAttachmentImpl.h:54
bool started()
Definition: BaseChannelImpl.h:750
bool isHanshakeOK() const
Definition: BaseChannelImpl.h:291
uint32_t m_receivedFileSize
Number of recieved bytes.
Definition: BinaryAttachmentReceivedCmd.h:26
uint32_t m_fileCrc32
File checksum.
Definition: BinaryAttachmentStartCmd.h:32
std::string getLockedSID() const
Definition: UserDefaults.cpp:491
std::shared_ptr< SEmptyCmd > ptr_t
Definition: CommandAttachmentImpl.h:64
void pushMsg(CProtocolMessage::protocolMessagePtr_t _msg, ECmdType _cmd, uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:436
Definition: BinaryAttachmentStartCmd.h:21
void accumulativePushMsg(const A &_attachment, uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:415
std::chrono::steady_clock::time_point m_startTime
Definition: BaseChannelImpl.h:218
Definition: ProtocolCommands.h:30
std::string m_sessionID
Definition: BaseChannelImpl.h:990
static CProtocolMessage::protocolMessagePtr_t encode(const SEmptyCmd &, uint64_t _ID)
Definition: CommandAttachmentImpl.h:71
MiscCommon::BYTEVector_t m_data
Definition: BaseChannelImpl.h:211
void pushMsg(uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:502
#define LOG(severity)
Definition: Logger.h:56
std::weak_ptr< T > weakConnectionPtr_t
Definition: BaseChannelImpl.h:236
boost::asio::io_context & m_ioContext
Definition: BaseChannelImpl.h:992
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:31
Definition: BinaryAttachmentCmd.h:21
EChannelType getChannelType() const
Definition: BaseChannelImpl.h:296
void start()
Definition: BaseChannelImpl.h:307
uint32_t m_fileSize
Definition: BaseChannelImpl.h:216
Definition: ProtocolDef.h:17
std::string m_requestedFileName
Requested name of the file.
Definition: BinaryAttachmentReceivedCmd.h:24
Definition: AgentConnectionManager.h:13
std::string remoteEndIDString()
Definition: BaseChannelImpl.h:755
Definition: ProtocolMessage.h:89
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
static connectionPtr_t makeNew(boost::asio::io_context &_service, uint64_t _protocolHeaderID, Args &(... args))
Definition: BaseChannelImpl.h:282
Definition: BaseChannelImpl.h:224
void pushMsg(const A &_attachment, uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:487
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:595
Definition: BaseChannelImpl.h:42
void dequeueMsg()
Definition: BaseChannelImpl.h:332
void accumulativePushMsg(uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:430
SBinaryAttachmentInfo()
Definition: BaseChannelImpl.h:202
Definition: BaseChannelImpl.h:40
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:36
uint32_t m_fileCrc32
Definition: BaseChannelImpl.h:214
void pushBinaryAttachmentCmd(const MiscCommon::BYTEVector_t &_data, const std::string &_fileName, uint16_t _cmdSource, uint64_t _protocolHeaderID)
Definition: BaseChannelImpl.h:549
std::vector< weakConnectionPtr_t > weakConnectionPtrVector_t
Definition: BaseChannelImpl.h:238
void smart_path(_T *_Path)
The function extends any environment variable found in the give path to its value.
Definition: SysHelper.h:95
Definition: StatImpl.h:110
std::shared_ptr< SBinaryAttachmentInfo > binaryAttachmentInfoPtr_t
Definition: BaseChannelImpl.h:221
void sendYourself(const A &_attachment, uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:509
void sendYourself(uint64_t _protocolHeaderID=0)
Definition: BaseChannelImpl.h:519
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:217
uint32_t crc32(const std::string &_str)
Definition: CRC.h:26
boost::asio::ip::tcp::socket & socket()
Definition: BaseChannelImpl.h:326
boost::uuids::uuid m_fileId
Unique ID of the file.
Definition: BinaryAttachmentStartCmd.h:29
uint32_t m_bytesReceived
Definition: BaseChannelImpl.h:212
uint64_t m_ID
Definition: BaseEventHandlersImpl.h:50
uint16_t m_srcCommand
Source command which initiated file transport.
Definition: BinaryAttachmentStartCmd.h:33
std::string m_fileName
Definition: BaseChannelImpl.h:213
uint64_t getProtocolHeaderID() const
Definition: BaseChannelImpl.h:772
void logWriteMessages(const protocolMessagePtrQueue_t &_messageQueue)
Definition: StatImpl.cpp:205
Definition: ProtocolCommands.h:31
std::vector< connectionPtr_t > connectionPtrVector_t
Definition: BaseChannelImpl.h:237
void setChannelType(EChannelType _channelType)
Definition: BaseChannelImpl.h:301
Definition: ChannelMessageHandlersImpl.h:20
uint16_t m_srcCommand
Definition: BaseChannelImpl.h:215
ECmdType
Definition: ProtocolCommands.h:25
Definition: ProtocolCommands.h:28
void stop()
Definition: BaseChannelImpl.h:318
uint64_t m_protocolHeaderID
Definition: BaseChannelImpl.h:991
std::shared_ptr< CProtocolMessage > protocolMessagePtr_t
Definition: ProtocolMessage.h:81