#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 &GetRouter() { return m_Router; } Ref &GetServerConfig() { return m_ServerConfig; } void RemoveRoute(const std::string &path) const; Ref &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 m_Router; Ref m_ServerConfig; Ref m_RequestHandler; SafeMap m_RawRequest{60000}; SafeMap m_OutRequest{60000}; Ref m_WorkerThread; std::mutex m_Mutex; bool m_IsExit{false}; protected: friend RequestHandler; }; }