-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathserver.h
37 lines (30 loc) · 917 Bytes
/
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
#ifndef KCPTUN_SERVER_H
#define KCPTUN_SERVER_H
#include "config.h"
#include "sess.h"
class smux;
class smux_sess;
using AcceptHandler = std::function<void(std::shared_ptr<smux_sess>)>;
class Server final : public std::enable_shared_from_this<Server>,
public AsyncInOutputer,
public kvar_,
public Destroy {
public:
Server(asio::io_service &io_service, OutputHandler handler);
~Server() override;
void run(AcceptHandler handler, uint32_t convid);
void async_input(char *buf, std::size_t len, Handler handler) override;
private:
void do_sess_receive();
void call_this_on_destroy() override;
private:
char sbuf_[2048];
asio::io_service &service_;
std::shared_ptr<Session> sess_;
std::shared_ptr<smux> smux_;
OutputHandler in;
OutputHandler out;
OutputHandler in2;
OutputHandler out2;
};
#endif