I am using a AHttpActor class to connect to my server and log in.
The application needs to give an error when the server could not be reached so to test this i turned the http server off.
To my surprise the UE3Editor crashed completely.
Of course i don’t want my game to crash so i need to know what is going on.
I hope anyone can help…
This is my response code.
void AHttpActor::OnLoginResponse(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
if (!HttpRequestSuccess = ResponseIsValid(Response, bWasSuccessful)){
return;
}
//Create a pointer to hold the json serialized data
TSharedPtr<FJsonObject> JsonObject; void AHttpActor::LoginToServer() {
TSharedRef<IHttpRequest> Request = Http->CreateRequest();
Request->OnProcessRequestComplete().BindUObject(this, &AHttpActor::OnLoginResponse);
//This is the url on which to process the request
Request->SetURL(ApiBaseUrl + TEXT("login.php"));
Request->SetVerb("GET");
Request->SetHeader(TEXT("User-Agent"), "X-UnrealEngine-Agent");
Request->SetHeader("Content-Type", TEXT("application/json"));
Request->SetHeader(TEXT("User-ID"), FGenericPlatformMisc::GetUniqueDeviceId());
Request->ProcessRequest();
}
//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
purchased_game = JsonObject->GetBoolField("purchased_game");
score = JsonObject->GetIntegerField("score");
rank = JsonObject->GetIntegerField("rank");
logged_in = true;
}
}
void AHttpActor::LoginToServer() {
TSharedRef<IHttpRequest> Request = Http->CreateRequest();
Request->OnProcessRequestComplete().BindUObject(this, &AHttpActor::OnLoginResponse);
//This is the url on which to process the request
Request->SetURL(ApiBaseUrl + TEXT("login.php"));
Request->SetVerb("GET");
Request->SetHeader(TEXT("User-Agent"), "X-UnrealEngine-Agent");
Request->SetHeader("Content-Type", TEXT("application/json"));
Request->SetHeader(TEXT("User-ID"), FGenericPlatformMisc::GetUniqueDeviceId());
Request->ProcessRequest();
}