Files
UnrealEngineUWP/Engine/Source/Runtime/NetworkFileSystem/Private/NetworkFileSystemModule.cpp
Wojciech Krywult 7b5537cc26 CookOnTheFly (platform protocol): Editor: Added support of the platform-specific transport communication protocols to the editor and use it in the cooking server.
This change allows the cooking server to communicate with clients using platform-specific communication protocols instead of TCP (the default).

This new mode is activated by adding '-platformprotocol' command-line parameter when starting the cooking server (in addition to the usual '-cookonthefly').

The new functionality is included in FNetworkFileServerPlatformProtocol, which is a variant of the preexisting FNetworkFileServer but using ITargetDevice/ITargetDeviceSocket interfaces instead of traditional sockets.

Direct communication with targets is only supported on some platforms, which can be checked by calling ITargetPlatform::SupportsFeature(ETargetPlatformFeatures::DirectDataExchange).

#rb jeff.newquist
#preflight 62166a4237178b0175af6269

[CL 19094838 by Wojciech Krywult in ue5-main branch]
2022-02-23 12:54:09 -05:00

75 lines
2.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "CoreMinimal.h"
#include "Misc/CommandLine.h"
#include "Modules/ModuleManager.h"
#include "INetworkFileSystemModule.h"
#include "NetworkFileSystemLog.h"
#include "NetworkFileServer.h"
#include "NetworkFileServerHttp.h"
#include "NetworkFileServerPlatformProtocol.h"
#include "Interfaces/ITargetPlatformManagerModule.h"
DEFINE_LOG_CATEGORY(LogFileServer);
/**
* Implements the NetworkFileSystem module.
*/
class FNetworkFileSystemModule
: public INetworkFileSystemModule
{
public:
// INetworkFileSystemModule interface
virtual INetworkFileServer* CreateNetworkFileServer( bool bLoadTargetPlatforms, int32 Port, FNetworkFileDelegateContainer NetworkFileDelegateContainer, const ENetworkFileServerProtocol Protocol ) const
{
FNetworkFileServerOptions FileServerOptions;
FileServerOptions.Protocol = Protocol;
FileServerOptions.Port = Port;
FileServerOptions.Delegates = MoveTemp(NetworkFileDelegateContainer);
FileServerOptions.bRestrictPackageAssetsToSandbox = false;
return CreateNetworkFileServer(MoveTemp(FileServerOptions), bLoadTargetPlatforms);
}
virtual INetworkFileServer* CreateNetworkFileServer(FNetworkFileServerOptions FileServerOptions, bool bLoadTargetPlatforms) const override
{
if (bLoadTargetPlatforms)
{
ITargetPlatformManagerModule& TPM = GetTargetPlatformManagerRef();
// if we didn't specify a target platform then use the entire target platform list (they could all be possible!)
FString Platforms;
if (FParse::Value(FCommandLine::Get(), TEXT("TARGETPLATFORM="), Platforms))
{
FileServerOptions.TargetPlatforms = TPM.GetActiveTargetPlatforms();
}
else
{
FileServerOptions.TargetPlatforms = TPM.GetTargetPlatforms();
}
}
switch (FileServerOptions.Protocol)
{
#if ENABLE_HTTP_FOR_NFS
case NFSP_Http:
return new FNetworkFileServerHttp(MoveTemp(FileServerOptions));
#endif
case NFSP_Tcp:
return new FNetworkFileServer(MoveTemp(FileServerOptions));
case NFSP_Platform:
return new FNetworkFileServerPlatformProtocol(MoveTemp(FileServerOptions));
}
return nullptr;
}
};
IMPLEMENT_MODULE(FNetworkFileSystemModule, NetworkFileSystem);