aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpnull.cpp
blob: 658f5183131fc273415bb2093778439d592ed09b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright Epic Games, Inc. All Rights Reserved.

#include "httpnull.h"

#include <zencore/logging.h>

#if ZEN_PLATFORM_WINDOWS
#	include <conio.h>
#endif

namespace zen {

HttpNullServer::HttpNullServer()
{
}

HttpNullServer::~HttpNullServer()
{
}

void
HttpNullServer::RegisterService(HttpService& Service)
{
	ZEN_UNUSED(Service);
}

int
HttpNullServer::Initialize(int BasePort)
{
	return BasePort;
}

void
HttpNullServer::Run(bool IsInteractiveSession)
{
	const bool TestMode = !IsInteractiveSession;

	int WaitTimeout = -1;
	if (!TestMode)
	{
		WaitTimeout = 1000;
	}

#if ZEN_PLATFORM_WINDOWS
	if (TestMode == false)
	{
		zen::logging::ConsoleLog().info("Zen Server running (null HTTP). Press ESC or Q to quit");
	}

	do
	{
		if (!TestMode && _kbhit() != 0)
		{
			char c = (char)_getch();

			if (c == 27 || c == 'Q' || c == 'q')
			{
				RequestApplicationExit(0);
			}
		}

		m_ShutdownEvent.Wait(WaitTimeout);
	} while (!IsApplicationExitRequested());
#else
	if (TestMode == false)
	{
		zen::logging::ConsoleLog().info("Zen Server running (null HTTP). Ctrl-C to quit");
	}

	do
	{
		m_ShutdownEvent.Wait(WaitTimeout);
	} while (!IsApplicationExitRequested());
#endif
}

void
HttpNullServer::RequestExit()
{
	m_ShutdownEvent.Set();
}

void
HttpNullServer::Close()
{
}

}  // namespace zen