Lesson 62 - Parsing the Metadata
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -69,4 +69,8 @@ Intermediate/*
|
|||||||
Plugins/**/Intermediate/*
|
Plugins/**/Intermediate/*
|
||||||
|
|
||||||
# Cache files for the editor to use
|
# Cache files for the editor to use
|
||||||
DerivedDataCache/*
|
DerivedDataCache/*
|
||||||
|
|
||||||
|
# IDE Settings
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
@@ -4,3 +4,5 @@
|
|||||||
#include "Modules/ModuleManager.h"
|
#include "Modules/ModuleManager.h"
|
||||||
|
|
||||||
IMPLEMENT_MODULE( FDefaultModuleImpl, DedicatedServers );
|
IMPLEMENT_MODULE( FDefaultModuleImpl, DedicatedServers );
|
||||||
|
|
||||||
|
DEFINE_LOG_CATEGORY( LogDedicatedServers );
|
||||||
@@ -3,3 +3,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
|
||||||
|
DECLARE_LOG_CATEGORY_EXTERN(LogDedicatedServers, Log, All);
|
||||||
@@ -3,9 +3,11 @@
|
|||||||
|
|
||||||
#include "UI/APITest/APITestManager.h"
|
#include "UI/APITest/APITestManager.h"
|
||||||
#include "HttpModule.h"
|
#include "HttpModule.h"
|
||||||
|
#include "JsonObjectConverter.h"
|
||||||
#include "Data/API/APIData.h"
|
#include "Data/API/APIData.h"
|
||||||
#include "GameplayTags/DedicatedServerTags.h"
|
#include "GameplayTags/DedicatedServerTags.h"
|
||||||
#include "Interfaces/IHttpResponse.h"
|
#include "Interfaces/IHttpResponse.h"
|
||||||
|
#include "UI/HTTP/HTTPRequestTypes.h"
|
||||||
|
|
||||||
|
|
||||||
void UAPITestManager::ListFleetsButtonClicked()
|
void UAPITestManager::ListFleetsButtonClicked()
|
||||||
@@ -34,13 +36,13 @@ void UAPITestManager::ListFleets_Response(FHttpRequestPtr Request, FHttpResponse
|
|||||||
|
|
||||||
if (FJsonSerializer::Deserialize(JsonReader, JsonObject))
|
if (FJsonSerializer::Deserialize(JsonReader, JsonObject))
|
||||||
{
|
{
|
||||||
if (JsonObject->HasField(TEXT("FleetIds")))
|
if (JsonObject->HasField(TEXT("$metadata")))
|
||||||
{
|
{
|
||||||
for (TSharedPtr<FJsonValue> Fleet : JsonObject->GetArrayField(TEXT("FleetIds")))
|
TSharedPtr<FJsonObject> MetaDataJsonObject = JsonObject->GetObjectField(TEXT("$metadata"));
|
||||||
{
|
FDSMetaData DSMetaData;
|
||||||
FString FleetString = Fleet->AsString();
|
FJsonObjectConverter::JsonObjectToUStruct(MetaDataJsonObject.ToSharedRef(), &DSMetaData);
|
||||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FleetString);
|
|
||||||
}
|
DSMetaData.Dump();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
Source/DedicatedServers/Private/UI/HTTP/HTTPRequestTypes.cpp
Normal file
11
Source/DedicatedServers/Private/UI/HTTP/HTTPRequestTypes.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include "UI/HTTP/HTTPRequestTypes.h"
|
||||||
|
#include "DedicatedServers/DedicatedServers.h"
|
||||||
|
|
||||||
|
void FDSMetaData::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, "attempts: {attempts}", attempts);
|
||||||
|
UE_LOGFMT(LogDedicatedServers, Log, "totalRetryDelay: {totalRetryDelay}", totalRetryDelay);
|
||||||
|
}
|
||||||
23
Source/DedicatedServers/Public/UI/HTTP/HTTPRequestTypes.h
Normal file
23
Source/DedicatedServers/Public/UI/HTTP/HTTPRequestTypes.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "HTTPRequestTypes.generated.h"
|
||||||
|
|
||||||
|
USTRUCT()
|
||||||
|
struct FDSMetaData
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
int32 httpStatusCode{};
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
FString requestId{};
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
int32 attempts{};
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
double totalRetryDelay{};
|
||||||
|
|
||||||
|
void Dump() const;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user