DDS  ver. 2.0
GenericChannel.h
Go to the documentation of this file.
1 // Copyright 2014 GSI, Inc. All rights reserved.
2 //
3 //
4 //
5 #ifndef __DDS__GenericChannel__
6 #define __DDS__GenericChannel__
7 // DDS
8 #include "ClientChannelImpl.h"
9 #include "Options.h"
10 
11 namespace dds
12 {
13  namespace agent_cmd_cmd
14  {
15  class CGenericChannel : public protocol_api::CClientChannelImpl<CGenericChannel>
16  {
17  CGenericChannel(boost::asio::io_service& _service, uint64_t _protocolHeaderID = 0)
18  : CClientChannelImpl<CGenericChannel>(_service, protocol_api::EChannelType::UI, _protocolHeaderID)
19  {
20  registerHandler<protocol_api::EChannelEvents::OnRemoteEndDissconnected>(
21  [this](const protocol_api::SSenderInfo& _sender) {
23  << "The DDS commander [" << this->socket().remote_endpoint().address().to_string()
24  << "] has closed the connection.";
25  });
26 
27  registerHandler<protocol_api::EChannelEvents::OnHandshakeOK>(
28  [this](const protocol_api::SSenderInfo& _sender) {
29  switch (m_options.m_agentCmd)
30  {
32  LOG(MiscCommon::log_stdout) << "Requesting log files from agents...";
33  pushMsg<protocol_api::cmdGET_LOG>();
34  break;
36  {
37  LOG(MiscCommon::log_stdout) << "Sending key update command...";
39  cmd.m_sKey = m_options.m_sUpdKey_key;
40  cmd.m_sValue = m_options.m_sUpdKey_value;
41  pushMsg<protocol_api::cmdUPDATE_KEY>(cmd);
42  }
43  break;
44  default:
45  LOG(MiscCommon::log_stderr) << "Uknown command.";
46  stop();
47  }
48  });
49  }
50 
52 
53  public:
58  END_MSG_MAP()
59 
60  void setOptions(const SOptions& _options)
61  {
62  m_options = _options;
63  }
64 
65  private:
66  // Message Handlers
68  const protocol_api::SSenderInfo& _sender);
69  bool on_cmdSHUTDOWN(
71  const protocol_api::SSenderInfo& _sender);
72  bool on_cmdPROGRESS(
74  const protocol_api::SSenderInfo& _sender);
75 
76  private:
77  SOptions m_options;
78  };
79  }
80 }
81 #endif /* defined(__DDS__GenericChannel__) */
Definition: def.h:156
Definition: def.h:154
BEGIN_MSG_MAP(CGenericChannel) MESSAGE_HANDLER(dds MESSAGE_HANDLER(dds::protocol_api::cmdSHUTDOWN, on_cmdSHUTDOWN) MESSAGE_HANDLER(dds
Definition: GenericChannel.h:56
Definition: BaseEventHandlersImpl.h:48
Definition: UpdateKeyCmd.h:14
#define REGISTER_DEFAULT_REMOTE_ID_STRING
Definition: BaseChannelImpl.h:171
dds-agent-cmd&#39;s container of options
Definition: dds-agent-cmd/src/Options.h:57
Definition: ProtocolDef.h:19
std::shared_ptr< SEmptyCmd > ptr_t
Definition: CommandAttachmentImpl.h:66
Definition: ProtocolCommands.h:30
#define LOG(severity)
Definition: Logger.h:54
Definition: ProtocolCommands.h:59
std::string m_sValue
Definition: UpdateKeyCmd.h:32
Definition: ProtocolCommands.h:33
std::string m_sUpdKey_value
Definition: dds-agent-cmd/src/Options.h:70
#define END_MSG_MAP()
Definition: BaseChannelImpl.h:134
Definition: dds-agent/src/AgentConnectionManager.h:18
Definition: GenericChannel.h:15
Definition: BaseChannelImpl.h:41
std::string m_sKey
Definition: UpdateKeyCmd.h:31
EAgentCmdType m_agentCmd
Definition: dds-agent-cmd/src/Options.h:68
boost::asio::ip::tcp::socket & socket()
Definition: BaseChannelImpl.h:304
Definition: def.h:150
std::string m_sUpdKey_key
Definition: dds-agent-cmd/src/Options.h:69
#define BEGIN_MSG_MAP(theClass)
Definition: BaseChannelImpl.h:49
void stop()
Definition: BaseChannelImpl.h:296