Download

Help understanding HttpRequest tutorial

Hello all,

So I’m working through the HttpRequest tutorial (https://wiki.unrealengine.com/Http-requests)

Inside the AHttpService::Login() method there is a line:


 
 // We'll add the PlayerState to the bound response method so    that we can use it later   Request->OnProcessRequestComplete().BindUObject(this,    &AHttpService::LoginResponse, PlayerState);  

As the comment here says, the PlayerState is being bound to the response method. However, I’m not very familiar with BindUObject and don’t understand how we can then access this PlayerState so that we can get the information at a later point.

Then, in the LoginResponse method there is this line:


 
 // We'll give back the information to the player's state so they can do something with it.         PlayerState->OnLoginSuccess(LoginResponse); 

Is OnLoginSuccess a method that assigns values to PlayerState? Basically I’m just confused trying to understand how the initial PlayerState that we pass in can then be used in different contexts from this code.

It’s using delegate payloads: https://docs.unrealengine.com/en-us/Programming/UnrealArchitecture/Delegates#payloaddata

Since Player state is available at the time when binding the delegate, it can store it somewhere in the binding and then pass it on to the bound function when executing it.