68 lines
3.3 KiB
C++
68 lines
3.3 KiB
C++
// Copyright 2017 David Romanski(Socke). All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "WebCommunication.h"
|
|
#include "UAsyncNodeWebCom.h"
|
|
#include "UAsyncNodeHttpRequest.generated.h"
|
|
|
|
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_SixParams(FAsyncNodeHttpRequestCompleteDelegate,const FString, dataString, const TArray<FString>&, data, const TArray<FString>&, header, const int32, statusCode, const TArray<uint8>&, byteData, const FString, requestID);
|
|
|
|
UCLASS()
|
|
class WEBCOMMUNICATION_API UAsyncNodeHttpRequest : public UAsyncNodeWebCom
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
|
|
public:
|
|
|
|
UPROPERTY(BlueprintAssignable)
|
|
FAsyncNodeHttpRequestCompleteDelegate OnSuccess;
|
|
|
|
UPROPERTY(BlueprintAssignable)
|
|
FAsyncNodeHttpRequestCompleteDelegate OnFail;
|
|
|
|
/**
|
|
* Send a GET HTTP Request to Webserver.
|
|
* if statusCode >= 400 then OnFail else OnSuccess
|
|
* @param bindServerSendEvent Activates the "Server Send Event" for this http request. If you as a client want to get multiple http responses from the server for one http request you can use the http technique "Server Sent Events".
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "WebCommunication|GET", meta = (BlueprintInternalUseOnly = "true", AutoCreateRefTerm = "header"))
|
|
static UAsyncNodeHttpRequest* AsyncExecuteHTTP_GET_REQUEST(FString url, TMap<FString,FString> header, FString optionalRequestID, bool bindServerSendEvent );
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "WebCommunication|GET", meta = (BlueprintInternalUseOnly = "true"))
|
|
static UAsyncNodeHttpRequest* AsyncExecuteHTTP_GoogleDrive_REQUEST(FString downloadID, FString optionalRequestID, int64 optionalFileSizeInByte);
|
|
|
|
/**
|
|
* Send a POST HTTP Request to Webserver.
|
|
* if statusCode >= 400 then OnFail else OnSuccess
|
|
* @param bindServerSendEvent Activates the "Server Send Event" for this http request. If you as a client want to get multiple http responses from the server for one http request you can use the http technique "Server Sent Events".
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "WebCommunication|POST", meta = (BlueprintInternalUseOnly = "true", AutoCreateRefTerm = "header,POSTData"))
|
|
static UAsyncNodeHttpRequest* AsyncExecuteHTTP_POST_REQUEST(FString url, TMap<FString, FString> header, TMap<FString, FString> POSTData, FString optionalRequestID, bool bindServerSendEvent);
|
|
|
|
/**
|
|
* Individual HTTP Request. You have to set all parameters yourself.
|
|
*
|
|
* @param url Server URL
|
|
* @param header User-Agent, Content-Type
|
|
* @param verb POST, GET, PUT, PATCH, DELETE
|
|
* @param content Request Body or Filepath
|
|
* @param addContentLengthHeader add Content-Length header with the length of the content.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "WebCommunication|Individual", meta = (BlueprintInternalUseOnly = "true", AutoCreateRefTerm = "header,binaryContent"))
|
|
static UAsyncNodeHttpRequest* AsyncExecuteHTTP_Individual_REQUEST(FString url, TMap<FString, FString> header, FString verb,
|
|
EHTTPWebComIndividualType contentType, FString content,TArray<uint8> binaryContent, FString optionalRequestID, bool addContentLengthHeader = true);
|
|
|
|
|
|
|
|
virtual void Activate() override;
|
|
virtual void BeginDestroy() override;
|
|
|
|
virtual void httpRequestComplete(const FString dataString, const TArray<FString>& data, const TArray<FString>& header, const int32 statusCode, const TArray<uint8>& byteData, const FString requestID) override;
|
|
|
|
private:
|
|
FString requestID;
|
|
TArray<struct FhttpRequest> httpRequests;
|
|
}; |