blob: f95362cf5175844de8c5573b926771d4a9ac2a44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#ifndef WANDA_CONTROL_INTERFACE_HPP
#define WANDA_CONTROL_INTERFACE_HPP
#include "control_connection.hpp"
#include "keyed.hpp"
#include <boost/asio.hpp>
#include <boost/system/error_code.hpp>
#include <filesystem>
#include <istream>
#include <memory>
#include <set>
#include <string>
namespace wanda
{
struct socket_deleter
{
~socket_deleter();
std::filesystem::path path;
};
struct control_interface : control_connection::listener, keyed<control_interface>, std::enable_shared_from_this<control_interface>
{
using protocol = boost::asio::local::stream_protocol;
using pointer = std::shared_ptr<control_interface>;
control_interface(key, boost::asio::io_service &service, protocol::endpoint endpoint);
boost::system::error_code start();
void on_received(control_connection::pointer connection, std::string message) override;
void on_close(control_connection::pointer) override;
private:
void perform_accept();
friend pointer make_interface(boost::asio::io_service &service, std::filesystem::path file);
boost::asio::io_service &m_service;
protocol::endpoint m_endpoint;
protocol::socket m_socket;
protocol::acceptor m_acceptor;
socket_deleter m_deleter{m_endpoint.path()};
std::set<control_connection::pointer> m_connections;
};
control_interface::pointer make_interface(boost::asio::io_service &service, std::filesystem::path file);
} // namespace wanda
#endif
|