Lesson 60 - Making an HTTP Request
This commit is contained in:
@@ -13,7 +13,8 @@ public class DedicatedServers : ModuleRules
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"OpenSSL",
|
||||
"GameplayTags"
|
||||
"GameplayTags",
|
||||
"HTTP"
|
||||
});
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[]
|
||||
|
||||
@@ -2,8 +2,28 @@
|
||||
|
||||
|
||||
#include "UI/APITest/APITestManager.h"
|
||||
#include "HttpModule.h"
|
||||
#include "Data/API/APIData.h"
|
||||
#include "GameplayTags/DedicatedServerTags.h"
|
||||
|
||||
void UAPITestManager::ListFleetsButtonClicked()
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "List Fleets Button Clicked");
|
||||
check(APIData);
|
||||
|
||||
TSharedPtr<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("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");
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Interfaces/IHttpRequest.h"
|
||||
#include "UI/HTTP/HTTPRequestManager.h"
|
||||
#include "APITestManager.generated.h"
|
||||
|
||||
@@ -18,4 +19,6 @@ public:
|
||||
|
||||
UFUNCTION()
|
||||
void ListFleetsButtonClicked();
|
||||
|
||||
void ListFleets_Response(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user