-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.hpp
More file actions
93 lines (85 loc) · 3.86 KB
/
Server.hpp
File metadata and controls
93 lines (85 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef SERVER_H
#define SERVER_H
#include "Irc.hpp"
#include "Client.hpp"
#include "Channel.hpp"
extern bool shut_down;
class Server
{
private:
struct addrinfo _address;
struct addrinfo *_servinfo;
int _port;
int _fd;
int _clientFd;
std::string _password;
std::vector<Client> _clients;
std::map<std::string, Channel> _channels;
public:
Server();
Server(int _port, std::string& password);
~Server();
void setAddress();
bool fillServerInfo(char *port);
bool initServer();
void runServer();
void parseClientInfo(const std::string& buffer, int client_fd);
void parseClientInfo(Client &user, int client_fd);
int getClientFdByName(const std::string& nickname);
void handleNewConnection(std::vector<struct pollfd>& fds);
void handleClientDisconnection(std::vector<struct pollfd>& fds, size_t i, int bytes_received, const std::string &leaveMsg);
bool handleClientData(std::vector<struct pollfd>& fds, size_t i);
void handleClientWrite(std::vector<struct pollfd>& fds, size_t i);
void handleClientError(std::vector<struct pollfd>& fds, size_t i);
bool checkBuffer(const std::string& buffer);
void checkRegist(int client_fd);
std::string getPass();
std::string sendMessage(std::string &buff);
void handleCommand(Client &user, int client_fd);
void handleNick(int client_fd, const std::string& message);
void handlePass(int client_fd, const std::string& message);
void handleUser(int client_fd, const std::string& message);
void handlePing(int client_fd, const std::string& message);
void handleJoin(int client_fd, std::string& channel_name, const std::string& pass);
void handleWho(int client_fd, const std::string& message);
void handlePrivmsg(int client_fd, const std::string& message);
void handleRegistration(const std::string& cmd, int client_fd, const std::string& line);
void handleUserCommand(const std::string& cmd, std::istringstream& cmdStream, int client_fd, const std::string& line);
void makeUserList(std::string channel);
void broadcastMessageToChannel(const std::string& message, std::string channel);
void broadcastMessageToClients(const std::string& message);
std::vector<Client>::iterator getClient(int clientFd);
void checkCommandPart(std::istringstream &lineStream);
void commandPart(std::string &channelName, const std::string &msg);
bool LookClientInChannel(std::string channel);
std::string getChannelTopic(std::string channel);
void changeChannelTopic(const std::string &channel, std::string &newTopic);
void checkCommandTopic(std::istringstream &lineStream);
void commandTopic(const std::string &channelName, std::string &newTopic);
void removeClientsFromChannels(int clientFd, const std::string &msg);
void checkCommandJoin(int client_fd, std::istringstream &lineStream);
void commandQuit(std::vector<struct pollfd>& fds, size_t i, std::istringstream &msg);
void checkCommandBot(std::istringstream &lineStream);
void commandBot(std::string &channelName, const std::string &msg);
bool LookBotInChannel(std::string channel);
void JoinBot(int client_fd, const std::string& channel_name);
void PartBot(const std::string &channelName);
void PrivmsgBot(const std::string& channel, const std::string& msg);
std::string getMsg();
void handleKick(int client_fd, const std::string& message);
void handleInvite(int client_fd, const std::string& message);
void handleMode(int client_fd, const std::string& message);
bool checkUserExists(const std::string& nickname) const;
void welcome_messages(int client_fd);
class ClientFdMatcher
{
public:
ClientFdMatcher(int fd);
bool operator()(const Client &client) const;
private:
int _fd;
};
};
std::string getLower(const std::string& str);
std::string getFullMsg(std::string &msg, std::istringstream &lineStream, int size);
#endif