caca boudin qui pue

This commit is contained in:
Kbz-8
2024-01-22 18:17:48 +01:00
parent 7b60a2e6d3
commit d70b1b8e30
4 changed files with 19 additions and 5 deletions

View File

@@ -6,7 +6,7 @@
# By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/08/09 15:08:49 by vavaas #+# #+# #
# Updated: 2024/01/22 17:31:49 by maldavid ### ########.fr #
# Updated: 2024/01/22 17:32:49 by maldavid ### ########.fr #
# #
#******************************************************************************#
@@ -27,6 +27,7 @@ OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o))
CXX = c++
FLAGS ?= true
CXXFLAGS = -std=c++98 -I includes
ifeq ($(FLAGS), true)
CXXFLAGS += -Wall -Wextra -Werror
endif

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 10:34:25 by maldavid #+# #+# */
/* Updated: 2024/01/22 16:06:15 by maldavid ### ########.fr */
/* Updated: 2024/01/22 18:14:50 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -26,15 +26,25 @@ namespace irc
Channel(const std::string& name);
inline const std::string& getName() const { return _name; }
inline const std::string& getPassword() const { return _password; }
inline void addClient(unstd::SharedPtr<Client> client) { _clients.insert(client); }
inline bool removeClient(unstd::SharedPtr<Client> client) { return _clients.erase(client); }
inline std::size_t getNumberOfClients() const { return _clients.size(); }
inline void addOperator(unstd::SharedPtr<Client> op) { _operators.insert(op); }
inline bool removeOperator(unstd::SharedPtr<Client> op) { return _operators.erase(op); }
inline bool isInviteOnly() const { return _invite_only; }
~Channel();
private:
std::set<unstd::SharedPtr<Client> > _clients;
std::set<unstd::SharedPtr<Client> > _operators;
const std::string _name;
std::string _password;
bool _invite_only;
};
}

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 09:31:17 by maldavid #+# #+# */
/* Updated: 2024/01/22 17:31:00 by maldavid ### ########.fr */
/* Updated: 2024/01/22 17:44:27 by maldavid ### ########.fr */
/* */
/******************************************************************************/
@@ -153,6 +153,7 @@ namespace irc
handlePing(client, msg);
else if(msg.getCmd() == "MODE")
handleMode(client, msg);
return true;
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/22 17:31:06 by maldavid #+# #+# */
/* Updated: 2024/01/22 17:31:28 by maldavid ### ########.fr */
/* Updated: 2024/01/22 18:05:35 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -57,6 +57,8 @@ namespace irc
void Server::handleQuit(unstd::SharedPtr<class Client> client, const Message& msg)
{
(void)msg;
for(std::vector<Channel>::iterator it = _channels.begin(); it != _channels.end(); ++it)
it->removeClient(client);
client->printUserHeader();
std::cout << "quit" << std::endl;
}
@@ -127,8 +129,8 @@ namespace irc
if(it == _channels.end())
{
_channels.push_back(Channel(msg.getTokens()[1]));
logs::report(log_message, "channel '%s' has beed created", msg.getTokens()[1].c_str());
_channels.back().addClient(client);
logs::report(log_message, "channel '%s' has beed created", msg.getTokens()[1].c_str());
}
else
it->addClient(client);