6 #ifndef DDS_ServerChannelImpl_h 7 #define DDS_ServerChannelImpl_h 15 namespace protocol_api
18 class CServerChannelImpl :
public CBaseChannelImpl<T>
23 , m_requiredChannelTypes(_requiredChannelTypes)
26 this->
template registerHandler<cmdHANDSHAKE>(
29 if (!processHandshake_channelTypeSupported(
30 static_cast<EChannelType>(_attachment->m_channelType),
true, _sender.
m_ID))
32 if (!processHandshake_versionMatch(_attachment->m_version,
true, _sender.
m_ID))
34 if (!processHandshake_sessionIDMatch(_attachment->m_sSID,
true, _sender.
m_ID))
37 this->m_protocolHeaderID = _sender.
m_ID;
38 this->m_isHandshakeOK =
true;
39 this->m_channelType = static_cast<EChannelType>(_attachment->m_channelType);
42 this->template pushMsg<cmdUNKNOWN>();
46 <<
"] has successfully connected.";
48 this->
template pushMsg<cmdREPLY_HANDSHAKE_OK>(_sender.
m_ID);
89 bool processHandshake_channelTypeSupported(
EChannelType _channelType,
bool _lobbyLeader, uint64_t _senderID)
92 bool isSupportedChnl(
false);
93 for (
const auto& v : m_requiredChannelTypes)
95 isSupportedChnl = (_channelType == v);
100 if (!isSupportedChnl)
102 handshakeFailed(
"Unsupported channel type", _lobbyLeader, _senderID);
108 bool processHandshake_versionMatch(uint16_t _version,
bool _lobbyLeader, uint64_t _senderID)
111 if (_version != DDS_PROTOCOL_VERSION)
113 std::stringstream ss;
114 ss <<
"Incompatible protocol version. Server: " << DDS_PROTOCOL_VERSION <<
" Client: " << _version;
115 handshakeFailed(ss.str(), _lobbyLeader, _senderID);
121 bool processHandshake_sessionIDMatch(
const std::string& _sessionID,
bool _lobbyLeader, uint64_t _senderID)
126 handshakeFailed(
"Incompatible Session ID", _lobbyLeader, _senderID);
132 void handshakeFailed(
const std::string& _reason,
bool , uint64_t _senderID)
138 this->
template pushMsg<cmdREPLY_HANDSHAKE_ERR>(SSimpleMsgCmd(_reason,
dds::misc::fatal), _senderID);
bool m_isHandshakeOK
Definition: BaseChannelImpl.h:978
Definition: BaseEventHandlersImpl.h:48
EChannelType
Definition: ProtocolDef.h:15
EChannelType m_channelType
Definition: BaseChannelImpl.h:979
std::shared_ptr< SEmptyCmd > ptr_t
Definition: CommandAttachmentImpl.h:64
std::string m_sessionID
Definition: BaseChannelImpl.h:980
#define LOG(severity)
Definition: Logger.h:34
Miscellaneous functions and helpers are located here.
Definition: AgentConnectionManager.h:13
std::string remoteEndIDString()
Definition: BaseChannelImpl.h:751
Definition: BaseChannelImpl.h:219
Definition: BaseChannelImpl.h:37
std::vector< EChannelType > channelTypeVector_t
Definition: ProtocolDef.h:21
boost::asio::ip::tcp::socket & socket()
Definition: BaseChannelImpl.h:319
uint64_t m_ID
Definition: BaseEventHandlersImpl.h:50