#ifndef SERVER_HPP #define SERVER_HPP #include #include #include #include // Include for the send function #include // Include for the strlen function #include #include #include #include #include #include #include #include "Client.hpp" #include #include #include "channel.hpp" #include #include #include #define BUFFER_SIZE 1024 #define RED "\033[31m" #define GREEN "\033[32m" #define YELLOW "\033[33m" #define BLUE "\033[34m" #define MAGENTA "\033[35m" #define CYAN "\033[36m" #define RESET "\033[0m" class Server { private: int _port; int _serverSocketFd; static bool _signal; std::string _password; std::vector _fds; std::vector _clients; // THAT'S THA DATA OF TOOOP GGG START FROM THERE . std::map nicknames; // Replace unordered_map with map std::map usernamesoperators; // Replace unordered_map with map std::map usernames; // Replace unordered_map with map std::map usernamesregulars; // std::map > channels; //here a chanel name and list of client in every chanel std::map channels; public: Server(); ~Server(); // THAT'S MY FUNCTIONS START FROM THERE void setNickname(int fd, const std::string& nickname); std::string getPassowrd() const; void setPassword(const std::string& password); void setUsernameoperators(int fd, const std::string& username); void setUsernames(int fd, const std::string& username); std::string formatCreationTime(); std::string constructCreationTimeMessage(const std::string& channelName); std::string constructJoinedTimeMessage(const std::string& channelName); void setUsernameregular(int fd, const std::string& username); void createChannel(const std::string& channel, const std::string& nickname, int fd); void handlePrivateMessage(int senderFd, const std::string& recipient, const std::string& message); void handleInvitation(int senderFd, const std::string& recipient, std::string channelName); void broadcastMessage(const std::string& channel, const std::string& senderNickname, const std::string& msg); void smallbroadcastMessagefortheckick(std::string nicknamesender , const std::string& channelname, const std::string& usertokick, const std::string& reason); void smallbroadcastMessageforjoin(std::string nicknamesender , const std::string& channelname); void smallbroadcastMessageforTopic(std::string nicknamesender, const std::string& channelname, std::string topic); void smallbroadcastMOOD(std::string nicknamesender, const std::string& channelname, std::string mode, std::string receiver); int findUserFd1(const std::string& username); std::string findUsernameforsending(int fd); bool isOperator(int fd); void kickUser(int fd); int findUserFdforkickregulars(const std::string& username); bool dontputthesamenick(const std::string& nickname); bool dontputthesameusername(const std::string& username); // AND END HERE. void parseArgs(int ac, char **av); static void receiveSignal(int signum); void init(); void run(); void createServerSocket(); void bindServerSocket(); void addPollfd(int fd); void handleClientConnection(); void handleClientData(int fd); void clientCleanup(int fd); void closeFds(); Client& getClientByFd(int fd); }; int randomInRange(int min, int max); std::string intToString(int number); #endif