Files
UnrealEngineUWP/Engine/Source/Runtime/NetworkFileSystem/Private/NetworkFileServerHttp.h
Ankit Khare dc9c1d04d2 #UE4 #HTML5
#TTP 341694 disable http nfs by default for all editor platforms - enable manually when needed for time being. a recent refactor enabled it for some builds.

    -code cleanup/adhere to standards

#codereview michael.trepka

[CL 2225368 by Ankit Khare in Main branch]
2014-07-21 04:38:16 -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