Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unreal SDK] Added a response code check to some functions #1870

Merged
merged 2 commits into from Oct 28, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 48 additions & 6 deletions sdks/unreal/Agones/Source/Agones/Private/AgonesComponent.cpp
Expand Up @@ -102,7 +102,13 @@ void UAgonesComponent::Ready(const FReadyDelegate SuccessDelegate, const FAgones
ErrorDelegate.ExecuteIfBound({});
return;
}

if (!EHttpResponseCodes::IsOk(HttpResponse->GetResponseCode()))
{
ErrorDelegate.ExecuteIfBound(
{FString::Format(TEXT("Error Code - {0}"), {FString::FromInt(HttpResponse->GetResponseCode())})});
return;
}

SuccessDelegate.ExecuteIfBound({});
});
Request->ProcessRequest();
Expand Down Expand Up @@ -205,7 +211,13 @@ void UAgonesComponent::Shutdown(const FShutdownDelegate SuccessDelegate, const F
ErrorDelegate.ExecuteIfBound({"Unsuccessful Call"});
return;
}

if (!EHttpResponseCodes::IsOk(HttpResponse->GetResponseCode()))
{
ErrorDelegate.ExecuteIfBound(
{FString::Format(TEXT("Error Code - {0}"), {FString::FromInt(HttpResponse->GetResponseCode())})});
return;
}

SuccessDelegate.ExecuteIfBound({});
});
Request->ProcessRequest();
Expand All @@ -230,7 +242,13 @@ void UAgonesComponent::SetAnnotation(
ErrorDelegate.ExecuteIfBound({"Unsuccessful Call"});
return;
}

if (!EHttpResponseCodes::IsOk(HttpResponse->GetResponseCode()))
{
ErrorDelegate.ExecuteIfBound(
{FString::Format(TEXT("Error Code - {0}"), {FString::FromInt(HttpResponse->GetResponseCode())})});
return;
}

SuccessDelegate.ExecuteIfBound({});
});
Request->ProcessRequest();
Expand All @@ -246,7 +264,13 @@ void UAgonesComponent::Allocate(const FAllocateDelegate SuccessDelegate, const F
ErrorDelegate.ExecuteIfBound({"Unsuccessful Call"});
return;
}

if (!EHttpResponseCodes::IsOk(HttpResponse->GetResponseCode()))
{
ErrorDelegate.ExecuteIfBound(
{FString::Format(TEXT("Error Code - {0}"), {FString::FromInt(HttpResponse->GetResponseCode())})});
return;
}

SuccessDelegate.ExecuteIfBound({});
});
Request->ProcessRequest();
Expand All @@ -271,7 +295,13 @@ void UAgonesComponent::Reserve(
ErrorDelegate.ExecuteIfBound({"Unsuccessful Call"});
return;
}

if (!EHttpResponseCodes::IsOk(HttpResponse->GetResponseCode()))
{
ErrorDelegate.ExecuteIfBound(
{FString::Format(TEXT("Error Code - {0}"), {FString::FromInt(HttpResponse->GetResponseCode())})});
return;
}

SuccessDelegate.ExecuteIfBound({});
});
Request->ProcessRequest();
Expand Down Expand Up @@ -384,7 +414,13 @@ void UAgonesComponent::SetPlayerCapacity(
ErrorDelegate.ExecuteIfBound({"Unsuccessful Call"});
return;
}

if (!EHttpResponseCodes::IsOk(HttpResponse->GetResponseCode()))
{
ErrorDelegate.ExecuteIfBound(
{FString::Format(TEXT("Error Code - {0}"), {FString::FromInt(HttpResponse->GetResponseCode())})});
return;
}

SuccessDelegate.ExecuteIfBound({});
});
Request->ProcessRequest();
Expand All @@ -400,6 +436,12 @@ void UAgonesComponent::GetPlayerCapacity(FGetPlayerCapacityDelegate SuccessDeleg
ErrorDelegate.ExecuteIfBound({"Unsuccessful Call"});
return;
}
if (!EHttpResponseCodes::IsOk(HttpResponse->GetResponseCode()))
{
ErrorDelegate.ExecuteIfBound(
{FString::Format(TEXT("Error Code - {0}"), {FString::FromInt(HttpResponse->GetResponseCode())})});
return;
}

const FString Json = HttpResponse->GetContentAsString();
TSharedPtr<FJsonObject> JsonObject;
Expand Down