-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
53 lines (35 loc) · 1.13 KB
/
main.cpp
File metadata and controls
53 lines (35 loc) · 1.13 KB
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
#include <simpleNW.hpp>
#include <iostream>
#include <memory>
#include <boost/asio.hpp>
class Echoing_Handler : public Handler {
void OnConnectionOpen(std::shared_ptr<Connection> connection) override {
//std::cout << "Connection openened: " << connection.get() << std::endl;
}
void OnConnectionClose(std::shared_ptr<Connection> connection) override {
//std::cout << "Connection closed: " << connection.get() << std::endl;
}
void OnReceive(std::shared_ptr<Connection> connection, char data[], size_t bytes_received) override {
connection->send_nonblocking(data, bytes_received);
std::cout << "Received message: ";
for (int i1 = 0; i1 < bytes_received; i1++) {
std::cout << data[i1];
}
std::cout << std::endl;
}
void OnSend(std::shared_ptr<Connection> connection, char data[], size_t data_size, size_t bytes_sent) override {
}
};
int main(int argc, char* argv[]) {
{
ServiceOptions options;
options.server_port_ = 5000;
options.threads_ = 8;
options.transport_protocol_ = IPV6::TCP();
NetworkService ok(options);
Echoing_Handler hand;
ok.addHandler(&hand);
ok.start();
std::cin.get();
}
}