2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2016-11-23 15:48:37 -05:00
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "HAL/ThreadSafeCounter.h"
|
|
|
|
|
#include "HAL/Runnable.h"
|
2017-08-30 09:37:09 -04:00
|
|
|
#include "INetworkFileServer.h"
|
|
|
|
|
#include "INetworkFileSystemModule.h"
|
2016-11-23 15:48:37 -05:00
|
|
|
|
|
|
|
|
class FInternetAddr;
|
|
|
|
|
class FSocket;
|
|
|
|
|
class ITargetPlatform;
|
2022-05-24 02:50:39 -04:00
|
|
|
namespace UE::Cook
|
|
|
|
|
{
|
|
|
|
|
class ICookOnTheFlyNetworkServer;
|
|
|
|
|
class ICookOnTheFlyClientConnection;
|
|
|
|
|
class FCookOnTheFlyRequest;
|
|
|
|
|
}
|
2017-08-30 09:37:09 -04:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
/**
|
|
|
|
|
* This class wraps the server thread and network connection
|
|
|
|
|
*/
|
|
|
|
|
class FNetworkFileServer
|
2022-05-24 02:50:39 -04:00
|
|
|
: public INetworkFileServer
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates and initializes a new instance.
|
|
|
|
|
*
|
2021-02-16 06:53:30 -04:00
|
|
|
* @param InFileServerOptions Network file server options
|
2014-03-14 14:13:41 -04:00
|
|
|
*/
|
2022-05-24 02:50:39 -04:00
|
|
|
FNetworkFileServer(FNetworkFileServerOptions InFileServerOptions, TSharedRef<UE::Cook::ICookOnTheFlyNetworkServer> InCookOnTheFlyNetworkServer);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor.
|
|
|
|
|
*/
|
|
|
|
|
~FNetworkFileServer( );
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
// INetworkFileServer interface
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-04-01 07:20:55 -04:00
|
|
|
virtual bool IsItReadyToAcceptConnections(void) const override;
|
2014-07-07 15:39:19 -04:00
|
|
|
virtual bool GetAddressList(TArray<TSharedPtr<FInternetAddr> >& OutAddresses) const override;
|
|
|
|
|
virtual FString GetSupportedProtocol() const override;
|
2015-04-01 07:20:55 -04:00
|
|
|
virtual int32 NumConnections() const override;
|
|
|
|
|
virtual void Shutdown() override;
|
2014-03-14 14:13:41 -04:00
|
|
|
private:
|
2022-05-24 02:50:39 -04:00
|
|
|
void OnClientConnected(UE::Cook::ICookOnTheFlyClientConnection& Connection);
|
|
|
|
|
void OnClientDisconnected(UE::Cook::ICookOnTheFlyClientConnection& Connection);
|
|
|
|
|
bool HandleRequest(UE::Cook::ICookOnTheFlyClientConnection& Connection, const UE::Cook::FCookOnTheFlyRequest& Request);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2021-02-16 06:53:30 -04:00
|
|
|
// File server options
|
|
|
|
|
FNetworkFileServerOptions FileServerOptions;
|
|
|
|
|
|
2022-05-24 02:50:39 -04:00
|
|
|
TSharedPtr<UE::Cook::ICookOnTheFlyNetworkServer> CookOnTheFlyServer;
|
|
|
|
|
|
|
|
|
|
// Holds all the client connections.
|
|
|
|
|
FCriticalSection ConnectionsCritical;
|
|
|
|
|
TMap<UE::Cook::ICookOnTheFlyClientConnection*, class FCookOnTheFlyNetworkFileServerConnection*> Connections;
|
2014-06-12 23:22:18 -04:00
|
|
|
};
|