diff options
| author | Martin Ridgers <[email protected]> | 2021-10-25 10:11:07 +0200 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-10-25 10:11:07 +0200 |
| commit | b8699caf508f8060559a88b67d2b9ddabf631f6a (patch) | |
| tree | 3ebf494d18d18b8963a4f91a256ab31e3ea79178 /zenhttp/httpasio.cpp | |
| parent | Made httpsys xmake option Windows only (diff) | |
| download | zen-b8699caf508f8060559a88b67d2b9ddabf631f6a.tar.xz zen-b8699caf508f8060559a88b67d2b9ddabf631f6a.zip | |
HttpAsioServer::Run() implementation for POSIX platforms
Diffstat (limited to 'zenhttp/httpasio.cpp')
| -rw-r--r-- | zenhttp/httpasio.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/zenhttp/httpasio.cpp b/zenhttp/httpasio.cpp index ea84e7e87..061cd607a 100644 --- a/zenhttp/httpasio.cpp +++ b/zenhttp/httpasio.cpp @@ -9,7 +9,9 @@ #include <memory_resource> ZEN_THIRD_PARTY_INCLUDES_START -#include <conio.h> +#if ZEN_PLATFORM_WINDOWS +# include <conio.h> +#endif #include <http_parser.h> #include <asio.hpp> ZEN_THIRD_PARTY_INCLUDES_END @@ -1157,6 +1159,13 @@ HttpAsioServer::Run(bool IsInteractive) { const bool TestMode = !IsInteractive; + int WaitTimeout = -1; + if (!TestMode) + { + WaitTimeout = 1000; + } + +#if ZEN_PLATFORM_WINDOWS if (TestMode == false) { zen::logging::ConsoleLog().info("Zen Server running (asio HTTP). Press ESC or Q to quit"); @@ -1164,13 +1173,6 @@ HttpAsioServer::Run(bool IsInteractive) do { - int WaitTimeout = -1; - - if (!TestMode) - { - WaitTimeout = 1000; - } - if (!TestMode && _kbhit() != 0) { char c = (char)_getch(); @@ -1183,6 +1185,18 @@ HttpAsioServer::Run(bool IsInteractive) m_ShutdownEvent.Wait(WaitTimeout); } while (!IsApplicationExitRequested()); +#else + if (TestMode == false) + { + zen::logging::ConsoleLog().info("Zen Server running (asio HTTP). Ctrl-C to quit"); + } + + do + { + m_ShutdownEvent.Wait(WaitTimeout); + } + while (!IsApplicationExitRequested()); +#endif } void |