/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Server.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/15 12:15:13 by fgras-ca #+# #+# */ /* Updated: 2024/06/04 15:03:28 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef SERVER_HPP #define SERVER_HPP #include "Utils.hpp" #include "Client.hpp" #include "Channel.hpp" #include "ClientManager.hpp" #include "CommandHandler.hpp" #include "AdditionalCommands.hpp" #include "RPL.hpp" #include "ModeHandler.hpp" #include "TopicHandler.hpp" #include #include #include #include #include #include #include #include #include #include #include #include class Client; class Channel; class ClientManager; class CommandHandler; class AdditionalCommands; class ModeHandler; class TopicHandler; class Server { public: Server(int port, const std::string &password); ~Server(); void run(); void log(const std::string &message, const std::string &color = "\033[0m"); void sendToClient(int client_fd, const std::string &message); std::map &getChannels(); std::map &getClients(); const std::string &getPassword() const; void broadcast(const std::string &message); Client* getClientByName(const std::string &name); Channel* getChannelByName(const std::string &name); void disconnectClient(int clientFd); bool MatchFd(const pollfd& pfd, int clientFd); void removePollFd(int clientFd); protected: int _server_fd; int _port; std::string _password; std::map _clients; std::map _channels; std::vector _poll_fds; ClientManager *_clientManager; CommandHandler *_commandHandler; ModeHandler *_modeHandler; TopicHandler *_topicHandler; friend class ClientManager; friend class CommandHandler; friend class ModeHandler; friend class TopicHandler; private: void initServer(); void handleServerCommands(); }; #endif