diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-03-09 13:03:17 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-03-20 23:44:57 +0800 |
| commit | 880b6a9275030515e11fdfeb3b6fc074bca9322d (patch) | |
| tree | 7679d12347beac15c91f050748c211ccf8bd556b /src/chatServer.cpp | |
| parent | 694dd95da005d09962fec05ee48c8e985782671b (diff) | |
sessionManager: run in a jthread, for prep of inputManager
refactor(main)!: move main infra to oop chatServer
Diffstat (limited to 'src/chatServer.cpp')
| -rw-r--r-- | src/chatServer.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/chatServer.cpp b/src/chatServer.cpp new file mode 100644 index 0000000..06f2021 --- /dev/null +++ b/src/chatServer.cpp @@ -0,0 +1,32 @@ +#include "chatServer.hpp" +#include "server.hpp" +#include "sessionManager.hpp" + +CChatServer::CChatServer() = default; + +CChatServer::~CChatServer() { + cleanup(); +} + +void CChatServer::cleanup() { + g_pServer.reset(); + g_pSessionManager.reset(); +} + +void CChatServer::initManagers() { + g_pServer = std::make_unique<CServer>(8080); + g_pSessionManager = std::make_shared<CSessionManager>(); +} + + +void CChatServer::start() { + initManagers(); + + // will await while waiting for accept() to return a new client + std::jthread sessionThread = std::jthread(&CSessionManager::enterLoop, g_pSessionManager); + sessionThread.detach(); + + while (true) { + } +} + |
