Compare commits
3 Commits
b26e9eb576
...
3912fe52c6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3912fe52c6 | ||
|
|
d989960b41 | ||
|
|
3407b94731 |
BIN
Content/DedicatedServers/APITest/BP_APITestManager.uasset
Normal file
BIN
Content/DedicatedServers/APITest/BP_APITestManager.uasset
Normal file
Binary file not shown.
Binary file not shown.
BIN
Content/DedicatedServers/Data/DA_GameSessionsAPIData.uasset
Normal file
BIN
Content/DedicatedServers/Data/DA_GameSessionsAPIData.uasset
Normal file
Binary file not shown.
@@ -14,7 +14,9 @@ public class DedicatedServers : ModuleRules
|
||||
{
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine"
|
||||
"Engine",
|
||||
"GameplayTags",
|
||||
"HTTP"
|
||||
});
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[]
|
||||
|
||||
11
Source/DedicatedServers/Private/Data/API/APIData.cpp
Normal file
11
Source/DedicatedServers/Private/Data/API/APIData.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
// 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;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#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")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/API_Test/APITestManager.h"
|
||||
#include "HttpModule.h"
|
||||
#include "Data/API/APIData.h"
|
||||
#include "GameplayTags/DedicatedServersTags.h"
|
||||
|
||||
void UAPITestManager::ListFleetsButtonClicked()
|
||||
{
|
||||
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();
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "List Fleets Request Made");
|
||||
|
||||
}
|
||||
|
||||
void UAPITestManager::ListFleets_Response(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, "List Fleets Response Received");
|
||||
}
|
||||
@@ -1,4 +1,21 @@
|
||||
// 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 "UI/API/ListFleets/ListFleetsBox.h"
|
||||
|
||||
|
||||
void UAPITestOverlay::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
check(APITestManagerClass);
|
||||
APITestManager = NewObject<UAPITestManager>(this, APITestManagerClass);
|
||||
|
||||
check (ListFleetsBox)
|
||||
check (ListFleetsBox->Button_ListFleets)
|
||||
ListFleetsBox->Button_ListFleets->OnClicked.AddDynamic(APITestManager, &UAPITestManager::ListFleetsButtonClicked);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UI/HTTP/HTTPRequestManager.h"
|
||||
38
Source/DedicatedServers/Public/Data/API/APIData.h
Normal file
38
Source/DedicatedServers/Public/Data/API/APIData.h
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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;
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "NativeGameplayTags.h"
|
||||
|
||||
namespace DedicatedServersTags
|
||||
{
|
||||
namespace GameSessionsAPI
|
||||
{
|
||||
UE_DECLARE_GAMEPLAY_TAG_EXTERN(ListFleets)
|
||||
}
|
||||
}
|
||||
24
Source/DedicatedServers/Public/UI/API_Test/APITestManager.h
Normal file
24
Source/DedicatedServers/Public/UI/API_Test/APITestManager.h
Normal file
@@ -0,0 +1,24 @@
|
||||
// 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"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DEDICATEDSERVERS_API UAPITestManager : public UHTTPRequestManager
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION()
|
||||
void ListFleetsButtonClicked();
|
||||
|
||||
void ListFleets_Response(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
|
||||
};
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "APITestOverlay.generated.h"
|
||||
|
||||
class UAPITestManager;
|
||||
class UListFleetsBox;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -13,4 +15,25 @@ UCLASS()
|
||||
class DEDICATEDSERVERS_API UAPITestOverlay : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TSubclassOf<UAPITestManager> APITestManagerClass;
|
||||
|
||||
protected:
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UListFleetsBox> ListFleetsBox;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UAPITestManager> APITestManager;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
25
Source/DedicatedServers/Public/UI/HTTP/HTTPRequestManager.h
Normal file
25
Source/DedicatedServers/Public/UI/HTTP/HTTPRequestManager.h
Normal file
@@ -0,0 +1,25 @@
|
||||
// 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;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Blueprintable)
|
||||
class DEDICATEDSERVERS_API UHTTPRequestManager : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TObjectPtr<UAPIData> APIData;
|
||||
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user