October3d55/M/HTTPWebCommunication/Source/WebCommunication/Private/UAsyncNodeHttpGoogleFileInf...

39 lines
1.7 KiB
C++
Raw Normal View History

2025-03-10 09:43:27 +08:00
// Copyright 2017 David Romanski(Socke). All Rights Reserved.
#include "UAsyncNodeHttpGoogleFileInfoRequest.h"
UAsyncNodeHttpGoogleFileInfoRequest* UAsyncNodeHttpGoogleFileInfoRequest::AsyncExecuteHTTP_GoogleFileInfo_REQUEST(FString downloadID){
//The node is only visible in Blueprints if the function is declared in a UBlueprintAsyncActionBase class.
//Therefore an instance of itself is created here.
UAsyncNodeHttpGoogleFileInfoRequest* instance = NewObject<UAsyncNodeHttpGoogleFileInfoRequest>();
instance->requestID = FGuid::NewGuid().ToString();
//save it in the main class to use it everywhere
UWebCommunicationBPLibrary::getWebCommunicationTarget()->registerUAsyncNodeHttpRequest(instance->requestID, instance);
int32 result = UWebCommunicationBPLibrary::getWebCommunicationTarget()->CreateHttpRequestGoogleDriveFileInfo(TArray<struct FhttpRequest>(), downloadID, instance->requestID, instance->httpRequests, instance->requestID);
if (result == 400) {
instance->httpRequestCompleteGoogleFileInfo("", 0, 400, downloadID, instance->requestID);
}
return instance;
}
void UAsyncNodeHttpGoogleFileInfoRequest::Activate(){
UWebCommunicationBPLibrary::webcom->startRequests(httpRequests);
}
void UAsyncNodeHttpGoogleFileInfoRequest::httpRequestCompleteGoogleFileInfo(const FString fileName, const int64 fileSizeInBytes, const int32 statusCode, const FString downloadID, const FString requestIDP){
if (statusCode >= 400) {
OnFail.Broadcast(fileName, fileSizeInBytes, statusCode, downloadID, requestIDP);
}
else {
OnSuccess.Broadcast(fileName, fileSizeInBytes, statusCode, downloadID, requestIDP);
}
//clean
UWebCommunicationBPLibrary::getWebCommunicationTarget()->unregisterUAsyncNodeHttpRequest(requestIDP);
RemoveFromRoot();
SetReadyToDestroy();
}