Compare commits
1 Commits
new/API_Ga
...
4121a3925f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4121a3925f |
@@ -2,9 +2,9 @@
|
||||
CommonUI.Debug.CheckGameViewportClientValid=0
|
||||
|
||||
[/Script/EngineSettings.GameMapsSettings]
|
||||
GameDefaultMap=/Game/Maps/StartupMap.StartupMap
|
||||
EditorStartupMap=/Game/Maps/StartupMap.StartupMap
|
||||
GlobalDefaultGameMode=/Game/Blueprints/Game/BP_ShooterGameModeBase.BP_ShooterGameModeBase_C
|
||||
GameDefaultMap=/Game/ThirdPerson/Maps/ThirdPersonMap.ThirdPersonMap
|
||||
EditorStartupMap=/Game/ThirdPerson/Maps/ThirdPersonMap.ThirdPersonMap
|
||||
GlobalDefaultGameMode=/Game/Blueprints/Game/BP_ShooterGameMode.BP_ShooterGameMode_C
|
||||
ServerDefaultMap=/Game/ThirdPerson/Maps/ThirdPersonMap.ThirdPersonMap
|
||||
|
||||
[/Script/WindowsTargetPlatform.WindowsTargetSettings]
|
||||
@@ -186,4 +186,3 @@ DefaultPort=7777
|
||||
+EnumRedirects=(OldName="/Script/FPSTemplate.EvalidationError",NewName="/Script/FPSTemplate.EValidationError")
|
||||
+FunctionRedirects=(OldName="/Script/FPSTemplate.GameLiftValidators.LogValidataErrorMessage",NewName="/Script/FPSTemplate.GameLiftValidators.LogValidationErrorMessage")
|
||||
;+PropertyRedirects=(OldName="/Script/FPSTemplate.CommandLineArgs.Arguments",NewName="/Script/FPSTemplate.CommandLineArgs.CmdArguments")
|
||||
|
||||
|
||||
Binary file not shown.
BIN
Content/Blueprints/Game/BP_ShooterGameMode.uasset
Normal file
BIN
Content/Blueprints/Game/BP_ShooterGameMode.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,11 +12,6 @@
|
||||
"Engine",
|
||||
"UMG"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "DedicatedServers",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "Default"
|
||||
}
|
||||
],
|
||||
"Plugins": [
|
||||
@@ -58,6 +53,10 @@
|
||||
{
|
||||
"Name": "PerforceSourceControl",
|
||||
"Enabled": false
|
||||
},
|
||||
{
|
||||
"Name": "GameLiftPlugin",
|
||||
"Enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
using System.IO;
|
||||
using UnrealBuildTool;
|
||||
using System.Linq;
|
||||
|
||||
public class DedicatedServers : ModuleRules
|
||||
{
|
||||
public DedicatedServers(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[]
|
||||
{
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"GameplayTags",
|
||||
"HTTP"
|
||||
});
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[]
|
||||
{
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
"OpenSSL",
|
||||
"UMG",
|
||||
"Json",
|
||||
"JsonUtilities"
|
||||
});
|
||||
|
||||
// Adds in the plugin for GameLiftServerSDK if it is the server build.
|
||||
|
||||
if (Target.Type == TargetType.Server)
|
||||
{
|
||||
PublicDependencyModuleNames.Add("GameLiftServerSDK");
|
||||
}
|
||||
else
|
||||
{
|
||||
PublicDefinitions.Add("WITH_GAMELIFT=0");
|
||||
}
|
||||
bEnableExceptions = true;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "DedicatedServers.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
IMPLEMENT_MODULE( FDefaultModuleImpl, DedicateServers );
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogDedicatedServers);
|
||||
@@ -1,7 +0,0 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogDedicatedServers, Log, All)
|
||||
@@ -1,11 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Data/API/APIData.h"
|
||||
|
||||
FString UAPIData::GetAPIEndpoint(const FGameplayTag& APIEndpoint)
|
||||
{
|
||||
const FString ResourceName = Resources.FindChecked(APIEndpoint);
|
||||
|
||||
return InvokeUrl + "/" + Stage + "/" + ResourceName;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
#include "GameplayTags/DedicatedServersTags.h"
|
||||
|
||||
namespace DedicatedServersTags
|
||||
{
|
||||
namespace GameSessionsAPI
|
||||
{
|
||||
UE_DEFINE_GAMEPLAY_TAG_COMMENT(ListFleets, "DedicatedServersTags.GameSessionsAPI.ListFleets", "List Fleets resource on the Game Session Resource")
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/API/GameSessions/JoinGame.h"
|
||||
@@ -1,4 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/API/ListFleets/FleetId.h"
|
||||
@@ -1,4 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/API/ListFleets/ListFleetsBox.h"
|
||||
@@ -1,48 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/API_Test/APITestManager.h"
|
||||
#include "HttpModule.h"
|
||||
#include "JsonObjectConverter.h"
|
||||
#include "Data/API/APIData.h"
|
||||
#include "DedicatedServers/DedicatedServers.h"
|
||||
#include "GameplayTags/DedicatedServersTags.h"
|
||||
#include "Interfaces/IHttpResponse.h"
|
||||
#include "UI/HTTP/HTTPRequestTypes.h"
|
||||
|
||||
void UAPITestManager::ListFleets()
|
||||
{
|
||||
check(APIData);
|
||||
TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();
|
||||
Request->OnProcessRequestComplete().BindUObject(this, &UAPITestManager::ListFleets_Response);
|
||||
const FString APIUrl = APIData->GetAPIEndpoint(DedicatedServersTags::GameSessionsAPI::ListFleets);
|
||||
Request->SetURL(APIUrl);
|
||||
Request->SetVerb(TEXT("GET"));
|
||||
Request->SetHeader(TEXT("Content-Type"), TEXT("application/json"));
|
||||
Request->ProcessRequest();
|
||||
}
|
||||
|
||||
void UAPITestManager::ListFleets_Response(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, "List Fleets Response Received");
|
||||
|
||||
TSharedPtr<FJsonObject> JsonObject;
|
||||
TSharedRef<TJsonReader<>> JsonReader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
|
||||
|
||||
if (FJsonSerializer::Deserialize(JsonReader, JsonObject))
|
||||
{
|
||||
const TSharedPtr<FJsonObject>* ErrorObjPtr = nullptr;;
|
||||
|
||||
if (ContainsErrors(JsonObject, false))
|
||||
{
|
||||
OnListFleetsResponseReceived.Broadcast(FDS_ListFleetsResponse(), false);
|
||||
return;
|
||||
}
|
||||
DumpMetaData(JsonObject);
|
||||
|
||||
FDS_ListFleetsResponse ListFleetsResponse;
|
||||
FJsonObjectConverter::JsonObjectToUStruct(JsonObject.ToSharedRef(), &ListFleetsResponse);
|
||||
ListFleetsResponse.Dump();
|
||||
OnListFleetsResponseReceived.Broadcast(ListFleetsResponse, true);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "UI/API_Test/APITestOverlay.h"
|
||||
#include "UI/API_Test/APITestManager.h"
|
||||
|
||||
|
||||
#include "Components/Button.h"
|
||||
#include "Components/ScrollBox.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "UI/API/ListFleets/FleetId.h"
|
||||
#include "UI/API/ListFleets/ListFleetsBox.h"
|
||||
#include "UI/HTTP/HTTPRequestTypes.h"
|
||||
|
||||
|
||||
void UAPITestOverlay::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
check(APITestManagerClass);
|
||||
APITestManager = NewObject<UAPITestManager>(this, APITestManagerClass);
|
||||
|
||||
check (ListFleetsBox)
|
||||
check (ListFleetsBox->Button_ListFleets)
|
||||
ListFleetsBox->Button_ListFleets->OnClicked.AddDynamic(this, &UAPITestOverlay::ListFleetsButtonClicked);
|
||||
}
|
||||
|
||||
void UAPITestOverlay::ListFleetsButtonClicked()
|
||||
{
|
||||
check(APITestManager);
|
||||
APITestManager->OnListFleetsResponseReceived.AddDynamic(this, &UAPITestOverlay::OnListFleetsResponseReceived);
|
||||
APITestManager->ListFleets();
|
||||
|
||||
ListFleetsBox->Button_ListFleets->SetIsEnabled(false);
|
||||
}
|
||||
|
||||
void UAPITestOverlay::OnListFleetsResponseReceived(const FDS_ListFleetsResponse& ListFleetResponse, bool bWasSuccessful)
|
||||
{
|
||||
if (APITestManager->OnListFleetsResponseReceived.IsAlreadyBound(this, &UAPITestOverlay::OnListFleetsResponseReceived))
|
||||
{
|
||||
APITestManager->OnListFleetsResponseReceived.RemoveDynamic(this, &UAPITestOverlay::OnListFleetsResponseReceived);
|
||||
}
|
||||
check(FleetIdWidgetClass);
|
||||
ListFleetsBox->ScrollBox_ListFleets->ClearChildren();
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
for (const FString& FleetId : ListFleetResponse.FleetIds)
|
||||
{
|
||||
UFleetId* FleetIdWidget = CreateWidget<UFleetId>(this, FleetIdWidgetClass);
|
||||
FleetIdWidget->TextBlock_FleetId->SetText(FText::FromString(FleetId));
|
||||
ListFleetsBox->ScrollBox_ListFleets->AddChild(FleetIdWidget);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UFleetId* FleetIdWidget = CreateWidget<UFleetId>(this, FleetIdWidgetClass);
|
||||
FleetIdWidget->TextBlock_FleetId->SetText(FText::FromString("Something went wrong!"));
|
||||
ListFleetsBox->ScrollBox_ListFleets->AddChild(FleetIdWidget);
|
||||
}
|
||||
ListFleetsBox->Button_ListFleets->SetIsEnabled(true);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/API_Test/API_TestHUD.h"
|
||||
#include "UI/API_Test/APITestOverlay.h"
|
||||
|
||||
void AAPI_TestHUD::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
APlayerController* PlayerController = GetOwningPlayerController();
|
||||
if (IsValid(PlayerController) && APITestOverlayClass)
|
||||
{
|
||||
APITestOverlay = CreateWidget<UAPITestOverlay>(PlayerController, APITestOverlayClass);
|
||||
APITestOverlay->AddToViewport();
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/HTTP/HTTPRequestManager.h"
|
||||
|
||||
#include "HTTPRequestTypes.h"
|
||||
#include "JsonObjectConverter.h"
|
||||
#include "DedicatedServers/DedicatedServers.h"
|
||||
|
||||
bool UHTTPRequestManager::ContainsErrors(TSharedPtr<FJsonObject> JsonObject, bool bSuppressLog)
|
||||
{
|
||||
if (JsonObject->HasField(TEXT("errorType")) || JsonObject->HasField(TEXT("errorMessage")))
|
||||
{
|
||||
if (!bSuppressLog)
|
||||
{
|
||||
FString ErrorType = JsonObject->HasField(TEXT("errorType")) ? JsonObject->GetStringField(TEXT("errorType")) : TEXT("Unknown Error");
|
||||
FString ErrorMessage = JsonObject->HasField(TEXT("errorMessage")) ? JsonObject->GetStringField(TEXT("errorMessage")) : TEXT("Unknown Error Message");
|
||||
|
||||
UE_LOGFMT(LogDedicatedServers, Error, "Error Type: {ErrorType}", ErrorType);
|
||||
UE_LOGFMT(LogDedicatedServers, Error, "Error Message: {ErrorMessage}", ErrorMessage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (JsonObject->HasField(TEXT("$fault")))
|
||||
{
|
||||
if (!bSuppressLog)
|
||||
{
|
||||
FString ErrorType = JsonObject->HasField(TEXT("name")) ? JsonObject->GetStringField(TEXT("name")) : TEXT("Unknown Error");
|
||||
UE_LOGFMT(LogDedicatedServers, Error, "Error Type: {ErrorType}", ErrorType);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UHTTPRequestManager::DumpMetaData(TSharedPtr<FJsonObject> JsonObject)
|
||||
{
|
||||
if (JsonObject->HasField(TEXT("$metadata")))
|
||||
{
|
||||
TSharedPtr<FJsonObject> MetaDataJsonObject = JsonObject->GetObjectField(TEXT("$metadata"));
|
||||
FDS_MetaData DSMetaData;
|
||||
FJsonObjectConverter::JsonObjectToUStruct(MetaDataJsonObject.ToSharedRef(), &DSMetaData);
|
||||
DSMetaData.Dump();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#include "UI/HTTP/HTTPRequestTypes.h"
|
||||
#include "DedicatedServers/DedicatedServers.h"
|
||||
|
||||
void FDS_MetaData::Dump() const
|
||||
{
|
||||
UE_LOGFMT(LogDedicatedServers, Log, "MetaData:");
|
||||
UE_LOGFMT(LogDedicatedServers, Log, "httpStatusCode: {httpStatusCode}", httpStatusCode);
|
||||
UE_LOGFMT(LogDedicatedServers, Log, "requestId: {requestId}", requestId);
|
||||
UE_LOGFMT(LogDedicatedServers, Log, "attemps: {attempts}", attempts);
|
||||
UE_LOGFMT(LogDedicatedServers, Log, "totalRetryDelay: {totalRetryDelay}", totalRetryDelay);
|
||||
}
|
||||
|
||||
void FDS_ListFleetsResponse::Dump() const
|
||||
{
|
||||
UE_LOGFMT(LogDedicatedServers, Log, "ListFleetsResponse:");
|
||||
for (const FString& FleetId : FleetIds)
|
||||
{
|
||||
UE_LOGFMT(LogDedicatedServers, Log, "FleetId: {FleetId}", FleetId);
|
||||
}
|
||||
if (!NextToken.IsEmpty())
|
||||
{
|
||||
UE_LOGFMT(LogDedicatedServers, Log, "NextToken: {NextToken}", NextToken);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Because this is in the private section is is still usable by the DedicatedServer Module, but not outside of the module.
|
||||
|
||||
#include "HTTPRequestTypes.generated.h"
|
||||
|
||||
USTRUCT()
|
||||
struct FDS_MetaData
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY()
|
||||
int32 httpStatusCode{};
|
||||
|
||||
UPROPERTY()
|
||||
FString requestId{};
|
||||
|
||||
UPROPERTY()
|
||||
int32 attempts{};
|
||||
|
||||
UPROPERTY()
|
||||
double totalRetryDelay{};
|
||||
|
||||
void Dump() const;
|
||||
};
|
||||
|
||||
USTRUCT()
|
||||
struct FDS_ListFleetsResponse
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY()
|
||||
TArray<FString> FleetIds{};
|
||||
|
||||
UPROPERTY()
|
||||
FString NextToken{};
|
||||
|
||||
void Dump() const;
|
||||
};
|
||||
@@ -1,23 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/Portal/PortalHUD.h"
|
||||
#include "UI/Portal/SignIn/SignInOverlay.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
|
||||
void APortalHUD::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
APlayerController* OwningPlayerController = GetOwningPlayerController();
|
||||
SignInOverlay = CreateWidget<USignInOverlay>(OwningPlayerController, SignInOverlayClass);
|
||||
if (IsValid(SignInOverlay))
|
||||
{
|
||||
SignInOverlay->AddToViewport();
|
||||
}
|
||||
|
||||
const FInputModeGameAndUI InputModeData;
|
||||
OwningPlayerController->SetInputMode(InputModeData);
|
||||
OwningPlayerController->SetShowMouseCursor(true);
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/Portal/PortalManager.h"
|
||||
@@ -1,14 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/Portal/SignIn/SignInOverlay.h"
|
||||
|
||||
#include "UI/Portal/PortalManager.h"
|
||||
|
||||
void USignInOverlay::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
check(PortalManagerClass);
|
||||
|
||||
PortalManager = NewObject<UPortalManager>(PortalManagerClass);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "GameplayTags/DedicatedServersTags.h"
|
||||
#include "APIData.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API UAPIData : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
FString GetAPIEndpoint(const FGameplayTag& APIEndpoint);
|
||||
|
||||
protected:
|
||||
|
||||
// Name of the API - for labeling in the Data Asset; this is not used by any code.
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FString Name;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
FString InvokeUrl;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
FString Stage;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TMap<FGameplayTag, FString> Resources;
|
||||
|
||||
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "NativeGameplayTags.h"
|
||||
|
||||
namespace DedicatedServersTags
|
||||
{
|
||||
namespace GameSessionsAPI
|
||||
{
|
||||
UE_DECLARE_GAMEPLAY_TAG_EXTERN(ListFleets)
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "JoinGame.generated.h"
|
||||
|
||||
class UButton;
|
||||
class UTextBlock;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API UJoinGame : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UButton> Button_JoinGame;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UTextBlock> TextBlock_StatusMessage;
|
||||
};
|
||||
@@ -1,23 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "FleetId.generated.h"
|
||||
|
||||
class UTextBlock;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API UFleetId : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(meta = (BindWidget), BlueprintReadWrite)
|
||||
TObjectPtr<UTextBlock> TextBlock_FleetId;
|
||||
};
|
||||
@@ -1,27 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "ListFleetsBox.generated.h"
|
||||
|
||||
class UButton;
|
||||
class UScrollBox;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API UListFleetsBox : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UScrollBox> ScrollBox_ListFleets;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UButton> Button_ListFleets;
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Interfaces/IHttpRequest.h"
|
||||
#include "UI/HTTP/HTTPRequestManager.h"
|
||||
#include "APITestManager.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnListFleetsResponseReceived, const FDS_ListFleetsResponse&, ListFleetResponse, bool, bWasSuccessful);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API UAPITestManager : public UHTTPRequestManager
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION()
|
||||
void ListFleets();
|
||||
|
||||
UPROPERTY()
|
||||
FOnListFleetsResponseReceived OnListFleetsResponseReceived;
|
||||
|
||||
void ListFleets_Response(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
|
||||
};
|
||||
@@ -1,50 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "APITestOverlay.generated.h"
|
||||
|
||||
class UAPITestManager;
|
||||
class UListFleetsBox;
|
||||
struct FDS_ListFleetsResponse;
|
||||
class UFleetId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API UAPITestOverlay : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TSubclassOf<UAPITestManager> APITestManagerClass;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TSubclassOf<UFleetId> FleetIdWidgetClass;
|
||||
|
||||
protected:
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UListFleetsBox> ListFleetsBox;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UAPITestManager> APITestManager;
|
||||
|
||||
UFUNCTION()
|
||||
void ListFleetsButtonClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void OnListFleetsResponseReceived(const FDS_ListFleetsResponse& ListFleetResponse, bool bWasSuccessful);
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/HUD.h"
|
||||
#include "API_TestHUD.generated.h"
|
||||
|
||||
class UAPITestOverlay;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API AAPI_TestHUD : public AHUD
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TSubclassOf<UAPITestOverlay> APITestOverlayClass;
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
TObjectPtr<UAPITestOverlay> APITestOverlay;
|
||||
|
||||
};
|
||||
@@ -1,28 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "HTTPRequestManager.generated.h"
|
||||
|
||||
class UAPIData;
|
||||
class FJsonObject;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Blueprintable)
|
||||
class DEDICATEDSERVERS_API UHTTPRequestManager : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TObjectPtr<UAPIData> APIData;
|
||||
|
||||
bool ContainsErrors(TSharedPtr<FJsonObject> JsonObject, bool bSuppressLog = true);
|
||||
void DumpMetaData(TSharedPtr<FJsonObject> JsonObject);
|
||||
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/HUD.h"
|
||||
#include "PortalHUD.generated.h"
|
||||
|
||||
class USignInOverlay;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API APortalHUD : public AHUD
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TSubclassOf<USignInOverlay> SignInOverlayClass;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<USignInOverlay> SignInOverlay;
|
||||
};
|
||||
@@ -1,16 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UI/HTTP/HTTPRequestManager.h"
|
||||
#include "PortalManager.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API UPortalManager : public UHTTPRequestManager
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
@@ -1,36 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "SignInOverlay.generated.h"
|
||||
|
||||
class UJoinGame;
|
||||
class UPortalManager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API USignInOverlay : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UJoinGame> JoinGameWidget;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TSubclassOf<UPortalManager> PortalManagerClass;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual void NativeConstruct() override;
|
||||
private:
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UPortalManager> PortalManager;
|
||||
};
|
||||
@@ -11,6 +11,5 @@ public class FPSTemplateTarget : TargetRules
|
||||
DefaultBuildSettings = BuildSettingsVersion.V6;
|
||||
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_7;
|
||||
ExtraModuleNames.Add("FPSTemplate");
|
||||
ExtraModuleNames.Add("DedicatedServers");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ public class FPSTemplate : ModuleRules
|
||||
"InputCore",
|
||||
"EnhancedInput",
|
||||
"PhysicsCore",
|
||||
"OpenSSL",
|
||||
"DedicatedServers"
|
||||
"OpenSSL"
|
||||
});
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[]
|
||||
@@ -30,6 +29,18 @@ public class FPSTemplate : ModuleRules
|
||||
"OpenSSL",
|
||||
});
|
||||
|
||||
// Adds in the plugin for GameLiftServerSDK if it is the server build.
|
||||
|
||||
if (Target.Type == TargetType.Server)
|
||||
{
|
||||
PublicDependencyModuleNames.Add("GameLiftServerSDK");
|
||||
}
|
||||
else
|
||||
{
|
||||
PublicDefinitions.Add("WITH_GAMELIFT=0");
|
||||
}
|
||||
bEnableExceptions = true;
|
||||
|
||||
// Uncomment if you are using Slate UI
|
||||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
|
||||
|
||||
@@ -1,52 +1,71 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DedicatedServers/Public/Game/DS_GameMode.h"
|
||||
#include "openssl/sha.h"
|
||||
#include "Game/ShooterGameMode.h"
|
||||
#include "GenericPlatform/GenericPlatformMisc.h"
|
||||
#include "Containers/UnrealString.h"
|
||||
#include "GameLiftClpTypes.h"
|
||||
#include "GameLift/GameLiftClp.h"
|
||||
#include "openssl/sha.h"
|
||||
|
||||
#if WITH_GAMELIFT
|
||||
#include "GameLiftServerSDK.h"
|
||||
#endif
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogDS_GameMode);
|
||||
|
||||
void ADS_GameMode::BeginPlay()
|
||||
DEFINE_LOG_CATEGORY(LogShooterGameMode);
|
||||
|
||||
// Function implementations.
|
||||
|
||||
AShooterGameMode::AShooterGameMode()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
void ADS_GameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
|
||||
void AShooterGameMode::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
#if WITH_GAMELIFT
|
||||
if ((GameLiftConfig.bIsAnywhereFleet && GameLiftConfig.bAllOptionsFound) ||
|
||||
!GameLiftConfig.bIsAnywhereFleet)
|
||||
{
|
||||
InitGameLift();
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
UE_LOG(LogShooterGameMode, Error, TEXT("GameLift Anywhere fleet missing required options. Exiting."));
|
||||
FGenericPlatformMisc::RequestExit(false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void AShooterGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
|
||||
{
|
||||
Super::InitGame(MapName, Options, ErrorMessage);
|
||||
|
||||
#if WITH_GAMELIFT
|
||||
|
||||
CachedCommandLine = FCommandLine::Get();
|
||||
|
||||
const FPortResult PortResult = cmdlineparser::details::GetConfiguredOrDefaultPort(CachedCommandLine, TEXT("port"));;
|
||||
if (PortResult.bUsedDefaultPort)
|
||||
{
|
||||
UE_LOGFMT (LogDS_GameMode, Warning, "{0}", PortResult.WarningMessage);
|
||||
UE_LOGFMT (LogShooterGameMode, Warning, "{0}", PortResult.WarningMessage);
|
||||
}
|
||||
|
||||
GameLiftConfig.ServerPort = PortResult.Port;
|
||||
if (FParse::Param(*CachedCommandLine, TEXT("glAnywhereFleet")))
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "Fleet type: Anywhere");
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "Fleet type: Anywhere");
|
||||
GameLiftConfig.bIsAnywhereFleet = true;
|
||||
GameLiftConfig.bAllOptionsFound = GetAnywhereFleetParameters(CachedCommandLine);
|
||||
LogAnywhereFleetParameters();
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "Fleet type: EC2");
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "Fleet type: EC2");
|
||||
// TODO: EC2 configuration
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
FString ADS_GameMode::GetSHA256Hash(const FString& InString)
|
||||
FString AShooterGameMode::GetSHA256Hash(const FString& InString)
|
||||
{
|
||||
|
||||
if (InString.IsEmpty())
|
||||
@@ -69,16 +88,16 @@ FString ADS_GameMode::GetSHA256Hash(const FString& InString)
|
||||
return Hash.ToString();
|
||||
}
|
||||
|
||||
void ADS_GameMode::InitGameLift()
|
||||
void AShooterGameMode::InitGameLift()
|
||||
{
|
||||
#if WITH_GAMELIFT
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "Calling InitGameLift...");
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "Calling InitGameLift...");
|
||||
|
||||
// Get the module first
|
||||
FGameLiftServerSDKModule* GameLiftSdkModule = &FModuleManager::LoadModuleChecked<FGameLiftServerSDKModule>("GameLiftServerSDK");
|
||||
FGameLiftGenericOutcome InitSdkOutcome;
|
||||
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "Initializing the GameLift Server...");
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "Initializing the GameLift Server...");
|
||||
if (GameLiftConfig.bIsAnywhereFleet)
|
||||
{
|
||||
// Define the server parameters for an Anywhere fleet. These are not needed for a GameLift managed EC2 fleet.
|
||||
@@ -87,7 +106,7 @@ void ADS_GameMode::InitGameLift()
|
||||
uint32 PID = FPlatformProcess::GetCurrentProcessId();
|
||||
FString PIDString = FString::FromInt(static_cast<int32>(PID));
|
||||
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "Configuring server parameters for Anywhere...");
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "Configuring server parameters for Anywhere...");
|
||||
// If AnywhereFleets are being used load the command line arguments parsed earlier.
|
||||
ServerParametersForAnywhere.m_webSocketUrl = TCHAR_TO_UTF8(*GameLiftConfig.WebSocketUrlResult.Value);
|
||||
ServerParametersForAnywhere.m_fleetId = TCHAR_TO_UTF8((*GameLiftConfig.FleetIdResult.Value));
|
||||
@@ -106,17 +125,17 @@ void ADS_GameMode::InitGameLift()
|
||||
|
||||
if (InitSdkOutcome.IsSuccess())
|
||||
{
|
||||
UE_LOG(LogDS_GameMode, SetColor, TEXT("%s"), COLOR_GREEN);
|
||||
UE_LOG(LogDS_GameMode, Log, TEXT("GameLift InitSDK succeeded!"));
|
||||
UE_LOG(LogDS_GameMode, SetColor, TEXT("%s"), COLOR_NONE);
|
||||
UE_LOG(LogShooterGameMode, SetColor, TEXT("%s"), COLOR_GREEN);
|
||||
UE_LOG(LogShooterGameMode, Log, TEXT("GameLift InitSDK succeeded!"));
|
||||
UE_LOG(LogShooterGameMode, SetColor, TEXT("%s"), COLOR_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDS_GameMode, SetColor, TEXT("%s"), COLOR_RED);
|
||||
UE_LOG(LogDS_GameMode, Log, TEXT("ERROR: InitSDK failed : ("));
|
||||
UE_LOG(LogShooterGameMode, SetColor, TEXT("%s"), COLOR_RED);
|
||||
UE_LOG(LogShooterGameMode, Log, TEXT("ERROR: InitSDK failed : ("));
|
||||
FGameLiftError GameLiftError = InitSdkOutcome.GetError();
|
||||
UE_LOG(LogDS_GameMode, Log, TEXT("ERROR: %s"), *GameLiftError.m_errorMessage);
|
||||
UE_LOG(LogDS_GameMode, SetColor, TEXT("%s"), COLOR_NONE);
|
||||
UE_LOG(LogShooterGameMode, Log, TEXT("ERROR: %s"), *GameLiftError.m_errorMessage);
|
||||
UE_LOG(LogShooterGameMode, SetColor, TEXT("%s"), COLOR_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -128,7 +147,7 @@ void ADS_GameMode::InitGameLift()
|
||||
ProcessParameters->OnStartGameSession.BindLambda([=](Aws::GameLift::Server::Model::GameSession InGameSession)
|
||||
{
|
||||
const FString GameSessionId = FString(InGameSession.GetGameSessionId());
|
||||
UE_LOG(LogDS_GameMode, Log, TEXT("GameSession Initializing: %s"), *GameSessionId);
|
||||
UE_LOG(LogShooterGameMode, Log, TEXT("GameSession Initializing: %s"), *GameSessionId);
|
||||
GameLiftSdkModule->ActivateGameSession();
|
||||
});
|
||||
|
||||
@@ -137,24 +156,24 @@ void ADS_GameMode::InitGameLift()
|
||||
//In this case, we simply tell Amazon GameLift Servers we are indeed going to shut down.
|
||||
ProcessParameters->OnTerminate.BindLambda([=]()
|
||||
{
|
||||
UE_LOG(LogDS_GameMode, Log, TEXT("Game Server Process is terminating"));
|
||||
UE_LOG(LogShooterGameMode, Log, TEXT("Game Server Process is terminating"));
|
||||
// First call ProcessEnding()
|
||||
FGameLiftGenericOutcome processEndingOutcome = GameLiftSdkModule->ProcessEnding();
|
||||
// Then call Destroy() to free the SDK from memory
|
||||
FGameLiftGenericOutcome destroyOutcome = GameLiftSdkModule->Destroy();
|
||||
// Exit the process with success or failure
|
||||
if (processEndingOutcome.IsSuccess() && destroyOutcome.IsSuccess()) {
|
||||
UE_LOG(LogDS_GameMode, Log, TEXT("Server process ending successfully"));
|
||||
UE_LOG(LogShooterGameMode, Log, TEXT("Server process ending successfully"));
|
||||
}
|
||||
else {
|
||||
if (!processEndingOutcome.IsSuccess()) {
|
||||
const FGameLiftError& error = processEndingOutcome.GetError();
|
||||
UE_LOG(LogDS_GameMode, Error, TEXT("ProcessEnding() failed. Error: %s"),
|
||||
UE_LOG(LogShooterGameMode, Error, TEXT("ProcessEnding() failed. Error: %s"),
|
||||
error.m_errorMessage.IsEmpty() ? TEXT("Unknown error") : *error.m_errorMessage);
|
||||
}
|
||||
if (!destroyOutcome.IsSuccess()) {
|
||||
const FGameLiftError& error = destroyOutcome.GetError();
|
||||
UE_LOG(LogDS_GameMode, Error, TEXT("Destroy() failed. Error: %s"),
|
||||
UE_LOG(LogShooterGameMode, Error, TEXT("Destroy() failed. Error: %s"),
|
||||
error.m_errorMessage.IsEmpty() ? TEXT("Unknown error") : *error.m_errorMessage);
|
||||
}
|
||||
}
|
||||
@@ -170,7 +189,7 @@ void ADS_GameMode::InitGameLift()
|
||||
//In this case, we're always healthy!
|
||||
ProcessParameters->OnHealthCheck.BindLambda([]()
|
||||
{
|
||||
UE_LOG(LogDS_GameMode, Log, TEXT("Performing Health Check"));
|
||||
UE_LOG(LogShooterGameMode, Log, TEXT("Performing Health Check"));
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -180,31 +199,31 @@ void ADS_GameMode::InitGameLift()
|
||||
Logfiles.Add(TEXT("FPSTemplate/Saved/Log/server.log"));
|
||||
ProcessParameters->logParameters = Logfiles;
|
||||
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "Calling Process Ready...");
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "Calling Process Ready...");
|
||||
FGameLiftGenericOutcome ProcessReadyOutcome = GameLiftSdkModule->ProcessReady(*ProcessParameters);
|
||||
|
||||
if (ProcessReadyOutcome.IsSuccess())
|
||||
{
|
||||
UE_LOG(LogDS_GameMode, SetColor, TEXT("%s"), COLOR_GREEN);
|
||||
UE_LOG(LogDS_GameMode, Log, TEXT("Process Ready!"));
|
||||
UE_LOG(LogDS_GameMode, SetColor, TEXT("%s"), COLOR_NONE);
|
||||
UE_LOG(LogShooterGameMode, SetColor, TEXT("%s"), COLOR_GREEN);
|
||||
UE_LOG(LogShooterGameMode, Log, TEXT("Process Ready!"));
|
||||
UE_LOG(LogShooterGameMode, SetColor, TEXT("%s"), COLOR_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDS_GameMode, SetColor, TEXT("%s"), COLOR_RED);
|
||||
UE_LOG(LogDS_GameMode, Log, TEXT("ERROR: Process Ready Failed!"));
|
||||
UE_LOG(LogShooterGameMode, SetColor, TEXT("%s"), COLOR_RED);
|
||||
UE_LOG(LogShooterGameMode, Log, TEXT("ERROR: Process Ready Failed!"));
|
||||
FGameLiftError ProcessReadyError = ProcessReadyOutcome.GetError();
|
||||
UE_LOG(LogDS_GameMode, Log, TEXT("ERROR: %s"), *ProcessReadyError.m_errorMessage);
|
||||
UE_LOG(LogDS_GameMode, SetColor, TEXT("%s"), COLOR_NONE);
|
||||
UE_LOG(LogShooterGameMode, Log, TEXT("ERROR: %s"), *ProcessReadyError.m_errorMessage);
|
||||
UE_LOG(LogShooterGameMode, SetColor, TEXT("%s"), COLOR_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "InitGameLift completed!");
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "InitGameLift completed!");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ADS_GameMode::GetAnywhereFleetParameters(const FString& CommandLineString)
|
||||
bool AShooterGameMode::GetAnywhereFleetParameters(const FString& CommandLineString)
|
||||
{
|
||||
bool bAllAnywhereFleetParametersValid = true;
|
||||
GameLiftConfig.AuthTokenResult = cmdlineparser::GetValueOfToken(CommandLineString, cmdlineparser::details::EAvailableTokens::AuthToken);
|
||||
@@ -222,7 +241,7 @@ bool ADS_GameMode::GetAnywhereFleetParameters(const FString& CommandLineString)
|
||||
return bAllAnywhereFleetParametersValid;
|
||||
}
|
||||
|
||||
void ADS_GameMode::LogAnywhereFleetParameters()
|
||||
void AShooterGameMode::LogAnywhereFleetParameters()
|
||||
{
|
||||
// Lambda for getting the token name from token
|
||||
auto GetTokenName = [](const cmdlineparser::details::FParseResult& Result) -> FString
|
||||
@@ -230,15 +249,15 @@ void ADS_GameMode::LogAnywhereFleetParameters()
|
||||
return cmdlineparser::details::CLI_TOKENS[static_cast<int32>(Result.Token)];
|
||||
};
|
||||
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "Anywhere Fleet Parameters:");
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "Anywhere Fleet Parameters:");
|
||||
if (GameLiftConfig.AuthTokenResult.bIsValid)
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "AuthToken: {0}", GetValueOrHash(GameLiftConfig.AuthTokenResult.Value));
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "AuthToken: {0}", GetValueOrHash(GameLiftConfig.AuthTokenResult.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOGFMT(
|
||||
LogDS_GameMode,
|
||||
LogShooterGameMode,
|
||||
Error,
|
||||
"AuthToken: {0}",
|
||||
FString::Format(
|
||||
@@ -253,12 +272,12 @@ void ADS_GameMode::LogAnywhereFleetParameters()
|
||||
|
||||
if (GameLiftConfig.FleetIdResult.bIsValid)
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "FleetId: {0}", GameLiftConfig.FleetIdResult.Value);
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "FleetId: {0}", GameLiftConfig.FleetIdResult.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOGFMT(
|
||||
LogDS_GameMode,
|
||||
LogShooterGameMode,
|
||||
Error,
|
||||
"FleetId: {0}",
|
||||
FString::Format(
|
||||
@@ -273,12 +292,12 @@ void ADS_GameMode::LogAnywhereFleetParameters()
|
||||
|
||||
if (GameLiftConfig.HostIdResult.bIsValid)
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "HostId: {0}", GameLiftConfig.HostIdResult.Value);
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "HostId: {0}", GameLiftConfig.HostIdResult.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOGFMT(
|
||||
LogDS_GameMode,
|
||||
LogShooterGameMode,
|
||||
Error,
|
||||
"HostId: {0}",
|
||||
FString::Format(
|
||||
@@ -293,12 +312,12 @@ void ADS_GameMode::LogAnywhereFleetParameters()
|
||||
|
||||
if (GameLiftConfig.WebSocketUrlResult.bIsValid)
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "WebSocketUrl: {0}", GameLiftConfig.WebSocketUrlResult.Value);
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "WebSocketUrl: {0}", GameLiftConfig.WebSocketUrlResult.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOGFMT(
|
||||
LogDS_GameMode,
|
||||
LogShooterGameMode,
|
||||
Error,
|
||||
"WebSocketUrl: {0}",
|
||||
FString::Format(
|
||||
@@ -311,50 +330,53 @@ void ADS_GameMode::LogAnywhereFleetParameters()
|
||||
);
|
||||
}
|
||||
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "Server Port: {0}", GameLiftConfig.ServerPort);
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "Server Port: {0}", GameLiftConfig.ServerPort);
|
||||
|
||||
if (GameLiftConfig.bAllOptionsFound)
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Log, "Anywhere Fleet Parameters Loaded Successfully....");
|
||||
UE_LOGFMT(LogShooterGameMode, Log, "Anywhere Fleet Parameters Loaded Successfully....");
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Error, "Anywhere Fleet Parameters Load FAILED....");
|
||||
UE_LOGFMT(LogShooterGameMode, Error, "Anywhere Fleet Parameters Load FAILED....");
|
||||
}
|
||||
}
|
||||
|
||||
void ADS_GameMode::LogServerParameters(const FServerParameters& InServerParameters)
|
||||
{
|
||||
#if WITH_GAMELIFT
|
||||
UE_LOGFMT(LogDS_GameMode, Log, ">>>> WebSocket URL: {WebSocketUrl}", InServerParameters.m_webSocketUrl);
|
||||
UE_LOGFMT(LogDS_GameMode, Log, ">>>> Fleet ID: {FleetId}", InServerParameters.m_fleetId);
|
||||
UE_LOGFMT(LogDS_GameMode, Log, ">>>> Process ID: {ProcessId}", InServerParameters.m_processId);
|
||||
UE_LOGFMT(LogDS_GameMode, Log, ">>>> Host ID (Compute Name): {HostId}", InServerParameters.m_hostId);
|
||||
UE_LOGFMT(LogDS_GameMode, Log, ">>>> Auth Token: {AuthToken}", GetValueOrHash(InServerParameters.m_authToken));
|
||||
|
||||
void AShooterGameMode::LogServerParameters(const FServerParameters& InServerParameters)
|
||||
{
|
||||
|
||||
UE_LOGFMT(LogShooterGameMode, Log, ">>>> WebSocket URL: {WebSocketUrl}", InServerParameters.m_webSocketUrl);
|
||||
UE_LOGFMT(LogShooterGameMode, Log, ">>>> Fleet ID: {FleetId}", InServerParameters.m_fleetId);
|
||||
UE_LOGFMT(LogShooterGameMode, Log, ">>>> Process ID: {ProcessId}", InServerParameters.m_processId);
|
||||
UE_LOGFMT(LogShooterGameMode, Log, ">>>> Host ID (Compute Name): {HostId}", InServerParameters.m_hostId);
|
||||
UE_LOGFMT(LogShooterGameMode, Log, ">>>> Auth Token: {AuthToken}", GetValueOrHash(InServerParameters.m_authToken));
|
||||
|
||||
if (!InServerParameters.m_awsRegion.IsEmpty())
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Log, ">>>> Aws Region: {AwsRegion}", InServerParameters.m_awsRegion);
|
||||
UE_LOGFMT(LogShooterGameMode, Log, ">>>> Aws Region: {AwsRegion}", InServerParameters.m_awsRegion);
|
||||
}
|
||||
|
||||
if (!InServerParameters.m_accessKey.IsEmpty())
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Log, ">>>> Access Key: {AccessKey}", GetValueOrHash(InServerParameters.m_accessKey));
|
||||
UE_LOGFMT(LogShooterGameMode, Log, ">>>> Access Key: {AccessKey}", GetValueOrHash(InServerParameters.m_accessKey));
|
||||
}
|
||||
|
||||
if (!InServerParameters.m_secretKey.IsEmpty())
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Log, ">>>> Secret Key: {SecretKey}", GetValueOrHash(InServerParameters.m_secretKey));
|
||||
UE_LOGFMT(LogShooterGameMode, Log, ">>>> Secret Key: {SecretKey}", GetValueOrHash(InServerParameters.m_secretKey));
|
||||
}
|
||||
|
||||
if (!InServerParameters.m_sessionToken.IsEmpty())
|
||||
{
|
||||
UE_LOGFMT(LogDS_GameMode, Log, ">>>> Session Token: {SessionToken}", GetValueOrHash(InServerParameters.m_sessionToken));
|
||||
UE_LOGFMT(LogShooterGameMode, Log, ">>>> Session Token: {SessionToken}", GetValueOrHash(InServerParameters.m_sessionToken));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
FString ADS_GameMode::GetValueOrHash(const FString& Value)
|
||||
#endif
|
||||
|
||||
FString AShooterGameMode::GetValueOrHash(const FString& Value)
|
||||
{
|
||||
#if UE_BUILD_DEBUG || UE_BUILD_DEVELOPMENT
|
||||
return Value;
|
||||
@@ -88,7 +88,7 @@ FPortResult cmdlineparser::details::GetConfiguredOrDefaultPort(const FString& Co
|
||||
}
|
||||
}
|
||||
PortResult.bUsedDefaultPort = true;
|
||||
PortResult.WarningMessage = FString("Command Line Option for Port is out of ranged... Using Default Port %s", PortResult.Port);
|
||||
PortResult.WarningMessage = FString::Printf(TEXT("Command Line Option for Port is out of ranged... Using Default Port %d"), PortResult.Port);
|
||||
return PortResult;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DedicatedServers/Public/GameLiftClpTypes.h"
|
||||
#include "GameFramework/GameMode.h"
|
||||
#include "DS_GameMode.generated.h"
|
||||
#include "GameLiftClpTypes.h"
|
||||
#include "ShooterGameModeBase.h"
|
||||
#include "ShooterGameMode.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogDS_GameMode, Log, All);
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogShooterGameMode, Log, All);
|
||||
|
||||
struct FProcessParameters;
|
||||
struct FServerParameters;
|
||||
@@ -25,11 +25,16 @@ struct FGameLiftConfig
|
||||
cmdlineparser::details::FParseResult WebSocketUrlResult;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API ADS_GameMode : public AGameMode
|
||||
class FPSTEMPLATE_API AShooterGameMode : public AShooterGameModeBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
AShooterGameMode();
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
@@ -38,13 +43,16 @@ protected:
|
||||
private:
|
||||
FGameLiftConfig GameLiftConfig;
|
||||
FString CachedCommandLine;
|
||||
TSharedPtr<FProcessParameters> ProcessParameters;
|
||||
|
||||
static FString GetSHA256Hash(const FString& InString);
|
||||
static FString GetSHA256Hash(const FString& CommandLineString);
|
||||
void InitGameLift();
|
||||
|
||||
bool GetAnywhereFleetParameters(const FString& CommandLineString);
|
||||
void LogAnywhereFleetParameters();
|
||||
#if WITH_GAMELIFT
|
||||
static void LogServerParameters(const FServerParameters& InServerParameters);
|
||||
#endif
|
||||
static FString GetValueOrHash(const FString& Value);
|
||||
|
||||
TSharedPtr<FProcessParameters> ProcessParameters;
|
||||
};
|
||||
@@ -3,14 +3,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Game/DS_GameMode.h"
|
||||
#include "GameFramework/GameMode.h"
|
||||
#include "ShooterGameModeBase.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class FPSTEMPLATE_API AShooterGameModeBase : public ADS_GameMode
|
||||
class FPSTEMPLATE_API AShooterGameModeBase : public AGameMode
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
@@ -11,6 +11,5 @@ public class FPSTemplateClientTarget : TargetRules
|
||||
DefaultBuildSettings = BuildSettingsVersion.V6;
|
||||
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_7;
|
||||
ExtraModuleNames.Add("FPSTemplate");
|
||||
ExtraModuleNames.Add("DedicatedServers");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,5 @@ public class FPSTemplateEditorTarget : TargetRules
|
||||
DefaultBuildSettings = BuildSettingsVersion.V6;
|
||||
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_7;
|
||||
ExtraModuleNames.Add("FPSTemplate");
|
||||
ExtraModuleNames.Add("DedicatedServers");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,5 @@ public class FPSTemplateServerTarget : TargetRules
|
||||
DefaultBuildSettings = BuildSettingsVersion.V6;
|
||||
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_7;
|
||||
ExtraModuleNames.Add("FPSTemplate");
|
||||
ExtraModuleNames.Add("DedicatedServers");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user