Skip to content

Commit

Permalink
add support for GameServer Status Addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
KAllan357 committed Aug 2, 2024
1 parent 049de2f commit 98abc95
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 98abc95

Please sign in to comment.