From f25eec7a0ba4a8a868eb87c76ec8b88f76f3a124 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 20 Mar 2025 22:38:46 +0800 Subject: feat: inputManager and commandHandler (#7) server now have ability to send chat like any clients. can also run commands(registered in commands.cpp) --- src/chatServer.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/chatServer.cpp') diff --git a/src/chatServer.cpp b/src/chatServer.cpp index 8e9a3ab..56caf4b 100644 --- a/src/chatServer.cpp +++ b/src/chatServer.cpp @@ -1,5 +1,8 @@ #include "chatServer.hpp" #include "chatManager.hpp" +#include "commandHandler.hpp" +#include "commands.hpp" +#include "inputManager.hpp" #include "log.hpp" #include "server.hpp" #include "sessionManager.hpp" @@ -23,6 +26,8 @@ void CChatServer::cleanup() { // m_sessionManagerThread.join(); g_pSessionManager.reset(); g_pServer.reset(); + g_pCommandHandler.reset(); + g_pInputManager.reset(); } void CChatServer::initManagers() { @@ -33,15 +38,20 @@ void CChatServer::initManagers() { g_pSessionManager = std::make_shared(); log(LOG, "Creating ChatManager"); g_pChatManager = std::make_unique(); + log(LOG, "Creating InputManager"); + g_pInputManager = std::make_unique(); } void CChatServer::start() { initManagers(); + log(LOG, "Creating CommandHandler"); + g_pCommandHandler = std::make_unique(); + registerCommands(); + // will await while waiting for accept() to return a new client m_sessionManagerThread = std::jthread(&CSessionManager::run, g_pSessionManager.get()); m_sessionManagerThread.detach(); - while (true) { - } + g_pInputManager->run(); } -- cgit v1.2.3