/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Server.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aortigos +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/04/13 22:31:44 by aortigos #+# #+# */ /* Updated: 2026/04/13 22:31:44 by aortigos ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef SERVER_HPP # define SERVER_HPP # include # include # include # include # include # include # include # include "../Client/Client.hpp" # include # include const std::string ERR_PASSWORD = "ERROR :Password incorrect\r\n"; const std::string ERR_NONICK = "ERROR :No nick given\r\n"; const std::string ERR_NOPASS = "ERROR :Authenticate first\r\n"; const std::string ERR_REREGISTER = "462 :You may not reregister\r\n"; const std::string ERR_NOUSER = "ERROR :No username given\r\n"; class Server { private: int port; std::string password; int server_fd; std::vector fds; std::map clients; void acceptClient(); void readClient(int fd); void removeClient(int fd); void parseCommand(int fd, std::string line); void cmd_pass(int fd, std::istringstream &ss); void cmd_nick(int fd, std::istringstream &ss); void cmd_user(int fd, std::istringstream &ss); public: Server(); Server(int port, std::string password); ~Server(); int run(); }; #endif