Kea  1.9.9-git
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
boost::shared_ptr< ClientConnection > ClientConnectionPtr
Type of the pointer to the ClientConnection object.
Represents client side connection over the unix domain socket.
SocketPath(const std::string &socket_path)
Defines the logger used by the top-level component of kea-dhcp-ddns.
boost::shared_ptr< const JSONFeed > ConstJSONFeedPtr
Pointer to the const JSONFeed.
Definition: json_feed.h:27
ControlCommand(const std::string control_command)
ClientConnection(asiolink::IOService &io_service)
Constructor.
Encapsulates timeout value.
void start(const SocketPath &socket_path, const ControlCommand &command, Handler handler, const Timeout &timeout=Timeout(5000))
Starts asynchronous transaction with a remote endpoint.
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...