Files
UnrealEngineUWP/Engine/Source/Runtime/NetworkFileSystem/Private/NetworkFileServerHttp.h
Daniel Lamb 7184ecc682 Seperated the support for tcp and http transports when using file serving so that they can be used at the same time.
#codereview Peter.Sauerbrei
#codereview Ankit.Khare

[CL 2170710 by Daniel Lamb in Main branch]
2014-07-07 15:39:19 -04:00

80 lines
2.5 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
NetworkFileServerHttp.h: Declares the NetworkFileServerHttp class.
This allows NFS to use a http server for serving Unreal Files.
=============================================================================*/
#pragma once
#if ENABLE_HTTP_FOR_NFS
class FNetworkFileServerHttp
: public INetworkFileServer // It is a NetworkFileServer
, private FRunnable // Also spins up a thread but others don't need to know.
{
public:
FNetworkFileServerHttp(int32 InPort, const FFileRequestDelegate* InFileRequestDelegate,
const FRecompileShadersDelegate* InRecompileShadersDelegate, const TArray<ITargetPlatform*>& InActiveTargetPlatforms );
// INetworkFileServer Interface.
virtual bool IsItReadyToAcceptConnections(void) const;
virtual FString GetSupportedProtocol() const override;
virtual bool GetAddressList(TArray<TSharedPtr<FInternetAddr> >& OutAddresses) const override;
virtual int32 NumConnections() const;
virtual void Shutdown();
virtual ~FNetworkFileServerHttp();
// static functions. callbacks for libwebsocket.
static int CallBack_HTTP( struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
void *in, size_t len);
private:
//FRunnable Interface.
virtual bool Init();
virtual uint32 Run();
virtual void Stop();
virtual void Exit();
static void Process (FArchive&, FArchive&, FNetworkFileServerHttp* );
// factory method for creating a new Client Connection.
FNetworkFileServerClientConnection* CreateNewConnection();
// 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;
// cached copy of the active target platforms (if any)
const TArray<ITargetPlatform*> ActiveTargetPlatforms;
// libwebsocket context. All access to the library happens via this context.
struct libwebsocket_context *context;
// Service Http connections on this thread.
FRunnableThread* WorkerThread;
// port on which this http server runs.
int32 Port;
// used to send simple message.
FThreadSafeCounter StopRequested;
// Has successfully Initialized;
FThreadSafeCounter Ready;
// Clients being served.
TMap< FGuid, FNetworkFileServerClientConnection* > RequestHandlers;
};
#endif