summaryrefslogtreecommitdiff
path: root/src/chatServer.cpp
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-06-12 21:41:41 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-06-13 20:22:51 +0800
commit6f7b994684032060f0a2d7af82f4f3572293b8d6 (patch)
tree793d328cbcd6761365267550b55db45aee9b21fc /src/chatServer.cpp
parent6a51ab4525c59e9fe2bdbd92493019b0a98c6b94 (diff)
internal!: organized internal structure, using cmake now
Diffstat (limited to 'src/chatServer.cpp')
-rw-r--r--src/chatServer.cpp68
1 files changed, 0 insertions, 68 deletions
diff --git a/src/chatServer.cpp b/src/chatServer.cpp
deleted file mode 100644
index 458fc09..0000000
--- a/src/chatServer.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-#include "chatServer.hpp"
-#include "IOManager.hpp"
-#include "chatManager.hpp"
-#include "commandHandler.hpp"
-#include "commands.hpp"
-#include "inputManager.hpp"
-#include "log.hpp"
-#include "renderManager.hpp"
-#include "server.hpp"
-#include "sessionManager.hpp"
-
-CChatServer::CChatServer(uint16_t port)
- : m_port(port) {
- if (std::atexit([]() { g_pChatServer->cleanup(); }))
- log(ERR, "Failed to register CChatServer atexit handler, dtors will not be called");
-
- log(LOG, "ChatServer: initialized");
-};
-
-CChatServer::~CChatServer() {
- cleanup();
- log(SYS, "ChatServer: bye");
-}
-
-void CChatServer::cleanup() {
- if (g_pSessionManager) {
- g_pSessionManager->shutdownSessions();
- g_pSessionManager.reset();
- }
-
- g_pChatManager.reset();
- g_pServer.reset();
- g_pCommandHandler.reset();
- g_pInputManager.reset();
- g_pIOManager.reset();
- g_pRenderManager.reset();
-}
-
-void CChatServer::initManagers() {
- log(LOG, "ChatServer: initializing managers");
-
- log(LOG, "Creating RenderManager");
- g_pRenderManager = std::make_unique<CRenderManager>();
- log(LOG, "Creating InputManager");
- g_pInputManager = std::make_unique<CInputManager>();
- log(LOG, "Creating Server");
- g_pServer = std::make_unique<CServer>(m_port);
- log(LOG, "Creating IOManager");
- g_pIOManager = std::make_unique<CIOManager>();
- log(LOG, "Creating SessionManager");
- g_pSessionManager = std::make_shared<CSessionManager>();
- log(LOG, "Creating ChatManager");
- g_pChatManager = std::make_unique<CChatManager>();
-}
-
-void CChatServer::start() {
- initManagers();
-
- log(LOG, "Creating CommandHandler");
- g_pCommandHandler = std::make_unique<CCommandHandler>();
- registerCommands();
-
- // will await while waiting for accept() to return a new client
- m_sessionManagerThread = std::jthread(&CSessionManager::run, g_pSessionManager.get());
- m_sessionManagerThread.detach();
-
- g_pInputManager->inputLoop();
-}