92 lines
951 B
C++
92 lines
951 B
C++
#ifndef headerfile_libscorpiohttpserver_src_server_h
|
|
#define headerfile_libscorpiohttpserver_src_server_h
|
|
|
|
|
|
#include <sys/select.h>
|
|
#include "client.h"
|
|
#include "headers_parser.h"
|
|
|
|
|
|
|
|
class Server
|
|
{
|
|
public:
|
|
|
|
|
|
Server();
|
|
virtual ~Server();
|
|
|
|
|
|
void CloseMainSocket();
|
|
void CloseClientSockets();
|
|
void Close();
|
|
|
|
void PrepareMainSocket();
|
|
void Wait();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<Client> client_tab;
|
|
int main_socket;
|
|
fd_set read_set, write_set;
|
|
bool close_server;
|
|
HeadersParser headers_parser;
|
|
|
|
|
|
int AddSocketsToSet();
|
|
void AddNewClient();
|
|
|
|
void ReadWriteToClients();
|
|
void ReadInputFromClient(Client & client);
|
|
void WriteOutputToClient(Client & client);
|
|
|
|
void CheckHeaders(Client & client, size_t input_buffer_index);
|
|
|
|
|
|
virtual bool SelectMethodName(Client & client, const std::wstring & method_name);
|
|
|
|
|
|
//void RemoveClientSocket(int client_socket);
|
|
|
|
virtual void CreateAnswer(Client & client);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|