feat: server, client 디렉토리 조정 및 client 헤더 파일 추가. 시나리오

혹은 대화형 클라이언트로 수정
This commit is contained in:
bumpsoo 2026-02-04 13:16:36 +00:00
parent b887f15662
commit 1d103d7f16
12 changed files with 281 additions and 112 deletions

View file

@ -1,32 +0,0 @@
#include "NetworkService.h"
#include "Logger.h"
#include "Session.h"
NetworkService::NetworkService(uint16_t port, int threadCount)
: acceptor_(io_context_, tcp::endpoint(tcp::v4(), port)),
work_guard_(boost::asio::make_work_guard(io_context_)) {
threads_.reserve(threadCount);
for (int i = 0; i < threadCount; ++i) {
threads_.emplace_back([this]() { io_context_.run(); });
}
}
NetworkService::~NetworkService() { Stop(); }
void NetworkService::Run() {
Logger::Log("서버가 포트 ", acceptor_.local_endpoint().port(),
"에서 리스닝을 시작했습니다.");
DoAccept();
}
void NetworkService::Stop() { io_context_.stop(); }
void NetworkService::DoAccept() {
acceptor_.async_accept(
[this](boost::system::error_code ec, tcp::socket socket) {
if (!ec) {
std::make_shared<Session>(std::move(socket))->Start();
}
DoAccept();
});
}