This commit is contained in:
2024-01-23 17:14:58 +01:00
parent 8042d3db6f
commit 7023f81541
4 changed files with 23 additions and 14 deletions

View File

@@ -1,14 +1,14 @@
/* ************************************************************************** */ /******************************************************************************/
/* */ /* */
/* ::: :::::::: */ /* ::: :::::::: */
/* channel.hpp :+: :+: :+: */ /* channel.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* 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/23 10:49:35 by maldavid ### ########.fr */ /* Updated: 2024/01/23 16:48:15 by vvaas ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /******************************************************************************/
#ifndef __CHANNEL__ #ifndef __CHANNEL__
#define __CHANNEL__ #define __CHANNEL__
@@ -17,7 +17,6 @@
#include <set> #include <set>
#include <unstd/shared_ptr.hpp> #include <unstd/shared_ptr.hpp>
#include <client.hpp> #include <client.hpp>
namespace irc namespace irc
{ {
class Channel class Channel

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 09:12:28 by maldavid #+# #+# */ /* 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; fd_set _fd_set;
const std::string _password; const std::string _password;
const std::string _ip; const std::string _ip;
const int _port; int _port;
int _main_socket; int _main_socket;
bool _active; bool _active;
}; };

View File

@@ -1,16 +1,18 @@
/* ************************************************************************** */ /******************************************************************************/
/* */ /* */
/* ::: :::::::: */ /* ::: :::::::: */
/* channel.cpp :+: :+: :+: */ /* channel.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* 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/23 11:01:06 by maldavid ### ########.fr */ /* Updated: 2024/01/23 17:10:16 by vvaas ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /******************************************************************************/
#include <channel.hpp> #include <channel.hpp>
#include <logs.hpp>
#include <iostream>
namespace irc namespace irc
{ {
@@ -18,11 +20,19 @@ namespace irc
void Channel::addClient(unstd::SharedPtr<Client> client) void Channel::addClient(unstd::SharedPtr<Client> client)
{ {
if(!_clients.insert(client).second) // client already in coco channel for (std::set<unstd::SharedPtr<Client> >::iterator it = _clients.begin(); it != _clients.end(); ++it)
return; {
if (const_cast<unstd::SharedPtr<irc::Client>&>(*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<unstd::SharedPtr<Client> >::iterator it = _clients.begin(); it != _clients.end(); ++it) for(std::set<unstd::SharedPtr<Client> >::iterator it = _clients.begin(); it != _clients.end(); ++it)
{ {
const_cast<unstd::SharedPtr<irc::Client>&>(*it)->sendMsg(client->getNickName(), "JOIN", _name); const_cast<unstd::SharedPtr<irc::Client>&>(*it)->sendMsg(client->getNickName(), "JOIN", _name);
logs::report(log_message, "%s has been sent a JOIN message", const_cast<unstd::SharedPtr<irc::Client>&>(*it)->getNickName().c_str());
} }
} }

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 09:31:17 by maldavid #+# #+# */ /* 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 */
/* */ /* */
/******************************************************************************/ /******************************************************************************/