#include "global.h"

HTNetServer server;

#include <conio.h>

LARGE_INTEGER lasttime;

int main(int argc, char* argv[])
{
	// Needs to be done sometime before any CoCreateInstance
	CoInitializeEx( NULL, COINIT_MULTITHREADED );

	printf("\n * Starting server: 8 Players max\n * PRESS 'q' TO QUIT\n");

	printf("\n>> Initializing and starting server...\n");
	server.Initialize();
	if (server.StartServer())
		printf(">> Server started!\n");
	else
	{
		printf(">> Could not start server!  :(\n");
		return 0;
	}

	//server.ServerThread();

	printf("Stopping server...\n");

	while (!kbhit() && server.IsServerHosting() && server.IsServerThreadRunning())
		Sleep(100);

	server.StopServer();

	printf("Server stopped.  All done!\n");

	while (kbhit())
		getch();

	printf("Press any key to exit\n");
	getch();

	return 0;
}
