diff options
| author | Stefan Boberg <[email protected]> | 2023-10-11 10:43:11 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-11 10:43:11 +0200 |
| commit | b124b83b31f368231fa417213e9ecf7df69b2d33 (patch) | |
| tree | 6674550ae05d08d474d629d6790ecdb1e1782fda /src/zenhttp/httpasio.cpp | |
| parent | updated plugin API class names (#462) (diff) | |
| download | zen-b124b83b31f368231fa417213e9ecf7df69b2d33.tar.xz zen-b124b83b31f368231fa417213e9ecf7df69b2d33.zip | |
hide HttpAsioServer interface behind factory function (#463)
Diffstat (limited to 'src/zenhttp/httpasio.cpp')
| -rw-r--r-- | src/zenhttp/httpasio.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/zenhttp/httpasio.cpp b/src/zenhttp/httpasio.cpp index 562f75e3d..f23e0edb1 100644 --- a/src/zenhttp/httpasio.cpp +++ b/src/zenhttp/httpasio.cpp @@ -929,6 +929,27 @@ HttpAsioServerImpl::RouteRequest(std::string_view Url) ////////////////////////////////////////////////////////////////////////// namespace zen { + +class HttpAsioServer : public HttpServer +{ +public: + HttpAsioServer(unsigned int ThreadCount); + ~HttpAsioServer(); + + virtual void RegisterService(HttpService& Service) override; + virtual int Initialize(int BasePort) override; + virtual void Run(bool IsInteractiveSession) override; + virtual void RequestExit() override; + virtual void Close() override; + +private: + Event m_ShutdownEvent; + int m_BasePort = 0; + unsigned int m_ThreadCount = 0; + + std::unique_ptr<asio_http::HttpAsioServerImpl> m_Impl; +}; + HttpAsioServer::HttpAsioServer(unsigned int ThreadCount) : m_ThreadCount(ThreadCount != 0 ? ThreadCount : Max(std::thread::hardware_concurrency(), 8u)) , m_Impl(std::make_unique<asio_http::HttpAsioServerImpl>()) @@ -1021,4 +1042,10 @@ HttpAsioServer::RequestExit() m_ShutdownEvent.Set(); } +Ref<HttpServer> +CreateHttpAsioServer(unsigned int ThreadCount) +{ + return Ref<HttpServer>{new HttpAsioServer(ThreadCount)}; +} + } // namespace zen |