SOLVED
Hello there. With reference to this wiki article: A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums .
If I have a class that inherits form AHttpActor and the Response function in the subclass instead. Is it possible to call MyHttpCall from the subclass and bind the response to a function in the subclass?
Any input/hints in the right direction would been appreciated.
This code below is from the link above:
void AHttpActor::MyHttpCall()
{
TSharedRef<IHttpRequest> Request = Http->CreateRequest();
Request->OnProcessRequestComplete().BindUObject(this, &AHttpActor::OnResponseReceived);
//This is the url on which to process the request
Request->SetURL("http://localhost:8081/WebApi/getint.php");
Request->SetVerb("GET");
Request->SetHeader(TEXT("User-Agent"), "X-UnrealEngine-Agent");
Request->SetHeader("Content-Type", TEXT("application/json"));
Request->ProcessRequest();
}
/*Assigned function on successfull http call*/
void AHttpActor::OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
//Create a pointer to hold the json serialized data
TSharedPtr<FJsonObject> JsonObject;
//Create a reader pointer to read the json data
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
//Deserialize the json data given Reader and the actual object to deserialize
if (FJsonSerializer::Deserialize(Reader, JsonObject))
{
//Get the value of the json object by field name
int32 recievedInt = JsonObject->GetIntegerField("customInt");
//Output it to the engine
GEngine->AddOnScreenDebugMessage(1, 2.0f, FColor::Green, FString::FromInt(recievedInt));
}
}
SOLVED: Using c++ template function with object and member function as params actually did the trick.