2023-09-16 16:29:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "EPollManager.h"
|
|
|
|
#include "SocketManager.h"
|
|
|
|
#include "Map.h"
|
|
|
|
#include "Router.h"
|
|
|
|
#include "RequestHandler.h"
|
|
|
|
#include "MiddleWareHandler.h"
|
|
|
|
#include "Route.h"
|
|
|
|
|
|
|
|
namespace VWeb {
|
|
|
|
class Server {
|
|
|
|
public:
|
|
|
|
Server();
|
|
|
|
// Will Load SharedLibs from subdirectory
|
|
|
|
// This will allow that VWeb will run as Standalone and will load .so files
|
|
|
|
// without recompiling itself
|
|
|
|
void LoadSharedLibs();
|
|
|
|
void Start();
|
|
|
|
void Join() { m_WorkerThread->join(); }
|
|
|
|
void Stop() { m_IsExit = true; }
|
|
|
|
Ref<Router> &GetRouter() { return m_Router; }
|
|
|
|
Ref<ServerConfig> &GetServerConfig() { return m_ServerConfig; }
|
2024-10-14 19:43:30 +02:00
|
|
|
Ref<RequestHandler> &GetRequestHandler() { return m_RequestHandler; }
|
2023-09-16 16:29:03 +02:00
|
|
|
|
|
|
|
Ref<MiddleWareHandler> &Middleware();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void Execute();
|
|
|
|
void OutgoingExecute(epoll_event &event);
|
|
|
|
void IncomingExecute(epoll_event &event);
|
|
|
|
void HandleRequestReading(epoll_event &event);
|
|
|
|
void CreateRequest(int sockID);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Ref<Router> m_Router;
|
|
|
|
Ref<ServerConfig> m_ServerConfig;
|
|
|
|
Ref<RequestHandler> m_RequestHandler;
|
|
|
|
SafeMap<int, Accept> m_RawRequest{60000};
|
|
|
|
SafeMap<int, SendData> m_OutRequest{60000};
|
|
|
|
Ref<std::thread> m_WorkerThread;
|
|
|
|
std::mutex m_Mutex;
|
|
|
|
bool m_IsExit{false};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend RequestHandler;
|
|
|
|
};
|
2024-10-14 19:43:30 +02:00
|
|
|
}
|