diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-03-09 14:16:46 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-03-20 23:44:57 +0800 |
| commit | 8ab26f85e474dcdbbb2c2fb94b6a087f71952bf8 (patch) | |
| tree | 752c1129db2d363dfd96dd15d27c34f2e126a4e3 /src/sessionManager.cpp | |
| parent | 938ca89e48c2a01d6aa072f01545fa2da585486c (diff) | |
feat: broadcast message from one client to the rest, making chat actually possible
fix(chatServer, CSessionManager): .join sessionThread properly
cleanup(server): unused header
Diffstat (limited to 'src/sessionManager.cpp')
| -rw-r--r-- | src/sessionManager.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/sessionManager.cpp b/src/sessionManager.cpp index e449567..84c3709 100644 --- a/src/sessionManager.cpp +++ b/src/sessionManager.cpp @@ -29,6 +29,12 @@ void CSessionManager::broadcast(const std::string &msg, eFormatType type) const session->write(msg, type); } +void CSessionManager::broadcastChat(const std::string &msg, const std::string &username) const { + for (const auto &[thread, session] : m_vSessions) + if (session->getName() != username) + session->write(msg, NONE); +} + void CSessionManager::removeSession(std::pair<std::jthread, std::shared_ptr<CSession>> *session) { auto it = std::ranges::find_if(m_vSessions, [session](const auto &s) { return s.second.get() == session->second.get(); }); |
