From 8ab26f85e474dcdbbb2c2fb94b6a087f71952bf8 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 9 Mar 2025 14:16:46 +0800 Subject: feat: broadcast message from one client to the rest, making chat actually possible fix(chatServer, CSessionManager): .join sessionThread properly cleanup(server): unused header --- src/sessionManager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/sessionManager.cpp') 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> *session) { auto it = std::ranges::find_if(m_vSessions, [session](const auto &s) { return s.second.get() == session->second.get(); }); -- cgit v1.2.3