summaryrefslogtreecommitdiff
path: root/src/sessionManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sessionManager.cpp')
-rw-r--r--src/sessionManager.cpp33
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) {