-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_build.cpp
More file actions
35 lines (28 loc) · 1 KB
/
test_build.cpp
File metadata and controls
35 lines (28 loc) · 1 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
#include "hvnetpp/EventLoop.h"
#include "hvnetpp/TcpServer.h"
#include "rtclog.h"
#include <iostream>
int main() {
// Initialize logger
rtclog_init("TestServer");
rtclog_configure("logs/xrtc.log", true);
rtclog_set_level(RTC_DEBUG);
RTCLOG(RTC_INFO, "Application started");
RTCLOG(RTC_WARN, "This is a warning message");
RTCLOG(RTC_ERROR, "This is an error message with code: %d", 404);
RTCLOG(RTC_INFO, "TestServer starting...");
hvnetpp::EventLoop loop;
hvnetpp::InetAddress addr(9999);
hvnetpp::TcpServer server(&loop, addr, "TestServer");
server.setConnectionCallback([](const hvnetpp::TcpConnectionPtr& conn) {
if (conn->connected()) {
RTCLOG(RTC_INFO, "Client connected: %s", conn->peerAddress().toIpPort().c_str());
} else {
RTCLOG(RTC_INFO, "Client disconnected: %s", conn->peerAddress().toIpPort().c_str());
}
});
server.start();
RTCLOG(RTC_INFO, "Server started loop");
loop.loop();
return 0;
}