-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.cpp
37 lines (30 loc) · 840 Bytes
/
main.cpp
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
#include "tcp_server.h"
#include "packetmanager.h"
#include <iostream>
int main() {
TCPServer server{IPV::V4, 30002};
server.OnConnect = [](TCPConnection::pointer connection) {
cout << format("[TCPServer] Client ({}) has connected to the server\n", connection->GetEndPoint());
};
server.OnDisconnect = [](TCPConnection::pointer connection) {
cout << format("[TCPServer] Client ({}) has disconnected from the server\n", connection->GetEndPoint());
};
server.OnClientPacket = [](TCPConnection::Packet::pointer packet) {
packetManager.QueuePacket(packet);
};
server.Start();
packetManager.Start();
string command;
while (getline(cin >> ws, command)) {
if (command == "stop") {
packetManager.Stop();
server.Stop();
break;
}
else {
cout << "Available commands: stop\n";
continue;
}
}
return 0;
}