c est metaphysique
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/21 10:34:25 by maldavid #+# #+# */
|
/* Created: 2024/01/21 10:34:25 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/30 17:23:28 by maldavid ### ########.fr */
|
/* Updated: 2024/01/30 20:14:08 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ namespace irc
|
|||||||
inline const std::string& getPassword() const { return _password; }
|
inline const std::string& getPassword() const { return _password; }
|
||||||
|
|
||||||
void addClient(unstd::SharedPtr<Client> client, bool op = false);
|
void addClient(unstd::SharedPtr<Client> client, bool op = false);
|
||||||
bool removeClient(unstd::SharedPtr<Client> client);
|
bool removeClient(unstd::SharedPtr<Client> client, std::string reason = "");
|
||||||
|
|
||||||
inline std::size_t getNumberOfClients() const { return _clients.size(); }
|
inline std::size_t getNumberOfClients() const { return _clients.size(); }
|
||||||
inline int getChannelSize() const { return _channel_size; }
|
inline int getChannelSize() const { return _channel_size; }
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/21 10:36:21 by maldavid #+# #+# */
|
/* Created: 2024/01/21 10:36:21 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/30 18:48:32 by vvaas ### ########.fr */
|
/* Updated: 2024/01/30 20:15:29 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@@ -71,16 +71,22 @@ namespace irc
|
|||||||
client->sendCode(ERR_USERNOTINCHANNEL, "User not in channel");
|
client->sendCode(ERR_USERNOTINCHANNEL, "User not in channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Channel::removeClient(unstd::SharedPtr<Client> client)
|
bool Channel::removeClient(unstd::SharedPtr<Client> client, std::string reason)
|
||||||
{
|
{
|
||||||
if(!_clients.erase(client))
|
if(!_clients.erase(client))
|
||||||
return (false);
|
return false;
|
||||||
if(isOp(client))
|
if(isOp(client))
|
||||||
_operators.erase(client);
|
_operators.erase(client);
|
||||||
for(client_it it = _clients.begin(); it != _clients.end(); ++it)
|
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);
|
const_cast<unstd::SharedPtr<irc::Client>&>(*it)->sendMsg(client->getNickName(), "PART", _name);
|
||||||
|
else
|
||||||
|
const_cast<unstd::SharedPtr<irc::Client>&>(*it)->sendMsg(client->getNickName(), "QUIT", reason);
|
||||||
|
}
|
||||||
|
if(reason.empty())
|
||||||
client->sendMsg(client->getNickName(), "PART", _name);
|
client->sendMsg(client->getNickName(), "PART", _name);
|
||||||
return (true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Channel::sendWho(unstd::SharedPtr<Client> client)
|
void Channel::sendWho(unstd::SharedPtr<Client> client)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/22 17:31:06 by maldavid #+# #+# */
|
/* Created: 2024/01/22 17:31:06 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/30 18:50:47 by maldavid ### ########.fr */
|
/* Updated: 2024/01/30 20:13:48 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@@ -119,9 +119,8 @@ namespace irc
|
|||||||
|
|
||||||
void Server::handleQuit(unstd::SharedPtr<class Client> client, const Message& msg)
|
void Server::handleQuit(unstd::SharedPtr<class Client> client, const Message& msg)
|
||||||
{
|
{
|
||||||
(void)msg;
|
|
||||||
for(channel_it it = _channels.begin(); it != _channels.end(); ++it)
|
for(channel_it it = _channels.begin(); it != _channels.end(); ++it)
|
||||||
it->removeClient(client);
|
it->removeClient(client, msg.getReason());
|
||||||
client->printUserHeader();
|
client->printUserHeader();
|
||||||
std::cout << "quit" << std::endl;
|
std::cout << "quit" << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/30 01:54:56 by vvaas #+# #+# */
|
/* Created: 2024/01/30 01:54:56 by vvaas #+# #+# */
|
||||||
/* Updated: 2024/01/30 18:34:07 by vvaas ### ########.fr */
|
/* Updated: 2024/01/30 18:52:24 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user