-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnectionSocket.hpp
61 lines (41 loc) · 1.05 KB
/
ConnectionSocket.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
//
// Created by mtriston on 30.04.2021.
//
#ifndef WEBSERV__CONNECTIONSOCKET_HPP_
#define WEBSERV__CONNECTIONSOCKET_HPP_
class Config_parser;
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include <iostream>
#include "ASocket.hpp"
#include "Response.hpp"
#include "Request.hpp"
enum session_states {
READ_REQUEST,
GENERATE_RESPONSE,
SEND_RESPONSE,
CLOSE_CONNECTION
};
class ConnectionSocket : public ASocket {
public:
ConnectionSocket(int socket, int port, Config_parser *parser);
~ConnectionSocket();
session_states getState() const;
void readRequest();
void generateResponse();
const std::string &getBuffer() const;
void sendResponse();
bool _isRequestRead();
int fillFdSet(fd_set *readfds, fd_set *writefds);
bool isReady(fd_set *readfds, fd_set *writefds);
IWork *getWork();
private:
ConnectionSocket();
ConnectionSocket(ConnectionSocket const &);
ConnectionSocket &operator=(ConnectionSocket const &);
enum session_states _state;
std::string _buffer;
Response *_response;
};
#endif //WEBSERV__CONNECTIONSOCKET_HPP_