32 lines
986 B
C++
32 lines
986 B
C++
|
|
#include "spdlog/spdlog.h"
|
||
|
|
#include "tcp_server.h" // 引入我们新的服务头文件
|
||
|
|
#include <boost/asio.hpp>
|
||
|
|
#include <iostream>
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
try {
|
||
|
|
spdlog::info("Edge Proxy main program started.");
|
||
|
|
|
||
|
|
// Boost.Asio 的核心 I/O 上下文/事件循环
|
||
|
|
boost::asio::io_context io_context;
|
||
|
|
|
||
|
|
// 创建我们的 TCP 服务实例,监听 9999 端口
|
||
|
|
TCPServer tcp_service(io_context, 9999);
|
||
|
|
|
||
|
|
// 在这里,未来您可以创建并启动其他服务...
|
||
|
|
// e.g., UDPService udp_service(io_context, 8888);
|
||
|
|
|
||
|
|
spdlog::info("All services initialized. Starting I/O event loop...");
|
||
|
|
|
||
|
|
// 运行 I/O 上下文,这会阻塞并开始处理所有异步事件(如网络连接)
|
||
|
|
io_context.run();
|
||
|
|
|
||
|
|
spdlog::info("Edge Proxy main program finished.");
|
||
|
|
|
||
|
|
} catch (const std::exception& e) {
|
||
|
|
spdlog::error("Exception in main: {}", e.what());
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|