Kea  1.5.0
client_connection.h
Go to the documentation of this file.
1 // Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef CLIENT_CONNECTION_H
8 #define CLIENT_CONNECTION_H
9 
10 #include <asiolink/io_service.h>
11 #include <cc/json_feed.h>
12 #include <boost/shared_ptr.hpp>
13 #include <functional>
14 
15 namespace isc {
16 namespace config {
17 
18 class ClientConnectionImpl;
19 
71 public:
72 
75 
76 
78  struct SocketPath {
79  explicit SocketPath(const std::string& socket_path)
80  : socket_path_(socket_path) { }
81 
82  std::string socket_path_;
83  };
84 
86  struct ControlCommand {
87  explicit ControlCommand(const std::string control_command)
88  : control_command_(control_command) { }
89 
90  std::string control_command_;
91  };
92 
94  struct Timeout {
95  explicit Timeout(const long timeout)
96  : timeout_(timeout) { }
97 
98  long timeout_;
99  };
100 
102 
105  typedef std::function<void(const boost::system::error_code& ec,
106  const ConstJSONFeedPtr& feed)> Handler;
107 
111  explicit ClientConnection(asiolink::IOService& io_service);
112 
143  void start(const SocketPath& socket_path, const ControlCommand& command,
144  Handler handler, const Timeout& timeout = Timeout(5000));
145 
146 private:
147 
149  boost::shared_ptr<ClientConnectionImpl> impl_;
150 
151 };
152 
154 typedef boost::shared_ptr<ClientConnection> ClientConnectionPtr;
155 
156 } // end of namespace config
157 } // end of namespace isc
158 
159 #endif // CLIENT_CONNECTION_H
isc::config::ClientConnection::Timeout
Encapsulates timeout value.
Definition: client_connection.h:94
isc::config::ClientConnectionPtr
boost::shared_ptr< ClientConnection > ClientConnectionPtr
Type of the pointer to the ClientConnection object.
Definition: client_connection.h:154
isc::config::ClientConnection::SocketPath::socket_path_
std::string socket_path_
Definition: client_connection.h:82
isc::config::ClientConnection::Handler
std::function< void(const boost::system::error_code &ec, const ConstJSONFeedPtr &feed)> Handler
Type of the callback invoked when the communication with the server is complete or an error has occur...
Definition: client_connection.h:106
isc::config::ClientConnection::ControlCommand::control_command_
std::string control_command_
Definition: client_connection.h:90
isc::config::ClientConnection::ClientConnection
ClientConnection(asiolink::IOService &io_service)
Constructor.
Definition: client_connection.cc:271
io_service.h
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::config::ClientConnection::ControlCommand
Encapsulates control command.
Definition: client_connection.h:86
isc::config::ClientConnection::SocketPath::SocketPath
SocketPath(const std::string &socket_path)
Definition: client_connection.h:79
isc::config::ClientConnection::Timeout::Timeout
Timeout(const long timeout)
Definition: client_connection.h:95
json_feed.h
isc::config::ConstJSONFeedPtr
boost::shared_ptr< const JSONFeed > ConstJSONFeedPtr
Pointer to the const JSONFeed.
Definition: json_feed.h:27
isc::config::ClientConnection::SocketPath
Encapsulates socket path.
Definition: client_connection.h:78
isc::config::ClientConnection::Timeout::timeout_
long timeout_
Definition: client_connection.h:98
isc::config::ClientConnection
Represents client side connection over the unix domain socket.
Definition: client_connection.h:70
isc::config::ClientConnection::ControlCommand::ControlCommand
ControlCommand(const std::string control_command)
Definition: client_connection.h:87
isc::config::ClientConnection::start
void start(const SocketPath &socket_path, const ControlCommand &command, Handler handler, const Timeout &timeout=Timeout(5000))
Starts asynchronous transaction with a remote endpoint.
Definition: client_connection.cc:276