summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-03-20 22:33:22 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-03-21 11:18:15 +0800
commit45ca296a55332a4d79319f8a706f332aa8feb336 (patch)
tree136a47b3bcd6701aac4a07ddcf0e4ebc32f180a3 /src
parente970b786f9e5b9307c1113373b9c1f96eaafacf4 (diff)
feat(session): getIp
Diffstat (limited to 'src')
-rw-r--r--src/session.cpp4
-rw-r--r--src/session.hpp1
-rw-r--r--src/sessionManager.hpp6
3 files changed, 8 insertions, 3 deletions
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<std::jthread, std::shared_ptr<CSession>> *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<std::jthread, std::shared_ptr<CSession>> *self);
std::unique_ptr<SRecvData> 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<std::shared_ptr<CSession>> getSessions() const;
+ 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;