Skip to content

Commit

Permalink
Added DEFINE_BEAM_OPERATION_HOOK macros to help us expose configurabl…
Browse files Browse the repository at this point in the history
…e last-mile hooks that customer code is allowed to hook into before continuing

- Fixed BeamFlowExamples blueprint compilation errors due to changes to RequestTracker types
- Fixed compilation issues due to UE 5.3.2 moving to C++20
- Added utility functions for triggering empty successful/error operations (much like Task.CompletedTask in C# land)
- DEFINE_BEAM_OPERATION_HOOK are meant to be used internally in the core SDK and by customers in our, currently unreleased, Online Subsystem plugin;
- Added template functions we can use to run one/array of DEFINE_BEAM_OPERATION_HOOK delegates; hooks are optional by definition so the wait handler executes 100% of time unless one of the given hooks is unbound --- we treat that as an Error.
- Refactored UBeamRuntime's DelayedOperation to use the new Hook function;
- Added Update Lobby Data, Update Player Tags and Provision Game Server Operations to UBeamLobbySubsystem; Provision
- UBeamStatsSubsystem::RefreshStats can now be called inside DedicatedServers by passing in a fully formed StatsType with the GamerTag of a player in that server's game session.
- Renamed UBeamLocalPlayerLobbyInfo to UBeamLobbyState for better clarity.
- Added better error handling for wait operations;
  • Loading branch information
PedroRauizBeamable committed Jan 23, 2024
1 parent 5b5bc4f commit 473b0d3
Show file tree
Hide file tree
Showing 22 changed files with 1,363 additions and 399 deletions.
4 changes: 2 additions & 2 deletions Plugins/BeamableCore/Content/BP_BeamUtilityMacros.uasset
Git LFS file not shown
Git LFS file not shown
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

void FBeamBackendSpec::Define()
{
Describe("Request/Response", [this]()
Describe("Request/Response", [=, this]()
{
const FBeamRealmHandle FakeRealmHandle{FString("000000000000"), FString("DE_000000000000")};
const FBeamRetryConfig FakeNoRetryConfig{{}, {}, 10, TArray<float>{0.5, 1}, 0};
Expand Down Expand Up @@ -973,7 +973,7 @@ void FBeamBackendSpec::Define()
});
});

Describe("Retry Configurations", [this]()
Describe("Retry Configurations", [=, this]()
{
const FUserSlot TestUserSlot{"TestSlot"};
const FRequestType RequestType{ULoginRefreshTokenRequest::StaticClass()->GetName()};
Expand Down Expand Up @@ -1052,7 +1052,7 @@ void FBeamBackendSpec::Define()
});
});

Describe("Retry Logic", [this]()
Describe("Retry Logic", [=, this]()
{
const FBeamRealmHandle FakeRealmHandle{FString("TEST_CID"), FString("TEST_PID")};
const FBeamRetryConfig FakeResponseCodeRetryConfig{{503}, {}, 10, TArray<float>{0.5, 1}, 1};
Expand Down Expand Up @@ -1226,7 +1226,7 @@ void FBeamBackendSpec::Define()
});
});

