From d70b1b8e304d245c877acee70ba5a942b08943a2 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Mon, 22 Jan 2024 18:17:48 +0100 Subject: [PATCH] caca boudin qui pue --- Makefile | 3 ++- includes/channel.hpp | 12 +++++++++++- srcs/server.cpp | 3 ++- srcs/server_functions.cpp | 6 ++++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 5c9aadf..1a0e170 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: vvaas +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # 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 diff --git a/includes/channel.hpp b/includes/channel.hpp index bc3ee30..05a6c86 100644 --- a/includes/channel.hpp +++ b/includes/channel.hpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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) { _clients.insert(client); } inline bool removeClient(unstd::SharedPtr client) { return _clients.erase(client); } inline std::size_t getNumberOfClients() const { return _clients.size(); } + inline void addOperator(unstd::SharedPtr op) { _operators.insert(op); } + inline bool removeOperator(unstd::SharedPtr op) { return _operators.erase(op); } + + inline bool isInviteOnly() const { return _invite_only; } + ~Channel(); private: std::set > _clients; + std::set > _operators; const std::string _name; + std::string _password; + bool _invite_only; }; } diff --git a/srcs/server.cpp b/srcs/server.cpp index 28ddc93..c232962 100644 --- a/srcs/server.cpp +++ b/srcs/server.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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; } diff --git a/srcs/server_functions.cpp b/srcs/server_functions.cpp index 8f4752a..c7205a0 100644 --- a/srcs/server_functions.cpp +++ b/srcs/server_functions.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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 client, const Message& msg) { (void)msg; + for(std::vector::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);