-
Notifications
You must be signed in to change notification settings - Fork 0
/
socket.hpp
85 lines (65 loc) · 1.56 KB
/
socket.hpp
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
#ifndef SOCKET_HPP
#define SOCKET_HPP
#include <iostream>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <string.h>
#include <string>
#include <poll.h>
#include <sstream>
#include <signal.h>
#include <cstdlib>
#include <vector>
#include <netdb.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <ctime>
using namespace std;
// #include "user.hpp"
// #include "CommanHandler.hpp"
// class Channel;
// class User;
// class Message;
// class CommanHandler;
class Socket
{
private:
int _port;
string _pass;
vector<User*> _userList;
vector<std::string> parseIncomingMsg(std::string buffer);
public:
int fd_server;
string msg;
string serverName;
static bool active;
struct pollfd clients[1024];
// std::vector<Channel*> _channelList;
/* Costructors and Deconstructors */
Socket();
~Socket();
Socket(string pass, int port);
/* Getters and Setters */
void setPass(std::string pass);
std::string getPass() const;
/* Actions */
int createServer();
void initClient();
void pollLoop();
void pingClient();
int readInput(int client_no);
int acceptCall();
/*
void killUser(User * user);
Channel* findChannel(std::string name); // finds a channel by name
void addChannel(Channel* newChannel);
User* findByFd(int clientFd); // finds user by FD
User* findByNick(std::string nick); // finds user by nickname
bool free_everything();
// CommanHandler* handler;
*/
};
#endif