2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class wraps the server thread and network connection
|
|
|
|
|
*/
|
|
|
|
|
class FNetworkFileServer
|
|
|
|
|
: public FRunnable
|
|
|
|
|
, public INetworkFileServer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates and initializes a new instance.
|
|
|
|
|
*
|
2014-06-12 23:22:18 -04:00
|
|
|
* @param InPort The port number to bind to (0 = any available port).
|
|
|
|
|
* @param InFileRequestDelegate
|
2014-03-14 14:13:41 -04:00
|
|
|
*/
|
2014-04-23 18:33:50 -04:00
|
|
|
FNetworkFileServer( int32 InPort, const FFileRequestDelegate* InFileRequestDelegate,
|
|
|
|
|
const FRecompileShadersDelegate* InRecompileShadersDelegate, const TArray<ITargetPlatform*>& InActiveTargetPlatforms );
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor.
|
|
|
|
|
*/
|
|
|
|
|
~FNetworkFileServer( );
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
// FRunnable Interface
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual bool Init( ) override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual uint32 Run( ) override;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual void Stop( ) override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-06-12 17:02:52 -04:00
|
|
|
StopRequested.Set(true);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual void Exit( ) override;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
|
|
// Holds the server (listening) socket.
|
|
|
|
|
FSocket* Socket;
|
|
|
|
|
|
|
|
|
|
// Holds the server thread object.
|
|
|
|
|
FRunnableThread* Thread;
|
|
|
|
|
|
|
|
|
|
// Holds the list of all client connections.
|
2014-06-12 17:02:52 -04:00
|
|
|
TArray< class FNetworkFileServerClientConnectionThreaded*> Connections;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-06-12 17:02:52 -04:00
|
|
|
// Holds a flag indicating whether the thread should stop executing
|
|
|
|
|
FThreadSafeCounter StopRequested;
|
|
|
|
|
|
|
|
|
|
// Is the Listner thread up and running.
|
|
|
|
|
FThreadSafeCounter Running;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// Holds a delegate to be invoked on every sync request.
|
|
|
|
|
FFileRequestDelegate FileRequestDelegate;
|
|
|
|
|
|
|
|
|
|
// Holds a delegate to be invoked when a client requests a shader recompile.
|
|
|
|
|
FRecompileShadersDelegate RecompileShadersDelegate;
|
|
|
|
|
|
2014-04-23 18:33:50 -04:00
|
|
|
// cached copy of the active target platforms (if any)
|
|
|
|
|
const TArray<ITargetPlatform*> ActiveTargetPlatforms;
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
// Holds the address that the server is bound to.
|
|
|
|
|
TSharedPtr<FInternetAddr> ListenAddr;
|
2014-06-12 23:22:18 -04:00
|
|
|
};
|