Skip to content

Commit

Permalink
add support for GameServer Status Addresses (#3932)
Browse files Browse the repository at this point in the history
Co-authored-by: igooch <igooch@google.com>
  • Loading branch information
KAllan357 and igooch authored Sep 9, 2024
1 parent 5e4dbca commit 59076bc
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions sdks/unreal/Agones/Source/Agones/Classes/Classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,28 @@ struct FSpec
}
};

USTRUCT(BlueprintType)
struct FAddress
{
GENERATED_BODY()

UPROPERTY(BlueprintReadOnly, Category="Agones")
FString Type;

UPROPERTY(BlueprintReadOnly, Category="Agones")
FString Address;

FAddress()
{
}

explicit FAddress(const TSharedPtr<FJsonObject> JsonObject)
{
JsonObject->TryGetStringField(TEXT("type"), Type);
JsonObject->TryGetStringField(TEXT("address"), Address);
}
};

USTRUCT(BlueprintType)
struct FPort
{
Expand Down Expand Up @@ -182,6 +204,9 @@ struct FStatus
UPROPERTY(BlueprintReadOnly, Category="Agones")
FString Address;

UPROPERTY(BlueprintReadOnly, Category="Agones")
TArray<FAddress> Addresses;

UPROPERTY(BlueprintReadOnly, Category="Agones")
TArray<FPort> Ports;

Expand All @@ -193,6 +218,20 @@ struct FStatus
{
JsonObject->TryGetStringField(TEXT("state"), State);
JsonObject->TryGetStringField(TEXT("address"), Address);
const TArray<TSharedPtr<FJsonValue>>* AddressesArray;
if (JsonObject->TryGetArrayField(TEXT("addresses"), AddressesArray))
{
const int32 ArrLen = AddressesArray->Num();
for (int32 i = 0; i < ArrLen; ++i)
{
const TSharedPtr<FJsonValue>& AddressItem = (*AddressesArray)[i];
if (AddressItem.IsValid() && !AddressItem->IsNull())
{
FAddress NewAddress = FAddress(AddressItem->AsObject());
Addresses.Add(NewAddress);
}
}
}
const TArray<TSharedPtr<FJsonValue>>* PortsArray;
if (JsonObject->TryGetArrayField(TEXT("ports"), PortsArray))
{
Expand Down

0 comments on commit 59076bc

Please sign in to comment.