Waiting for Events (DELEGATES)

Hello everyone,

I’m not very familiar yet with UE4 Programming uses and I am stuck in a bad situation…

I want to make some HTTP requests to connect to a Webplatform so I used this tutorial to do it : A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums

It perfectly works, I can retrieve a xmlcontent which contains a “Connection Id” that I need to do an other HTTP request on the same plateform !

The only problem is that the RequestProcess is done in an other thread (with this line if I have well undestood) :

Request->OnProcessRequestComplete().BindUObject(this, &AHttpActor::OnResponseReceived);

So when I try my second HTTP operation (in the main thread) I have not already the “Connection Id” I need and the Request failed…

So I know that I have to use DELEGATES (AddDynamic ?) to wait for my first operation, but I’m totally new to it and I don’t really understand how to listen for this Event…

I have seen a lot of topics on this subject but I didn’t find one which well explain how to do to wait for an event …

I hope somebody here could help me and explain to me how it works :slight_smile:

Have a good day :wink:

Hello :slight_smile:

I finally undestood how it works, so now it works fine !

In my first class, (where I do the HttpCall) : I have just declare and create a DELEGATE to broadcast that the Connection Operation is ended

FirstClass.h :


and as a member of this class :

// Event for Connection complete
	FConnectionDelegate_OnComplete OnConnectionComplete;

I have also created a class to Control the Http Module (It’s in this class that I will call for my FirstClass::Connect() and FirstClass::Login()). In this class (wich includes FirstClass.h) in ControllerClass::BeginPlay() :

// New Http Module (from firstClass)
	HttpModule = NewObject<FirstClass>();

// Events
	HttpModule->OnConnectionComplete.AddDynamic(this, &ControllerClass::LoginController);		// After Connection, Login will be asked 

// Connection
	ConnectionController();   // Call for FirstClass::Connect() with the goods arguments

Now “ControllerClass::LoginController()” will be called when the FirstClass will send that the Connection is ended.

Now if you look at the exemple I gave in my first post, in the OnResponseReceived if my XML was correctly parsed I just call a “Broadcast” to notify every DELEGATES of this type,


// Notify every listener that the connection is a success (allow to login)

At this moment, “ControllerClass::LoginController” will be called, and it will call “FirstClass::Login()” with the args that “FirstClass::Connect” will return.

Problem solved ! :wink:

If my explanations are not very clear, please let me know :slight_smile: