Files
ft_irc/Server/Server.hpp
2026-05-09 21:52:16 +02:00

61 lines
1.7 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Server.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: iherman- <iherman-@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/05/06 17:18:11 by iherman- #+# #+# */
/* Updated: 2026/05/09 21:47:58 by iherman- ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SERVER_HPP
# define SERVER_HPP
// C lib functions
// C++ lib functions
# include <iostream>
# include <string>
# include <cstring>
# include <vector>
# include <map>
# include "../User/User.hpp"
# define PORT_DEFAULT 9898
class Server
{
private:
static const int kConnectionQueueLimit;
int port_;
int serverSocket_;
std::string password_;
std::vector<struct pollfd> sockets_;
std::map<int, User> clients_;
bool handleClient(User& client);
void addClient();
std::vector<struct pollfd>::iterator removeClient(std::vector<struct pollfd>::iterator client);
Server(const Server& other);
Server &operator=(const Server& other);
public:
Server();
Server(int port, const std::string& password);
~Server();
void run();
};
#endif // SERVER_HPP