// 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::ListFleets() { 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(); } void UAPITestManager::ListFleets_Response(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) { TSharedPtr JsonObject; TSharedRef> JsonReader = TJsonReaderFactory<>::Create(Response->GetContentAsString()); if (FJsonSerializer::Deserialize(JsonReader, JsonObject)) { if (ContainsErrors(JsonObject)) { OnListFleetsResponseReceived.Broadcast(FDSListFleetsResponse(), false); return; } DumpMetadata(JsonObject); FDSListFleetsResponse ListFleetsResponse; FJsonObjectConverter::JsonObjectToUStruct(JsonObject.ToSharedRef(), &ListFleetsResponse); OnListFleetsResponseReceived.Broadcast(ListFleetsResponse, true); ListFleetsResponse.Dump(); } }