From 45ca296a55332a4d79319f8a706f332aa8feb336 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 20 Mar 2025 22:33:22 +0800 Subject: feat(session): getIp --- src/session.cpp | 4 ++++ src/session.hpp | 1 + src/sessionManager.hpp | 6 +++--- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/session.cpp b/src/session.cpp index 05d6873..9668cd8 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -204,6 +204,10 @@ const std::string &CSession::getName() const { return m_name; } +const char *CSession::getIp() const { + return m_ip; +} + void CSession::setSelf(std::pair> *self) { this->self = self; } diff --git a/src/session.hpp b/src/session.hpp index c4525bd..18c587d 100644 --- a/src/session.hpp +++ b/src/session.hpp @@ -22,6 +22,7 @@ class CSession { }; const std::string &getName() const; + const char *getIp() const; void setSelf(std::pair> *self); std::unique_ptr read(); diff --git a/src/sessionManager.hpp b/src/sessionManager.hpp index b33a39e..a0f4389 100644 --- a/src/sessionManager.hpp +++ b/src/sessionManager.hpp @@ -22,9 +22,9 @@ class CSessionManager { bool nameExists(const std::string &name); void shutdownSessions(); - CSession *getByName(const std::string &name) const; - CSession *getByIp(const char m_ip[INET_ADDRSTRLEN]) const; - std::vector> getSessions() const; + CSession *getByName(const std::string &name) const; + CSession *getByIp(const char m_ip[INET_ADDRSTRLEN]) const; + std::vector> getSessions() const; private: void broadcastChat(const std::string &msg, const std::string &username) const; -- cgit v1.2.3