diff options
| author | Stefan Boberg <[email protected]> | 2021-10-14 19:07:14 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-14 19:07:14 +0200 |
| commit | 2b71d6a8d57c773bc7734b253a1ffd1e47162184 (patch) | |
| tree | c0c70f9f2f8b9dc895080aac9f7de1140c56ebf0 /zenhttp/httpuws.cpp | |
| parent | Merge branch 'main' of https://github.com/EpicGames/zen (diff) | |
| download | zen-2b71d6a8d57c773bc7734b253a1ffd1e47162184.tar.xz zen-2b71d6a8d57c773bc7734b253a1ffd1e47162184.zip | |
asio HTTP implementation (#23)
asio-based HTTP implementation
Diffstat (limited to 'zenhttp/httpuws.cpp')
| -rw-r--r-- | zenhttp/httpuws.cpp | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/zenhttp/httpuws.cpp b/zenhttp/httpuws.cpp deleted file mode 100644 index 2a6950532..000000000 --- a/zenhttp/httpuws.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - -#include "httpuws.h" - -#pragma warning(push) -#pragma warning(disable : 4244 4324 4267 4458 4706) -#include <uwebsockets/App.h> -#pragma warning(pop) - -#include <conio.h> -#include <zencore/logging.h> - -#if ZEN_PLATFORM_WINDOWS -# pragma comment(lib, "Iphlpapi.lib") -# pragma comment(lib, "userenv.lib") -#endif - -namespace zen { - -HttpUwsServer::HttpUwsServer() -{ -} - -HttpUwsServer::~HttpUwsServer() -{ -} - -void -HttpUwsServer::RegisterService(HttpService& Service) -{ - ZEN_UNUSED(Service); -} - -void -HttpUwsServer::Initialize(int BasePort) -{ - m_BasePort = BasePort; -} - -void -HttpUwsServer::Run(bool IsInteractive) -{ - const bool TestMode = !IsInteractive; - - if (TestMode == false) - { - zen::logging::ConsoleLog().info("Zen Server running (uWS HTTP). Press ESC or Q to quit"); - } - - ::uWS::App() - .any("/*", - [](uWS::HttpResponse<false>* res, uWS::HttpRequest* req) { - res->onData([=](std::string_view Data, bool fin) { - ZEN_UNUSED(Data); - if (fin) - res->end("Hello world!"); - }); - - res->onAborted([&] {}); - ZEN_UNUSED(req); - }) - .listen(m_BasePort, [](auto* listen_socket) { ZEN_UNUSED(listen_socket); }) - .run(); - - 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 -HttpUwsServer::RequestExit() -{ - m_ShutdownEvent.Set(); -} - -} // namespace zen |