Download

Dynamic Delegate Blueprint Callable

Greetings,
I’ve been trying to create an dynamic delegate that can be called in blueprint ( on LoginApiLoginRequestComplete ) and bind it to a function.
But It doesn’t work…
Anyone can help?



void UMainObject::Login(FString Username, FString Password) {


	UE_LOG(LogTemp, Warning, TEXT("Creating api request."));
	TSharedRef<IHttpRequest> HttpRequest = FHttpModule::Get().CreateRequest();
	HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/x-www-form-urlencoded"));

//delegate to void LoginApiLoginRequestComplete()
	HttpRequest->OnProcessRequestComplete().BindUObject(this, &UMainObject::LoginApiLoginRequestComplete);

	FString RequestURL = ServerApiURL + "main.php?api_key=" + ServerApiKey + "&username=" + Username + "&password=" + Password;
	HttpRequest->SetURL(RequestURL);
	HttpRequest->SetVerb(TEXT("GET"));
	HttpRequest->ProcessRequest();

}

void UMainObject::LoginApiLoginRequestComplete(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
}



Never mind I’ve got it done. :slight_smile:

When you solve your own problems, it’s always nice to post your solution so that others who find this thread in the future have some idea of how to proceed :slight_smile:

Oh yeah
Using this as delegate: DECLARE_DYNAMIC_MULTICAST_DELEGATE(FLoginCompleteDelegate); under Generated Uclass Body.
Under public I defined the Delegate:
FLoginCompleteDelegate LoginDelegate;

And when the request is complete :
LoginDelegate.Broadcast();

Cheers,
Bander

Just for future generations, if you have no other choice than to use a normal dynamic delegate: It is possible.

Make the dynamic delegate, in this case LoginDelegate, BlueprintReadWrite by using UFUNCTION(BlueprintReadWrite). Then in the Blueprint just set the delegate to a custom event.

WBP Slider Hight is the object the delegate is from, OnValueChanged is the delegate and the Custom Event is thrown whenever the delegate is executed.