reconstructing code
This commit is contained in:
55
Server.hpp
55
Server.hpp
@@ -16,18 +16,10 @@
|
||||
#include "Client.hpp"
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include "channel.hpp"
|
||||
#include "Channel.hpp"
|
||||
#include <ctime>
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#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:
|
||||
@@ -41,21 +33,25 @@ class Server {
|
||||
std::map<int, std::string> usernames;
|
||||
std::map<std::string, Channel> channels;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
Server();
|
||||
~Server();
|
||||
void setNickname(int fd, const std::string& nickname);
|
||||
|
||||
std::string getPassowrd() const;
|
||||
Client& getClientByFd(int fd);
|
||||
|
||||
void setNickname(int fd, const std::string& nickname);
|
||||
void setUsernames(int fd, const std::string& username);
|
||||
void setUsernameregular(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);
|
||||
@@ -64,11 +60,12 @@ class Server {
|
||||
int findUserFd1(const std::string& username);
|
||||
bool dontputthesamenick(const std::string& nickname);
|
||||
bool dontputthesameusername(const std::string& username);
|
||||
void parseArgs(int ac, char **av);
|
||||
static void receiveSignal(int signum);
|
||||
|
||||
// Server
|
||||
void init();
|
||||
void run();
|
||||
|
||||
void parseArgs(int ac, char **av);
|
||||
static void receiveSignal(int signum);
|
||||
void createServerSocket();
|
||||
void bindServerSocket();
|
||||
void addPollfd(int fd);
|
||||
@@ -78,8 +75,32 @@ class Server {
|
||||
void cleanChannel(int fd);
|
||||
void closeFds();
|
||||
|
||||
Client& getClientByFd(int fd);
|
||||
void addUserToChannel(const std::string& nickname, const std::string& channelName, int fd);
|
||||
void sendJoinMsg(const std::string& nickname, const std::string& channelName, int fd);
|
||||
void ping(const std::string& command, int fd);
|
||||
|
||||
// User authentication
|
||||
void processPassword(Client& client, const std::string& command, int fd);
|
||||
void processNickCmd(Client& client, const std::string& command, int fd);
|
||||
void processUserCmd(Client& client, const std::string& command, int fd);
|
||||
void welcome(const std::string& nickname, int fd);
|
||||
|
||||
// Commands
|
||||
void processJoinCmd(Client& client, const std::string& command, int fd);
|
||||
void processPrivmsgCmd(Client& client, const std::string& command, int fd);
|
||||
void processQuitCmd(int fd);
|
||||
void processKickCmd(Client& client, const std::string& command, int fd);
|
||||
void processTopicCmd(Client& client, const std::string& command, int fd);
|
||||
void processInviteCmd(Client& client, const std::string& command, int fd);
|
||||
void processModeCmd(Client& client, const std::string& command, int fd);
|
||||
void processBotCmd(Client& client, const std::string& command, int fd);
|
||||
|
||||
// Channel modes
|
||||
void handleOpPrivilege(const std::string& nick, const std::string& channelName, const std::string& mode, int fd);
|
||||
void handleTopicRestriction(const std::string& nick, const std::string& channelName, const std::string& mode, int fd);
|
||||
void handleInviteOnly(const std::string& nick, const std::string& channelName, const std::string& mode, int fd);
|
||||
void handleChannelKey(std::string& nick, const std::string& channelName, const std::string& mode, int fd);
|
||||
void handleChannelLimit(const std::string& nick, const std::string& channelName, const std::string& mode, int fd);
|
||||
};
|
||||
|
||||
int randomInRange(int min, int max);
|
||||
|
Reference in New Issue
Block a user