diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-03-11 13:37:25 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-03-20 23:44:58 +0800 |
| commit | 4764b5f494fd5c0fe41dbc01779738c450198933 (patch) | |
| tree | a7880b2e6beb97152414cea6f451204c41ddf110 /src/sessionManager.cpp | |
| parent | 513623fc0e5182d37aaf91c6dc42670bca3aa888 (diff) | |
clang-format
Diffstat (limited to 'src/sessionManager.cpp')
| -rw-r--r-- | src/sessionManager.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/sessionManager.cpp b/src/sessionManager.cpp index b4e1ad5..7b40bc2 100644 --- a/src/sessionManager.cpp +++ b/src/sessionManager.cpp @@ -1,29 +1,29 @@ #include "sessionManager.hpp" +#include "log.hpp" #include "server.hpp" #include "session.hpp" #include <algorithm> #include <unistd.h> #include <utility> -#include "log.hpp" void CSessionManager::shutdownSessions() { for (const auto &[thread, session] : m_vSessions) - session->onShutdown(); + session->onShutdown(); } CSessionManager::CSessionManager() { - if (std::atexit([]() { g_pSessionManager->shutdownSessions(); })) - log(ERR, "Failed to register SessionManager atexit handler, will fallback to quick_exit after hang"); + if (std::atexit([]() { g_pSessionManager->shutdownSessions(); })) + log(ERR, "Failed to register SessionManager atexit handler, will fallback to quick_exit after hang"); - log(LOG, "SessionManager: initialized"); + log(LOG, "SessionManager: initialized"); }; CSessionManager::~CSessionManager() { for (auto &[thread, session] : m_vSessions) - if (thread.joinable()) - thread.join(); + if (thread.joinable()) + thread.join(); - log(SYS, "SessionManager: bye"); + log(SYS, "SessionManager: bye"); } std::pair<std::jthread, std::shared_ptr<CSession>> *CSessionManager::newSession(Hyprutils::OS::CFileDescriptor sockfd) { @@ -34,8 +34,8 @@ std::pair<std::jthread, std::shared_ptr<CSession>> *CSessionManager::newSession( } void CSessionManager::run() { - while (true) - newSession(Hyprutils::OS::CFileDescriptor{accept(g_pServer->getSocket()->get(), nullptr, nullptr) /* awaits new client/session */}); + while (true) + newSession(Hyprutils::OS::CFileDescriptor{accept(g_pServer->getSocket()->get(), nullptr, nullptr) /* awaits new client/session */}); } void CSessionManager::broadcast(const std::string &msg, eFormatType type) const { @@ -45,15 +45,16 @@ void CSessionManager::broadcast(const std::string &msg, eFormatType type) const void CSessionManager::broadcastChat(const std::string &msg, const std::string &username) const { for (const auto &[thread, session] : m_vSessions) { - if (!session) continue; - auto name = session->getName(); - if (name != username) - session->write(msg, NONE); - } + if (!session) + continue; + auto name = session->getName(); + if (name != username) + session->write(msg, NONE); + } } bool CSessionManager::nameExists(const std::string &name) { - return std::ranges::any_of(m_vSessions, [&name](const auto &s) { return s.second->getName() == name; }); + return std::ranges::any_of(m_vSessions, [&name](const auto &s) { return s.second->getName() == name; }); } void CSessionManager::removeSession(std::pair<std::jthread, std::shared_ptr<CSession>> *session) { |
