hon hon hon baguette

This commit is contained in:
Kbz-8
2024-01-25 17:04:42 +01:00
parent 92847d7c19
commit 3953cb8d0a
9 changed files with 138 additions and 22 deletions

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 09:31:17 by maldavid #+# #+# */
/* Updated: 2024/01/25 00:09:16 by vvaas ### ########.fr */
/* Updated: 2024/01/25 16:39:09 by maldavid ### ########.fr */
/* */
/******************************************************************************/
@@ -22,6 +22,12 @@
namespace irc
{
typedef std::vector<unstd::SharedPtr<Client> >::iterator client_it;
typedef std::vector<unstd::SharedPtr<Client> >::const_iterator client_const_it;
typedef std::vector<Channel>::iterator channel_it;
typedef std::vector<Channel>::const_iterator channel_const_it;
Server::Server(int port, const std::string& password) : _s_len(sizeof(_s_data)), _password(password), _port(port), _active(true)
{
std::memset(&_s_data, 0, sizeof(sockaddr));
@@ -158,6 +164,26 @@ namespace irc
return true;
}
bool Server::isUserKnown(const std::string& user) const
{
for(client_const_it it = _client.begin(); it < _client.end(); ++it)
{
if(const_cast<unstd::SharedPtr<Client>&>(*it)->getNickName() == user)
return true;
}
return false;
}
bool Server::isChannelKnown(const std::string& channel) const
{
for(channel_const_it it = _channels.begin(); it < _channels.end(); ++it)
{
if(it->getName() == channel)
return true;
}
return false;
}
Server::~Server()
{
closeMainSocket();