// Fill out your copyright notice in the Description page of Project Settings. #include "UI/APITest/APITestManager.h" #include "HttpModule.h" #include "JsonObjectConverter.h" #include "Data/API/APIData.h" #include "GameplayTags/DedicatedServerTags.h" #include "Interfaces/IHttpResponse.h" #include "UI/HTTP/HTTPRequestTypes.h" void UAPITestManager::ListFleetsButtonClicked() { check(APIData); TSharedPtr Request = FHttpModule::Get().CreateRequest(); Request->OnProcessRequestComplete().BindUObject(this, &UAPITestManager::ListFleets_Response); const FString APIUrl = APIData->GetAPIEndPoint(DedicatedServersTags::GameSessionsAPI::ListFleets); Request->SetURL(APIUrl); Request->SetVerb("GET"); Request->SetHeader("Content-Type", "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::Red, "List Fleets Response Received"); TSharedPtr JsonObject; TSharedRef> JsonReader = TJsonReaderFactory<>::Create(Response->GetContentAsString()); if (FJsonSerializer::Deserialize(JsonReader, JsonObject)) { if (JsonObject->HasField(TEXT("$metadata"))) { TSharedPtr MetaDataJsonObject = JsonObject->GetObjectField(TEXT("$metadata")); FDSMetaData DSMetaData; FJsonObjectConverter::JsonObjectToUStruct(MetaDataJsonObject.ToSharedRef(), &DSMetaData); DSMetaData.Dump(); } FDSListFleetsResponse ListFleetsResponse; FJsonObjectConverter::JsonObjectToUStruct(JsonObject.ToSharedRef(), &ListFleetsResponse); ListFleetsResponse.Dump(); } }