summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sessionManager.cpp5
-rw-r--r--src/sessionManager.hpp1
2 files changed, 6 insertions, 0 deletions
diff --git a/src/sessionManager.cpp b/src/sessionManager.cpp
index adf3834..801d9a7 100644
--- a/src/sessionManager.cpp
+++ b/src/sessionManager.cpp
@@ -3,6 +3,7 @@
#include "session.hpp"
#include <algorithm>
#include <cstring>
+#include <ranges>
#include <unistd.h>
#include <utility>
@@ -68,6 +69,10 @@ CSession *CSessionManager::getByIp(const char m_ip[INET_ADDRSTRLEN]) const {
return it != m_vSessions.end() ? it->second.get() : nullptr;
}
+std::vector<std::shared_ptr<CSession>> CSessionManager::getSessions() const {
+ return m_vSessions | std::views::transform([](const auto &s) { return s.second; }) | std::ranges::to<std::vector>();
+}
+
void CSessionManager::kick(CSession *session, const bool &kill, const std::string &reason) {
for (auto &_session : m_vSessions)
if (_session.second.get() == session)
diff --git a/src/sessionManager.hpp b/src/sessionManager.hpp
index 70faa58..b33a39e 100644
--- a/src/sessionManager.hpp
+++ b/src/sessionManager.hpp
@@ -24,6 +24,7 @@ class CSessionManager {
CSession *getByName(const std::string &name) const;
CSession *getByIp(const char m_ip[INET_ADDRSTRLEN]) const;
+ std::vector<std::shared_ptr<CSession>> getSessions() const;
private:
void broadcastChat(const std::string &msg, const std::string &username) const;