Describe("Connectivity", [this]()
Describe("Connectivity", [=, this]()
{
BeforeEach([this]()
{
Expand Down Expand Up @@ -1343,7 +1343,7 @@ void FBeamBackendSpec::Define()
});
});

Describe("Dedicated Servers", [this]()
Describe("Dedicated Servers", [=, this]()
{
BeforeEach([this]()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void FBeamResponseCacheSpec::Define()
BeamResponseCache->ClearNonGlobalConfigs();
});

It("should not hit cache if cache was never updated.", [this, FakeRealmHandle, FakeNoRetryConfig]()
It("should not hit cache if cache was never updated.", [=, this]()
{
UBeamMockGetRequest* FakeGetRequest = NewObject<UBeamMockGetRequest>();

Expand All @@ -40,7 +40,7 @@ void FBeamResponseCacheSpec::Define()
FakeGetRequest->MarkAsGarbage();
});

It("should update and then retrieve the cache for this request type.", [this, FakeRealmHandle, FakeNoRetryConfig]()
It("should update and then retrieve the cache for this request type.", [=, this]()
{
UBeamMockGetRequest* FakeGetRequest = NewObject<UBeamMockGetRequest>();

Expand All @@ -61,7 +61,7 @@ void FBeamResponseCacheSpec::Define()
FakeGetRequest->MarkAsGarbage();
});

It("should update the cache for this request type, but fail to retrieve it when hitting a different layer of the hierarchy.", [this, FakeRealmHandle, FakeNoRetryConfig]()
It("should update the cache for this request type, but fail to retrieve it when hitting a different layer of the hierarchy.", [=, this]()
{
UBeamMockGetRequest* FakeGetRequest = NewObject<UBeamMockGetRequest>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ void FBeamContentObjectSpec::Define()
WithoutOptionals = WithoutOptionals.Replace(TEXT("₢UnrealClassB₢"), *TestUnrealClassB);


Describe("Content Serialization", [this, TestId, TestVersion, TestValueAInt, TestBeamCid, TestValueA, TestValueB, TestSoftObjPath, TestUnrealClassA, TestValueBInt, TestGameplayTagA, TestGameplayTagB, TestUnrealClassB]()
Describe("Content Serialization", [=, this]()
{
BeforeEach([this, TestId, TestVersion, TestValueAInt, TestBeamCid, TestValueA, TestValueB, TestSoftObjPath, TestUnrealClassA, TestGameplayTagA, TestGameplayTagB, TestValueBInt, TestUnrealClassB]()
BeforeEach([=, this]()
{
ContentObject = NewObject<UMockBeamContentObject>();
ContentObject->Id = TestId;
Expand Down Expand Up @@ -374,12 +374,12 @@ void FBeamContentObjectSpec::Define()
ContentObject->UnrealClassMap = TMap<FString, UClass*>{{TEXT("a"), FSoftClassPath{TestUnrealClassA}.ResolveClass()}, {TEXT("b"), FSoftClassPath{TestUnrealClassB}.ResolveClass()}};
});

AfterEach([this]()
AfterEach([=, this]()
{
ContentObject = nullptr;
});

It("should serialize ids and version", [this, TestId, TestVersion]()
It("should serialize ids and version", [=, this]()
{
FString Json = FString{};
ContentObject->ToBasicJson(Json);
Expand All @@ -392,7 +392,7 @@ void FBeamContentObjectSpec::Define()
NewObj = nullptr;
});

It("should serialize primitives properly", [this, TestValueAInt]()
It("should serialize primitives properly", [=, this]()
{
FString Json = FString{};
ContentObject->ToBasicJson(Json);
Expand All @@ -404,7 +404,7 @@ void FBeamContentObjectSpec::Define()
NewObj = nullptr;
});

It("should serialize semantic types properly", [this, TestBeamCid]()
It("should serialize semantic types properly", [=, this]()
{
FString Json = FString{};
ContentObject->ToBasicJson(Json);
Expand All @@ -416,7 +416,7 @@ void FBeamContentObjectSpec::Define()
NewObj = nullptr;
});

It("should serialize gameplay tags properly", [this, TestGameplayTagA, TestGameplayTagB]()
It("should serialize gameplay tags properly", [=, this]()
{
FString Json = FString{};
ContentObject->ToBasicJson(Json);
Expand All @@ -436,7 +436,7 @@ void FBeamContentObjectSpec::Define()
NewObj = nullptr;
});

It("should serialize UClass* properly", [this, TestUnrealClassA, TestUnrealClassB]()
It("should serialize UClass* properly", [=, this]()
{
FString Json = FString{};
ContentObject->ToBasicJson(Json);
Expand All @@ -456,7 +456,7 @@ void FBeamContentObjectSpec::Define()
NewObj = nullptr;
});

It("should serialize FSoftObjectPtr<> types properly", [this, TestSoftObjPath]()
It("should serialize FSoftObjectPtr<> types properly", [=, this]()
{
FString Json = FString{};
ContentObject->ToBasicJson(Json);
Expand All @@ -468,7 +468,7 @@ void FBeamContentObjectSpec::Define()
NewObj = nullptr;
});

It("should serialize TArray<> properly", [this, TestValueBInt, TestValueAInt, TestValueB, TestValueA, TestBeamCid]()
It("should serialize TArray<> properly", [=, this]()
{
FString Json = FString{};
ContentObject->ToBasicJson(Json);
Expand All @@ -484,7 +484,7 @@ void FBeamContentObjectSpec::Define()
TestEqual("String Array serialized correctly", NewObj->ArrayOfBeamCid[0], FBeamCid{TestBeamCid});
});

It("should serialize TMap<FString,> properly", [this, TestValueAInt, TestValueA, TestBeamCid]()
It("should serialize TMap<FString,> properly", [=, this]()
{
FString Json = FString{};
ContentObject->ToBasicJson(Json);
Expand All @@ -497,7 +497,7 @@ void FBeamContentObjectSpec::Define()
TestEqual("String Array serialized correctly", NewObj->MapOfBeamCid.FindRef(TEXT("a")), FBeamCid{TestBeamCid});
});

It("should serialize BeamArrays properly", [this, TestValueA, TestValueB]()
It("should serialize BeamArrays properly", [=, this]()
{
FString Json = FString{};
ContentObject->ToBasicJson(Json);
Expand All @@ -512,7 +512,7 @@ void FBeamContentObjectSpec::Define()
TestEqual("TArray<FMapOfString> deserialized correctly", NewObj->ArrayOfMapOfString[1].Values.FindRef(TEXT("a")), TestValueB);
});

It("should serialize BeamMaps properly", [this, TestValueA, TestValueB]()
It("should serialize BeamMaps properly", [=, this]()
{
FString Json = FString{};
ContentObject->ToBasicJson(Json);
Expand All @@ -526,7 +526,7 @@ void FBeamContentObjectSpec::Define()
TestEqual("TMap<FString, FMapOfString> deserialized correctly", NewObj->MapOfMapOfString.FindRef("a").Values.FindRef("a"), TestValueA);
});

It("should serialize BeamOptionals properly", [this, TestBeamCid, TestValueAInt, TestValueBInt]()
It("should serialize BeamOptionals properly", [=, this]()
{
ContentObject->BeamOptionalBool = FOptionalBool(false);
ContentObject->BeamOptionalBeamCid = FOptionalBeamCid(TestBeamCid);
Expand All @@ -551,7 +551,7 @@ void FBeamContentObjectSpec::Define()
TestEqual("Optional of TArray of Semantic Type deserialized correctly", NewObj->BeamOptionalArrayOfBeamPid.Val[0].AsString, TestBeamCid);
});

It("should deserialize BeamOptionals as unset when they are not in the JSON", [this]()
It("should deserialize BeamOptionals as unset when they are not in the JSON", [=, this]()
{
FString Json = FString{};
ContentObject->ToBasicJson(Json);
Expand All @@ -567,39 +567,39 @@ void FBeamContentObjectSpec::Define()
});
});

Describe("Content Deserialization", [this, FullObject, TestId, TestVersion, TestValueAInt, TestBeamCid, TestGameplayTagA, TestGameplayTagB, TestUnrealClassA, TestUnrealClassB, TestValueBInt, TestValueA, TestValueB, TestSoftObjPath, WithoutOptionals]()
Describe("Content Deserialization", [=, this]()
{
BeforeEach([this]()
BeforeEach([=, this]()
{
ContentObject = NewObject<UMockBeamContentObject>();
});

AfterEach([this]()
AfterEach([=, this]()
{
ContentObject = nullptr;
});

It("should deserialize ids and version properly", [this, FullObject, TestId, TestVersion]()
It("should deserialize ids and version properly", [=, this]()
{
ContentObject->FromBasicJson(FullObject);

TestEqual("Id deserialized correctly", ContentObject->Id, TestId);
TestEqual("Version deserialized correctly", ContentObject->Version, TestVersion);
});

It("should deserialize primitives properly", [this, TestValueAInt, FullObject]()
It("should deserialize primitives properly", [=, this]()
{
ContentObject->FromBasicJson(FullObject);
TestEqual("Value deserialized correctly", ContentObject->Value, TestValueAInt);
});

It("should deserialize semantic types properly", [this, TestBeamCid, FullObject]()
It("should deserialize semantic types properly", [=, this]()
{
ContentObject->FromBasicJson(FullObject);
TestEqual("BeamCid deserialized correctly", ContentObject->BeamCid, FBeamCid{TestBeamCid});
});

It("should deserialize gameplay tags types properly", [this, FullObject, TestGameplayTagA, TestGameplayTagB]()
It("should deserialize gameplay tags types properly", [=, this]()
{
ContentObject->FromBasicJson(FullObject);
TestEqual("GameplayTag deserialized correctly", ContentObject->UnrealGameplayTag.ToString(), TestGameplayTagA);
Expand All @@ -611,7 +611,7 @@ void FBeamContentObjectSpec::Define()
TestEqual("GameplayTag deserialized correctly", ContentObject->GameplayTagsMap.FindRef(TEXT("b")).ToString(), TestGameplayTagB);
});

It("should deserialize UClass tags types properly", [this, TestUnrealClassA, TestUnrealClassB, FullObject]()
It("should deserialize UClass tags types properly", [=, this]()
{
ContentObject->FromBasicJson(FullObject);
TestEqual("GameplayTag deserialized correctly", ContentObject->UnrealClass, FSoftClassPath{TestUnrealClassA}.ResolveClass());
Expand All @@ -623,21 +623,21 @@ void FBeamContentObjectSpec::Define()
TestEqual("GameplayTag deserialized correctly", ContentObject->UnrealClassMap.FindRef(TEXT("b")), FSoftClassPath{TestUnrealClassB}.ResolveClass());
});

It("should deserialize SoftObjectPtr correctly types properly", [this, FullObject, TestSoftObjPath]()
It("should deserialize SoftObjectPtr correctly types properly", [=, this]()
{
ContentObject->FromBasicJson(FullObject);
TestEqual("FSoftObjectPtr deserialized correctly", ContentObject->UnrealSoftObjRef, TSoftObjectPtr<UTexture2D>{FSoftObjectPath(TestSoftObjPath)});
});

It("should deserialize TArray<> properly", [this, FullObject, TestValueAInt, TestValueBInt, TestValueA, TestValueB, TestBeamCid]()
It("should deserialize TArray<> properly", [=, this]()
{
ContentObject->FromBasicJson(FullObject);
TestEqual("U8 Array deserialized correctly", ContentObject->ArrayOfU8, TArray{static_cast<uint8>(TestValueAInt), static_cast<uint8>(TestValueBInt)});
TestEqual("String Array deserialized correctly", ContentObject->ArrayOfString, TArray{TestValueA, TestValueB});
TestEqual("Semantic Type Array deserialized correctly", ContentObject->ArrayOfBeamCid[0], FBeamCid{TestBeamCid});
});

It("should deserialize TMap<FString,> properly", [this, FullObject, TestValueAInt, TestValueA, TestBeamCid]()
It("should deserialize TMap<FString,> properly", [=, this]()
{
ContentObject->FromBasicJson(FullObject);

Expand All @@ -646,7 +646,7 @@ void FBeamContentObjectSpec::Define()
TestEqual("Semantic Type Map deserialized correctly", ContentObject->MapOfBeamCid.FindRef(TEXT("a")), FBeamCid{TestBeamCid});
});

It("should deserialize BeamArrays properly", [this, FullObject, TestValueA, TestValueB]()
It("should deserialize BeamArrays properly", [=, this]()
{
ContentObject->FromBasicJson(FullObject);
TestEqual("FArrayOfString deserialized correctly", ContentObject->BeamArrayOfString.Values[0], TestValueA);
Expand All @@ -656,7 +656,7 @@ void FBeamContentObjectSpec::Define()
TestEqual("TArray<FMapOfString> deserialized correctly", ContentObject->ArrayOfMapOfString[1].Values.FindRef(TEXT("a")), TestValueB);
});

It("should deserialize BeamMaps properly", [this, FullObject, TestValueA, TestValueB]()
It("should deserialize BeamMaps properly", [=, this]()
{
ContentObject->FromBasicJson(FullObject);
TestEqual("FMapOfString deserialized correctly", ContentObject->BeamMapOfString.Values.FindRef(TEXT("a")), TestValueA);
Expand All @@ -666,7 +666,7 @@ void FBeamContentObjectSpec::Define()
});


It("should deserialize BeamOptionals properly", [this, FullObject, TestBeamCid, TestValueAInt, TestValueBInt]()
It("should deserialize BeamOptionals properly", [=, this]()
{
ContentObject->FromBasicJson(FullObject);
TestEqual("Optional of Primitive deserialized correctly", ContentObject->BeamOptionalBool.Val, false);
Expand All @@ -680,7 +680,7 @@ void FBeamContentObjectSpec::Define()
TestEqual("Optional of TArray of Semantic Type deserialized correctly", ContentObject->BeamOptionalArrayOfBeamPid.Val[0].AsString, TestBeamCid);
});

It("should deserialize BeamOptionals as unset when they are not in the JSON", [this, WithoutOptionals]()
It("should deserialize BeamOptionals as unset when they are not in the JSON", [=, this]()
{
ContentObject->FromBasicJson(WithoutOptionals);
TestEqual("Optional of Primitive deserialized correctly", ContentObject->BeamOptionalBool.IsSet, false);
Expand Down
Loading

0 comments on commit 473b0d3

Please sign in to comment.