c est metaphysique
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/21 10:34:25 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/30 20:14:08 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/30 20:54:21 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace irc
|
||||
inline const std::string& getPassword() const { return _password; }
|
||||
|
||||
void addClient(unstd::SharedPtr<Client> client, bool op = false);
|
||||
bool removeClient(unstd::SharedPtr<Client> client, std::string reason = "");
|
||||
bool removeClient(unstd::SharedPtr<Client> client, const std::string& reason, bool quit = false);
|
||||
|
||||
inline std::size_t getNumberOfClients() const { return _clients.size(); }
|
||||
inline int getChannelSize() const { return _channel_size; }
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/21 10:36:21 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/30 20:50:31 by vvaas ### ########.fr */
|
||||
/* Updated: 2024/01/30 21:01:06 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace irc
|
||||
client->sendCode(ERR_USERNOTINCHANNEL, "User not in channel");
|
||||
}
|
||||
|
||||
bool Channel::removeClient(unstd::SharedPtr<Client> client, std::string reason)
|
||||
bool Channel::removeClient(unstd::SharedPtr<Client> client, const std::string& reason, bool quit)
|
||||
{
|
||||
if(!_clients.erase(client))
|
||||
return false;
|
||||
@@ -79,13 +79,13 @@ namespace irc
|
||||
_operators.erase(client);
|
||||
for(client_it it = _clients.begin(); it != _clients.end(); ++it)
|
||||
{
|
||||
if(reason.empty())
|
||||
const_cast<unstd::SharedPtr<irc::Client>&>(*it)->sendMsg(client->getNickName(), "PART", _name);
|
||||
if(!quit)
|
||||
const_cast<unstd::SharedPtr<irc::Client>&>(*it)->sendMsg(client->getNickName(), "PART", _name + ' ' + reason);
|
||||
else
|
||||
const_cast<unstd::SharedPtr<irc::Client>&>(*it)->sendMsg(client->getNickName(), "QUIT", reason);
|
||||
}
|
||||
if(reason.empty())
|
||||
client->sendMsg(client->getNickName(), "PART", _name);
|
||||
if(!quit)
|
||||
client->sendMsg(client->getNickName(), "PART", _name + ' ' + reason);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/21 09:31:17 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/30 18:08:41 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/30 20:58:31 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace irc
|
||||
close((*it)->getFD());
|
||||
for(channel_it cit = _channels.begin(); cit != _channels.end();)
|
||||
{
|
||||
cit->removeClient(*it);
|
||||
cit->removeClient(*it, "");
|
||||
if(cit->getNumberOfClients() == 0)
|
||||
{
|
||||
logs::report(log_message, "channel '%s' has been destroyed", cit->getName().c_str());
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/22 17:31:06 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/30 20:46:24 by vvaas ### ########.fr */
|
||||
/* Updated: 2024/01/30 21:01:20 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace irc
|
||||
void Server::handleQuit(unstd::SharedPtr<class Client> client, const Message& msg)
|
||||
{
|
||||
for(channel_it it = _channels.begin(); it != _channels.end(); ++it)
|
||||
it->removeClient(client, (msg.getReason().empty() ? "Leaving" : msg.getReason()));
|
||||
it->removeClient(client, (msg.getReason().empty() ? "Leaving" : msg.getReason()), true);
|
||||
client->printUserHeader();
|
||||
std::cout << "quit" << std::endl;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ namespace irc
|
||||
Channel* channel = getChannelByName(msg.getArgs()[0]);
|
||||
if(channel == NULL)
|
||||
logs::report(log_fatal_error, "(KICK), cannot get channel '%s' by name; panic !", channel->getName().c_str());
|
||||
if(!channel->removeClient(client))
|
||||
if(!channel->removeClient(client, (msg.getReason().empty() ? "" : msg.getReason())))
|
||||
{
|
||||
client->sendCode(ERR_NOTONCHANNEL, "Not on channel");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user