From 7023f81541a6987fd805142f359a03447331bf8f Mon Sep 17 00:00:00 2001 From: Namonay Date: Tue, 23 Jan 2024 17:14:58 +0100 Subject: [PATCH] gg --- includes/channel.hpp | 9 ++++----- includes/server.hpp | 4 ++-- srcs/channel.cpp | 22 ++++++++++++++++------ srcs/server.cpp | 2 +- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/includes/channel.hpp b/includes/channel.hpp index 1db2769..bf0ac7e 100644 --- a/includes/channel.hpp +++ b/includes/channel.hpp @@ -1,14 +1,14 @@ -/* ************************************************************************** */ +/******************************************************************************/ /* */ /* ::: :::::::: */ /* channel.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: maldavid +#+ +:+ +#+ */ +/* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 10:34:25 by maldavid #+# #+# */ -/* Updated: 2024/01/23 10:49:35 by maldavid ### ########.fr */ +/* Updated: 2024/01/23 16:48:15 by vvaas ### ########.fr */ /* */ -/* ************************************************************************** */ +/******************************************************************************/ #ifndef __CHANNEL__ #define __CHANNEL__ @@ -17,7 +17,6 @@ #include #include #include - namespace irc { class Channel diff --git a/includes/server.hpp b/includes/server.hpp index c30f035..3db9b85 100644 --- a/includes/server.hpp +++ b/includes/server.hpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 09:12:28 by maldavid #+# #+# */ -/* Updated: 2024/01/23 10:21:04 by maldavid ### ########.fr */ +/* Updated: 2024/01/23 17:07:50 by vvaas ### ########.fr */ /* */ /******************************************************************************/ @@ -69,7 +69,7 @@ namespace irc fd_set _fd_set; const std::string _password; const std::string _ip; - const int _port; + int _port; int _main_socket; bool _active; }; diff --git a/srcs/channel.cpp b/srcs/channel.cpp index c4bda60..5758bc6 100644 --- a/srcs/channel.cpp +++ b/srcs/channel.cpp @@ -1,16 +1,18 @@ -/* ************************************************************************** */ +/******************************************************************************/ /* */ /* ::: :::::::: */ /* channel.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: maldavid +#+ +:+ +#+ */ +/* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 10:36:21 by maldavid #+# #+# */ -/* Updated: 2024/01/23 11:01:06 by maldavid ### ########.fr */ +/* Updated: 2024/01/23 17:10:16 by vvaas ### ########.fr */ /* */ -/* ************************************************************************** */ +/******************************************************************************/ #include +#include +#include namespace irc { @@ -18,11 +20,19 @@ namespace irc void Channel::addClient(unstd::SharedPtr client) { - if(!_clients.insert(client).second) // client already in coco channel - return; + for (std::set >::iterator it = _clients.begin(); it != _clients.end(); ++it) + { + if (const_cast&>(*it)->getNickName() == client->getNickName()) + { + logs::report(log_message, "%s is already is channel for", client->getNickName().c_str()); + return ; + } + } + _clients.insert(client); for(std::set >::iterator it = _clients.begin(); it != _clients.end(); ++it) { const_cast&>(*it)->sendMsg(client->getNickName(), "JOIN", _name); + logs::report(log_message, "%s has been sent a JOIN message", const_cast&>(*it)->getNickName().c_str()); } } diff --git a/srcs/server.cpp b/srcs/server.cpp index 5de2d5d..676cc0d 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/23 10:48:00 by maldavid ### ########.fr */ +/* Updated: 2024/01/23 17:10:38 by vvaas ### ########.fr */ /* */ /******************************************************************************/