Files
UnrealEngineUWP/Engine/Source/Runtime/NetworkFileSystem/Private/NetworkFileServer.h
CarlMagnus Nordin 0282a5aef6 Unified Zen and legacy COTF network protocols.
*Reduces code duplication
*Enables the same ODSC flow to be used for both COTF variants
*The client will now autodetect if it should run in Zen mode or not
#rb pj.kack,per.larsson
#preflight 628c79bdf057b981ca479b3e

[CL 20344832 by CarlMagnus Nordin in ue5-main branch]
2022-05-24 02:50:39 -04:00

62 lines
1.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "HAL/ThreadSafeCounter.h"
#include "HAL/Runnable.h"
#include "INetworkFileServer.h"
#include "INetworkFileSystemModule.h"
class FInternetAddr;
class FSocket;
class ITargetPlatform;
namespace UE::Cook
{
class ICookOnTheFlyNetworkServer;
class ICookOnTheFlyClientConnection;
class FCookOnTheFlyRequest;
}
/**
* This class wraps the server thread and network connection
*/
class FNetworkFileServer
: public INetworkFileServer
{
public:
/**
* Creates and initializes a new instance.
*
* @param InFileServerOptions Network file server options
*/
FNetworkFileServer(FNetworkFileServerOptions InFileServerOptions, TSharedRef<UE::Cook::ICookOnTheFlyNetworkServer> InCookOnTheFlyNetworkServer);
/**
* Destructor.
*/
~FNetworkFileServer( );
// INetworkFileServer interface
virtual bool IsItReadyToAcceptConnections(void) const override;
virtual bool GetAddressList(TArray<TSharedPtr<FInternetAddr> >& OutAddresses) const override;
virtual FString GetSupportedProtocol() const override;
virtual int32 NumConnections() const override;
virtual void Shutdown() override;
private:
void OnClientConnected(UE::Cook::ICookOnTheFlyClientConnection& Connection);
void OnClientDisconnected(UE::Cook::ICookOnTheFlyClientConnection& Connection);
bool HandleRequest(UE::Cook::ICookOnTheFlyClientConnection& Connection, const UE::Cook::FCookOnTheFlyRequest& Request);
// File server options
FNetworkFileServerOptions FileServerOptions;
TSharedPtr<UE::Cook::ICookOnTheFlyNetworkServer> CookOnTheFlyServer;
// Holds all the client connections.
FCriticalSection ConnectionsCritical;
TMap<UE::Cook::ICookOnTheFlyClientConnection*, class FCookOnTheFlyNetworkFileServerConnection*> Connections;
};