diff options
| author | Stefan Boberg <[email protected]> | 2021-09-09 16:29:24 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-09 16:29:24 +0200 |
| commit | a73862b954209fd1adce0f07b8f80b8cf27f2486 (patch) | |
| tree | 07f2898998f884e871c47a2979dfb01434443584 /zenhttp/httpnull.cpp | |
| parent | Factored out http server related code into zenhttp module since it feels out ... (diff) | |
| download | zen-a73862b954209fd1adce0f07b8f80b8cf27f2486.tar.xz zen-a73862b954209fd1adce0f07b8f80b8cf27f2486.zip | |
Added compile time logic to toggle http.sys / null http implementation on/off
Diffstat (limited to 'zenhttp/httpnull.cpp')
| -rw-r--r-- | zenhttp/httpnull.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/zenhttp/httpnull.cpp b/zenhttp/httpnull.cpp new file mode 100644 index 000000000..571c4241c --- /dev/null +++ b/zenhttp/httpnull.cpp @@ -0,0 +1,65 @@ +#include "httpnull.h" + +#include <zencore/logging.h> +#include <conio.h> + +namespace zen { + +HttpNullServer::HttpNullServer() +{ +} + +HttpNullServer::~HttpNullServer() +{ +} + +void +HttpNullServer::RegisterService(HttpService& Service) +{ + ZEN_UNUSED(Service); +} + +void +HttpNullServer::Initialize(int BasePort) +{ + ZEN_UNUSED(BasePort); +} + +void +HttpNullServer::Run(bool TestMode) +{ + if (TestMode == false) + { + zen::logging::ConsoleLog().info("Zen Server running (null HTTP). Press ESC or Q to quit"); + } + + do + { + int WaitTimeout = -1; + + if (!TestMode) + { + WaitTimeout = 1000; + } + + if (!TestMode && _kbhit() != 0) + { + char c = (char)_getch(); + + if (c == 27 || c == 'Q' || c == 'q') + { + RequestApplicationExit(0); + } + } + + m_ShutdownEvent.Wait(WaitTimeout); + } while (!IsApplicationExitRequested()); +} + +void +HttpNullServer::RequestExit() +{ + m_ShutdownEvent.Set(); +} + +} // namespace zen |