-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwsd_server.h
53 lines (41 loc) · 1.32 KB
/
wsd_server.h
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
// Copyright (c) 2022, Eugene Gershnik
// SPDX-License-Identifier: BSD-3-Clause
#ifndef HEADER_WSD_SERVER_H_INCLUDED
#define HEADER_WSD_SERVER_H_INCLUDED
#include "udp_server.h"
#include "http_server.h"
class WsdServer : public ref_counted<WsdServer> {
friend ref_counted<WsdServer>;
public:
enum State {
NotStarted,
Running,
Stopped
};
public:
virtual void start() = 0;
virtual void stop(bool graceful) = 0;
auto state() const -> State {
return m_state;
}
auto interface() const -> const NetworkInterface & {
return m_interface;
}
protected:
WsdServer(const NetworkInterface & iface): m_interface(iface) {
}
virtual ~WsdServer() noexcept {
}
protected:
const NetworkInterface m_interface;
State m_state = NotStarted;
};
using WsdServerFactoryT = auto (asio::io_context & ctxt,
const refcnt_ptr<Config> & config,
HttpServerFactory httpFactory,
UdpServerFactory udpFactory,
const NetworkInterface & iface,
const ip::address & addr) -> refcnt_ptr<WsdServer>;
using WsdServerFactory = std::function<WsdServerFactoryT>;
WsdServerFactoryT createWsdServer;
#endif