Files
UnrealEngineUWP/Engine/Source/Programs/UnrealFileServer/Private/UnrealFileServer.cpp
Matthew Griffin bb70b349ce Merging CL 2804086 from //UE4/Release-4.11 to Dev-Main (//UE4/Dev-Main) to isolate copyright update
#lockdown Nick.Penwarden

[CL 2819020 by Matthew Griffin in Main branch]
2016-01-07 08:17:16 -05:00

69 lines
1.7 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "UnrealFileServer.h"
#include "DirectoryWatcherModule.h"
#include "RequiredProgramMainCPPInclude.h"
#include "NetworkFileSystem.h"
#include "SocketSubsystem.h"
IMPLEMENT_APPLICATION(UnrealFileServer, "UnrealFileServer");
/**
* Application entry point
*
* @param ArgC Command-line argument count
* @param ArgV Argument strings
*/
INT32_MAIN_INT32_ARGC_TCHAR_ARGV()
{
// start up the main loop
GEngineLoop.PreInit(ArgC, ArgV);
check(GConfig && GConfig->IsReadyForUse());
#if PLATFORM_WINDOWS
// hide the console window, if desired
if (FParse::Param(FCommandLine::Get(), TEXT("HIDDEN")))
{
ShowWindow(GetConsoleWindow(), SW_HIDE);
}
#endif
// start the listening thread
INetworkFileServer* NetworkFileServer = FModuleManager::LoadModuleChecked<INetworkFileSystemModule>("NetworkFileSystem")
.CreateNetworkFileServer(false);
// loop while the server does the rest
double LastTime = FPlatformTime::Seconds();
while (!GIsRequestingExit)
{
// let some time pass
FPlatformProcess::Sleep(1.0f);
double Now = FPlatformTime::Seconds();
float DeltaSeconds = LastTime - Now;
LastTime = Now;
// @todo: Put me into an FTicker that is created when the DW module is loaded
FDirectoryWatcherModule& DirectoryWatcherModule = FModuleManager::Get().LoadModuleChecked<FDirectoryWatcherModule>(TEXT("DirectoryWatcher"));
DirectoryWatcherModule.Get()->Tick(Now - LastTime);
GLog->FlushThreadedLogs();
LastTime = Now;
}
// shutdown the server
NetworkFileServer->Shutdown();
delete NetworkFileServer;
// Shutdown sockets layer
ISocketSubsystem::ShutdownAllSystems();
return 0;
}