From 6da78f6457941b8d2ef2d408d3768c1359c983b4 Mon Sep 17 00:00:00 2001 From: Ladebeze66 Date: Tue, 11 Jun 2024 16:03:46 +0200 Subject: [PATCH] finalversionpeutetre --- ft_irc3/src/Join.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ft_irc3/src/Join.cpp b/ft_irc3/src/Join.cpp index eab6a02..c6a4638 100644 --- a/ft_irc3/src/Join.cpp +++ b/ft_irc3/src/Join.cpp @@ -46,6 +46,27 @@ void JoinHandler::handleJoinCommand(Client* client, const std::string& params, S if (channelName[0] == '0' && channelName.size() == 1) { + std::cout << "leave all -----------" << std::endl; + std::map & channels = server->getChannels(); + for (std::map::iterator it = channels.begin(); it != channels.end(); ++it) + { + // std::cout << it->second->getName() << std::endl; + if (it->second->hasClient(client)) + { + it->second->removeClient(client); + if (it->second->isEmpty()) + { + delete it->second; + } + + std::ostringstream partMsg; + partMsg << ":" << client->getNickname() << " PART " << it->first << " Leaving" << "\r\n"; + server->sendToClient(client->getFd(), partMsg.str()); + + it->second->broadcast(partMsg.str(), client, server); + } + } + // Leave all channels return; }