mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-29 21:38:00 +03:00
feat: refactor for consistency, some additions
This commit is contained in:
@@ -7,37 +7,57 @@
|
||||
#include "Socket.hpp"
|
||||
#include "parse.hpp"
|
||||
|
||||
|
||||
class Client;
|
||||
|
||||
class Server
|
||||
{
|
||||
private:
|
||||
int _port;
|
||||
int _epoll_fd;
|
||||
int _client;
|
||||
struct epoll_event _events[MAX_CLIENT];
|
||||
struct sockaddr_in _addres;
|
||||
std::string _ip;
|
||||
std::vector<ServerConfig *> _configs;
|
||||
void add_to_epoll_list(int fd, unsigned int ep_events);
|
||||
private:
|
||||
int _port;
|
||||
int _epoll_fd;
|
||||
int _client;
|
||||
struct epoll_event _events[MAX_CLIENT];
|
||||
struct sockaddr_in _addres;
|
||||
std::string _ip;
|
||||
std::vector<ServerConfig *> _configs;
|
||||
void add_to_epoll_list(int fd, unsigned int ep_events);
|
||||
|
||||
private:
|
||||
void checkError(int fd, std::string str);
|
||||
void sendFile(std::string str);
|
||||
void sendClient(Client head, int);
|
||||
void sendResponse(Client head, int);
|
||||
void setNonBlock(int fd);
|
||||
void sendData(Client &client, int fd);
|
||||
void readSocket(int fd, std::map<int, Client> &client_map);
|
||||
public:
|
||||
Server();
|
||||
Server(std::string path);
|
||||
static void print_epoll_events(unsigned int events);
|
||||
|
||||
void readConfig(void);
|
||||
void setupConfig(void);
|
||||
void start(void);
|
||||
void end(void);
|
||||
~Server();
|
||||
private:
|
||||
void checkError(int fd, std::string str);
|
||||
void sendFile(std::string str);
|
||||
void sendClient(Client head, int);
|
||||
void sendResponse(Client head, int);
|
||||
void setNonBlock(int fd);
|
||||
void sendData(Client &client, int fd);
|
||||
void readSocket(Client &client, int fd);
|
||||
|
||||
enum e_req_status
|
||||
{
|
||||
READING,
|
||||
WRITING,
|
||||
ENDED
|
||||
};
|
||||
|
||||
typedef struct s_client_status
|
||||
{
|
||||
int fd;
|
||||
int serverfd;
|
||||
size_t readn;
|
||||
size_t left;
|
||||
enum e_req_status req_status;
|
||||
} t_client_status;
|
||||
|
||||
public:
|
||||
Server();
|
||||
Server(std::string path);
|
||||
|
||||
void readConfig(void);
|
||||
void setupConfig(void);
|
||||
void start(void);
|
||||
void end(void);
|
||||
~Server();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user