-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathServer.hpp
More file actions
68 lines (60 loc) · 1.63 KB
/
Server.hpp
File metadata and controls
68 lines (60 loc) · 1.63 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
#ifndef SERVER_HPP
# define SERVER_HPP
# include <sys/types.h>
# include <sys/socket.h>
# include <sys/select.h>
# include <netdb.h>
# include <list>
# include <string>
# include <iostream>
# include <exception>
# include <cstring>
# include <cerrno>
# include <unistd.h>
# include <fcntl.h>
# include "User.hpp"
# include "Channel.hpp"
#include "Command.hpp"
class Server
{
public:
typedef std::list<User *>::iterator u_iterator;
typedef std::list<Channel *>::iterator c_iterator;
private:
fd_set _master;
int _max;
int _listener;
std::string _password;
std::list<User *> _users;
std::list<Channel *> _channels;
Server &operator=(const Server &rhs);
Server(const Server & other);
public:
//Coplien
Server(void);
~Server(void);
//Start configuration
void start(const std::string &port);
//User and channel lists management
void addUser(void);
User *getSocketUser(int socket);
User *getUserNick(const std::string &str);
std::list<User *> &getUsers(void);
void deleteUser(const std::string &nick);
void deleteUser(int fd);
void addChannel(Channel *chann);
Channel *getChannelName(const std::string &str);
std::list <Channel *> &getChannels(void);
void deleteChannel(const std::string &name);
//Get(set)ters
void setMax(int max);
int getMax(void) const;
int getListener(void) const;
void setMaster(fd_set set);
fd_set &getMaster(void);
void setPassword(const std::string &password);
std::string getPassword(void) const;
//Message
bool are_in_same_channels(int sender, int receiver);
};
#endif