From 0cfeac7495719c237e74a6f5ae3e80dcd6eaecf2 Mon Sep 17 00:00:00 2001 From: AccelbyteBuild Date: Thu, 7 Nov 2024 12:20:40 +0000 Subject: [PATCH] Updated from pipeline, Version : 26.3.1 --- .variables | 13 +-- CHANGELOG.md | 10 ++ .../Private/AccelByteUe4SdkModule.cpp | 4 +- .../Private/Api/AccelByteChatApi.cpp | 27 +++-- .../Private/Api/AccelByteGameTelemetryApi.cpp | 34 +++--- .../Private/Api/AccelByteLobbyApi.cpp | 103 +++++++++++------- .../Private/Api/AccelByteTurnManagerApi.cpp | 2 +- .../Private/Core/AccelByteApiClient.cpp | 26 ++++- .../Private/Core/AccelByteRegistry.cpp | 7 +- .../Private/Core/AccelByteServerSettings.cpp | 8 +- .../Public/Api/AccelByteChatApi.h | 10 +- .../Public/Api/AccelByteGameTelemetryApi.h | 13 ++- .../Public/Api/AccelByteLobbyApi.h | 19 +++- .../Public/Core/AccelByteApiClient.h | 36 ++++-- .../Public/Core/AccelByteRegistry.h | 7 +- .../Public/Models/AccelByteChallengeModels.h | 3 +- version.json | 2 +- 17 files changed, 222 insertions(+), 102 deletions(-) diff --git a/.variables b/.variables index d9941145..9161fdf3 100644 --- a/.variables +++ b/.variables @@ -1,10 +1,9 @@ -export DO_UPDATE=true export LEVEL=CRITICAL export REPO_NAME=justice-unreal-sdk-plugin -export WORKDIR=/tmp/pipelines/8222839531/1519193148/ -export COMMIT_HASH=3101fd8361b05d4052eb2b8188072b2c537fd417 -export GIT_HASH=3101fd8361b05d4052eb2b8188072b2c537fd417 -export VERSION=26.3.0 -export REVISION_ID=26.3.0 +export WORKDIR=/tmp/pipelines/8295288212/1531474268/ +export COMMIT_HASH=d39e3b59bc0b60f7db9a59af369b0f5f339d3390 +export GIT_HASH=d39e3b59bc0b60f7db9a59af369b0f5f339d3390 +export VERSION=26.3.1 +export REVISION_ID=26.3.1 export SLACK_EMAIL=build@accelbyte.net -export COMMIT_MESSAGE_BASE64='Y2hvcmUocmVsZWFzZSk6IDI2LjMuMCAtIGNvbW1pdGVkIGFuZCB0YWdnZWQgYnkgSmVua2luc2Fnc1ZlcnNpb246IjIwMjQuMSIKCg==' +export COMMIT_MESSAGE_BASE64='Y2hvcmUocmVsZWFzZSk6IDI2LjMuMSAtIGNvbW1pdGVkIGFuZCB0YWdnZWQgYnkgSmVua2lucwo=' diff --git a/CHANGELOG.md b/CHANGELOG.md index 715f63e2..b17b17e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [26.3.1](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/branches/compare/26.3.1%0D26.3.0) (2024-11-07) + + +### Bug Fixes + +* **AMS:** make heartbeat as optional and change error message for AMS parameters ([5de3fec](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/commits/5de3fec5240ee63bac13b025f891973d3f2c3b46)) +* **challenge:** add missing enum member CUSTOM in EAccelByteModelsChallengeAssignmentRule ([2553488](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/commits/255348832847d5dbd06244b4ab43ed1f176dd96b)) +* **gameTelemetry:** change TSharedPtr to TSharedPtr ([9cb2754](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/commits/9cb275462cdfba90e707cbf01de28a20f413e2a2)) +* **lobby, chat:** move to sharedPtr ([89ab8af](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/commits/89ab8af1ce7a47be22753f24639ce5ffc693be7f)) + ## [26.3.0](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/branches/compare/26.3.0%0D26.2.1) (2024-10-30) diff --git a/Source/AccelByteUe4Sdk/Private/AccelByteUe4SdkModule.cpp b/Source/AccelByteUe4Sdk/Private/AccelByteUe4SdkModule.cpp index 404dc7b6..4eff7be4 100644 --- a/Source/AccelByteUe4Sdk/Private/AccelByteUe4SdkModule.cpp +++ b/Source/AccelByteUe4Sdk/Private/AccelByteUe4SdkModule.cpp @@ -19,6 +19,7 @@ #include "Api/AccelBytePredefinedEventApi.h" #include "Api/AccelByteGameStandardEventApi.h" #include "Api/AccelByteQos.h" +#include "Api/AccelByteLobbyApi.h" #include "Core/ServerTime/AccelByteTimeManager.h" #include "GameServerApi/AccelByteServerAMSApi.h" #include "Engine/GameInstance.h" @@ -106,6 +107,7 @@ void FAccelByteUe4SdkModule::StartupModule() AccelByte::FRegistry::GameTelemetryPtr->Startup(); AccelByte::FRegistry::PredefinedEventPtr->Startup(); AccelByte::FRegistry::GameStandardEventPtr->Startup(); + AccelByte::FRegistry::LobbyPtr->Startup(); #if !UE_SERVER AccelByte::FRegistry::HeartBeat.Startup(); #endif @@ -424,7 +426,7 @@ void FAccelByteUe4SdkModule::OnGameInstanceCreated(UGameInstance* GameInstance) { if (!AccelByte::FRegistry::ServerSettings.LoadAMSSettings()) { - UE_LOG(LogAccelByte, Warning, TEXT("dsid not provided, not connecting to AMS")); + UE_LOG(LogAccelByte, Log, TEXT("Dedicated server is not connected to AMS.")); } else { diff --git a/Source/AccelByteUe4Sdk/Private/Api/AccelByteChatApi.cpp b/Source/AccelByteUe4Sdk/Private/Api/AccelByteChatApi.cpp index b283dece..e185d05b 100644 --- a/Source/AccelByteUe4Sdk/Private/Api/AccelByteChatApi.cpp +++ b/Source/AccelByteUe4Sdk/Private/Api/AccelByteChatApi.cpp @@ -449,6 +449,8 @@ namespace IncomingMessage { if(UObjectInitialized()) { + UnbindEvent(); + Disconnect(); ReconnectAttempted.Clear(); MassiveOutage.Clear(); } @@ -477,12 +479,12 @@ namespace IncomingMessage *this /*Reconnect Strategy*/, PingDelay); - WebSocket->OnConnected().AddRaw(this, &Chat::OnConnected); - WebSocket->OnMessageReceived().AddRaw(this, &Chat::OnMessage); - WebSocket->OnConnectionError().AddRaw(this, &Chat::OnConnectionError); - WebSocket->OnConnectionClosed().AddRaw(this, &Chat::OnClosed); - WebSocket->OnReconnectAttempt().AddRaw(this, &Chat::OnReconnectAttempt); - WebSocket->OnMassiveOutage().AddRaw(this, &Chat::OnMassiveOutage); + WebSocket->OnConnected().AddThreadSafeSP(AsShared(), &Chat::OnConnected); + WebSocket->OnMessageReceived().AddThreadSafeSP(AsShared(), &Chat::OnMessage); + WebSocket->OnConnectionError().AddThreadSafeSP(AsShared(), &Chat::OnConnectionError); + WebSocket->OnConnectionClosed().AddThreadSafeSP(AsShared(), &Chat::OnClosed); + WebSocket->OnReconnectAttempt().AddThreadSafeSP(AsShared(), &Chat::OnReconnectAttempt); + WebSocket->OnMassiveOutage().AddThreadSafeSP(AsShared(), &Chat::OnMassiveOutage); } void Chat::Connect() @@ -542,13 +544,18 @@ namespace IncomingMessage auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); if (MessagingSystemPtr.IsValid()) { + ChatWPtr ChatWeak = AsShared(); AuthTokenSetDelegateHandle = MessagingSystemPtr->SubscribeToTopic(EAccelByteMessagingTopic::AuthTokenSet , FOnMessagingSystemReceivedMessage::CreateLambda( - [this](FString const& Message) + [ChatWeak](FString const& Message) { - FOauth2Token Token; - FJsonObjectConverter::JsonObjectStringToUStruct(Message, &Token); - RefreshToken(Token.Access_token, RefreshTokenResponse); + auto ChatApi = ChatWeak.Pin(); + if (ChatApi.IsValid()) + { + FOauth2Token Token; + FJsonObjectConverter::JsonObjectStringToUStruct(Message, &Token); + ChatApi->RefreshToken(Token.Access_token, ChatApi->RefreshTokenResponse); + } })); } diff --git a/Source/AccelByteUe4Sdk/Private/Api/AccelByteGameTelemetryApi.cpp b/Source/AccelByteUe4Sdk/Private/Api/AccelByteGameTelemetryApi.cpp index 92b925c2..741d1517 100644 --- a/Source/AccelByteUe4Sdk/Private/Api/AccelByteGameTelemetryApi.cpp +++ b/Source/AccelByteUe4Sdk/Private/Api/AccelByteGameTelemetryApi.cpp @@ -39,7 +39,7 @@ void GameTelemetry::OnLoginSuccess(FOauth2Token const& Response) { if (bCacheEvent) { - TWeakPtr GameTelemetryWeak = AsShared(); + GameTelemetryWPtr GameTelemetryWeak = AsShared(); AsyncTask(ENamedThreads::AnyBackgroundThreadNormalTask, [GameTelemetryWeak]() { const auto GameTelemetryApi = GameTelemetryWeak.Pin(); @@ -109,12 +109,12 @@ void GameTelemetry::Send(FAccelByteModelsTelemetryBody TelemetryBody if (ImmediateEvents.Contains(TelemetryBody.EventName)) { - SendProtectedEvents({ MakeShared(TelemetryBody) }, OnSuccess, OnError); + SendProtectedEvents({ MakeShared(TelemetryBody) }, OnSuccess, OnError); } else { - TSharedPtr TelemetryPtr = MakeShared(TelemetryBody); - JobQueue.Enqueue(TTuple, FVoidHandler, FErrorHandler>{ TelemetryPtr, OnSuccess, OnError }); + TelemetryBodyPtr TelemetryPtr = MakeShared(TelemetryBody); + JobQueue.Enqueue(TTuple{ TelemetryPtr, OnSuccess, OnError }); if (bCacheEvent || CriticalEvents.Contains(TelemetryBody.EventName)) { GameTelemetryWPtr GameTelemetryWeak = AsShared(); @@ -186,12 +186,12 @@ bool GameTelemetry::PeriodicTelemetry(float DeltaTime) { FReport::Log(FString(__FUNCTION__)); - TArray> TelemetryBodies; + TArray TelemetryBodies; TArray OnSuccessCallbacks; TArray OnErrorCallbacks; while (!JobQueue.IsEmpty()) { - TTuple, FVoidHandler, FErrorHandler> DequeueResult; + TTuple DequeueResult; if (JobQueue.Dequeue(DequeueResult)) { TelemetryBodies.Add(DequeueResult.Get<0>()); @@ -199,7 +199,7 @@ bool GameTelemetry::PeriodicTelemetry(float DeltaTime) OnErrorCallbacks.Add(DequeueResult.Get<2>()); } } - TWeakPtr GameTelemetryWeak = AsShared(); + GameTelemetryWPtr GameTelemetryWeak = AsShared(); SendProtectedEvents(TelemetryBodies , FVoidHandler::CreateLambda( [GameTelemetryWeak, OnSuccessCallbacks, TelemetryBodies]() @@ -227,7 +227,7 @@ bool GameTelemetry::PeriodicTelemetry(float DeltaTime) { for (int i = 0; i < TelemetryBodies.Num(); i++) { - GameTelemetryApi->JobQueue.Enqueue(TTuple, FVoidHandler, FErrorHandler> + GameTelemetryApi->JobQueue.Enqueue(TTuple { TelemetryBodies[i], i < OnSuccessCallbacks.Num() ? OnSuccessCallbacks[i] : FVoidHandler{}, @@ -247,7 +247,7 @@ bool GameTelemetry::PeriodicTelemetry(float DeltaTime) return true; } -void GameTelemetry::SendProtectedEvents(TArray> const& Events +void GameTelemetry::SendProtectedEvents(TArray const& Events , FVoidHandler const& OnSuccess , FErrorHandler const& OnError) { @@ -301,7 +301,7 @@ void GameTelemetry::LoadCachedEvents() bCacheUpdated = true; - TWeakPtr GameTelemetryWeak = AsShared(); + GameTelemetryWPtr GameTelemetryWeak = AsShared(); IAccelByteUe4SdkModuleInterface::Get().GetLocalDataStorage()->GetItem(TelemetryKey , THandler>::CreateLambda( [GameTelemetryWeak](TPair Pair) @@ -311,7 +311,7 @@ void GameTelemetry::LoadCachedEvents() return; } const auto GameTelemetryApi = GameTelemetryWeak.Pin(); - TArray> EventList; + TArray EventList; if (GameTelemetryApi.IsValid() && GameTelemetryApi->EventsJsonToArray(Pair.Value, EventList)) { @@ -337,7 +337,7 @@ void GameTelemetry::LoadCachedEvents() { for (int i = 0; i < EventList.Num(); i++) { - GameTelemetryApi->JobQueue.Enqueue(TTuple, FVoidHandler, FErrorHandler> + GameTelemetryApi->JobQueue.Enqueue(TTuple { EventList[i], FVoidHandler{}, FErrorHandler{} }); } } @@ -349,7 +349,7 @@ void GameTelemetry::LoadCachedEvents() } //Should be called from async task -void GameTelemetry::AppendEventToCache(TSharedPtr Telemetry) +void GameTelemetry::AppendEventToCache(TelemetryBodyPtr Telemetry) { FString TelemetryKey = GetTelemetryKey(); if (TelemetryKey.IsEmpty()) @@ -399,7 +399,7 @@ void GameTelemetry::AppendEventToCache(TSharedPtr } //Should be called from async task -void GameTelemetry::RemoveEventsFromCache(TArray> const& Events) +void GameTelemetry::RemoveEventsFromCache(TArray const& Events) { FString TelemetryKey = GetTelemetryKey(); if (TelemetryKey.IsEmpty()) @@ -436,7 +436,7 @@ bool GameTelemetry::JobArrayQueueAsJsonString(FString& OutJsonString) { TSharedRef TelemetryObj = MakeShared(); TArray> EventsObjArray; - TArray> TempEventPtrArray; + TArray TempEventPtrArray; { FScopeLock ScopeLock(&EventPtrArrayLock); TempEventPtrArray = EventPtrArray; @@ -473,7 +473,7 @@ const FString GameTelemetry::GetEventNamespace() } bool GameTelemetry::EventsJsonToArray(FString& InJsonString - , TArray>& OutArray) + , TArray& OutArray) { TSharedPtr JsonObjectPtr{ MakeShared() }; @@ -505,7 +505,7 @@ bool GameTelemetry::EventsJsonToArray(FString& InJsonString TelemetryBody.Payload = JsonObj->GetObjectField(TEXT("Payload")); ClientTimestamp = JsonObj->GetIntegerField(TEXT("ClientTimestamp")); TelemetryBody.ClientTimestamp = FDateTime::FromUnixTimestamp(ClientTimestamp); - OutArray.Add(MakeShared(TelemetryBody)); + OutArray.Add(MakeShared(TelemetryBody)); } return true; } diff --git a/Source/AccelByteUe4Sdk/Private/Api/AccelByteLobbyApi.cpp b/Source/AccelByteUe4Sdk/Private/Api/AccelByteLobbyApi.cpp index 73833e9b..c0828103 100644 --- a/Source/AccelByteUe4Sdk/Private/Api/AccelByteLobbyApi.cpp +++ b/Source/AccelByteUe4Sdk/Private/Api/AccelByteLobbyApi.cpp @@ -461,6 +461,8 @@ void Lobby::Connect(FString const& Token) { FReport::Log(FString(__FUNCTION__)); + Startup(); + if(TokenGenerator.IsValid() && Token.IsEmpty()) { TokenGenerator->RequestToken(); @@ -2214,6 +2216,7 @@ void Lobby::UnbindV2MatchmakingEvents() V2MatchmakingMatchFoundNotif.Unbind(); V2MatchmakingExpiredNotif.Unbind(); V2MatchmakingStartNotif.Unbind(); + V2MatchmakingCanceledNotif.Unbind(); } void Lobby::OnNotificationSenderMessageReceived(FString const& Payload) @@ -2231,16 +2234,21 @@ void Lobby::OnConnected() auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); if (MessagingSystemPtr.IsValid()) { + LobbyWPtr LobbyWeak = AsShared(); AuthTokenSetDelegateHandle = MessagingSystemPtr->SubscribeToTopic(EAccelByteMessagingTopic::AuthTokenSet , FOnMessagingSystemReceivedMessage::CreateLambda( - [this](FString const& Message) + [LobbyWeak](FString const& Message) { - FOauth2Token Token; - FJsonObjectConverter::JsonObjectStringToUStruct(Message, &Token); - RefreshToken(Token.Access_token); + auto LobbyApi = LobbyWeak.Pin(); + if (LobbyApi.IsValid()) + { + FOauth2Token Token; + FJsonObjectConverter::JsonObjectStringToUStruct(Message, &Token); + LobbyApi->RefreshToken(Token.Access_token); + } })); - NotificationSenderListenerDelegate = FOnMessagingSystemReceivedMessage::CreateRaw(this + NotificationSenderListenerDelegate = FOnMessagingSystemReceivedMessage::CreateThreadSafeSP(AsShared() , &Lobby::OnNotificationSenderMessageReceived); NotificationSenderListenerDelegateHandle = MessagingSystemPtr->SubscribeToTopic(EAccelByteMessagingTopic::NotificationSenderLobby , NotificationSenderListenerDelegate); @@ -2361,12 +2369,12 @@ void Lobby::CreateWebSocket(FString const& Token) , PingDelay ); - WebSocket->OnConnected().AddRaw(this, &Lobby::OnConnected); - WebSocket->OnMessageReceived().AddRaw(this, &Lobby::OnMessage, false); - WebSocket->OnConnectionError().AddRaw(this, &Lobby::OnConnectionError); - WebSocket->OnConnectionClosed().AddRaw(this, &Lobby::OnClosed); - WebSocket->OnReconnectAttempt().AddRaw(this, &Lobby::OnReconnectAttempt); - WebSocket->OnMassiveOutage().AddRaw(this, &Lobby::OnMassiveOutage); + WebSocket->OnConnected().AddThreadSafeSP(AsShared(), &Lobby::OnConnected); + WebSocket->OnMessageReceived().AddThreadSafeSP(AsShared(), &Lobby::OnMessage, false); + WebSocket->OnConnectionError().AddThreadSafeSP(AsShared(), &Lobby::OnConnectionError); + WebSocket->OnConnectionClosed().AddThreadSafeSP(AsShared(), &Lobby::OnClosed); + WebSocket->OnReconnectAttempt().AddThreadSafeSP(AsShared(), &Lobby::OnReconnectAttempt); + WebSocket->OnMassiveOutage().AddThreadSafeSP(AsShared(), &Lobby::OnMassiveOutage); } FString Lobby::LobbyMessageToJson(FString const& Message) @@ -3183,16 +3191,21 @@ void Lobby::HandleMessageNotif(FString const& ReceivedMessageType UnbanSchedules.Remove(Key); } + LobbyWPtr LobbyWeak = AsShared(); TSharedRef Data = MakeShared(Result); FUnbanScheduleRef NewSchedule = MakeShared(); NewSchedule->DelegateHandle = FTickerAlias::GetCoreTicker().AddTicker(FTickerDelegate::CreateLambda( - [this, Data, ScheduledTime](float DeltaTime) + [LobbyWeak, Data, ScheduledTime](float DeltaTime) { + auto LobbyApi = LobbyWeak.Pin(); double CurrentTime = FPlatformTime::Seconds(); - if (CurrentTime >= ScheduledTime) + if (!LobbyApi.IsValid() || CurrentTime >= ScheduledTime) { - Data->Enable = false; - UserUnbannedNotification.ExecuteIfBound(*Data); + if (LobbyApi.IsValid()) + { + Data->Enable = false; + LobbyApi->UserUnbannedNotification.ExecuteIfBound(*Data); + } return false; } return true; @@ -3349,8 +3362,8 @@ bool Lobby::TryBufferNotification(FString const& ParsedJsonString) UE_LOG(LogAccelByteLobby, Warning, TEXT("Missing notification(s) detected, received: %s"), *ParsedJsonString); // get missing notification from the time last valid (still in order) received notification up to the most recent received notification - GetNotifications(THandler::CreateRaw(this, &Lobby::OnGetMissingNotificationSuccess) - ,FErrorHandler::CreateRaw(this, &Lobby::OnGetMissingNotificationError)); + GetNotifications(THandler::CreateThreadSafeSP(AsShared(), &Lobby::OnGetMissingNotificationSuccess) + ,FErrorHandler::CreateThreadSafeSP(AsShared(), &Lobby::OnGetMissingNotificationError)); return true; } @@ -3501,27 +3514,36 @@ FAccelByteTaskWPtr Lobby::WritePartyStorageRecursive(TSharedPtrPartyId , THandler::CreateLambda( - [this, DataWrapper](FAccelByteModelsPartyDataNotif Result) + [LobbyWeak, DataWrapper](FAccelByteModelsPartyDataNotif Result) { - Result.Custom_attribute = DataWrapper->PayloadModifier(Result.Custom_attribute); + auto LobbyApi = LobbyWeak.Pin(); + if (LobbyApi.IsValid()) + { + Result.Custom_attribute = DataWrapper->PayloadModifier(Result.Custom_attribute); - FAccelByteModelsPartyDataUpdateRequest PartyStorageBodyRequest; + FAccelByteModelsPartyDataUpdateRequest PartyStorageBodyRequest; - PartyStorageBodyRequest.UpdatedAt = FCString::Atoi64(*Result.UpdatedAt); - PartyStorageBodyRequest.Custom_attribute = Result.Custom_attribute; + PartyStorageBodyRequest.UpdatedAt = FCString::Atoi64(*Result.UpdatedAt); + PartyStorageBodyRequest.Custom_attribute = Result.Custom_attribute; - RequestWritePartyStorage(DataWrapper->PartyId - , PartyStorageBodyRequest - , DataWrapper->OnSuccess - , DataWrapper->OnError - , FSimpleDelegate::CreateLambda( - [this, DataWrapper]() - { - DataWrapper->RemainingAttempt--; - WritePartyStorageRecursive(DataWrapper); - })); + LobbyApi->RequestWritePartyStorage(DataWrapper->PartyId + , PartyStorageBodyRequest + , DataWrapper->OnSuccess + , DataWrapper->OnError + , FSimpleDelegate::CreateLambda( + [LobbyWeak, DataWrapper]() + { + DataWrapper->RemainingAttempt--; + auto LobbyApi = LobbyWeak.Pin(); + if (LobbyApi.IsValid()) + { + LobbyApi->WritePartyStorageRecursive(DataWrapper); + } + })); + } }) , FErrorHandler::CreateLambda( [DataWrapper](int32 ErrorCode, FString ErrorMessage) @@ -3583,7 +3605,7 @@ void Lobby::SetTokenGenerator(TSharedPtr const& TokenG if (TokenGeneratorRef.IsValid()) { - OnTokenReceivedDelegateHandle = TokenGenerator->OnTokenReceived().AddRaw(this, &Lobby::OnTokenReceived); + OnTokenReceivedDelegateHandle = TokenGenerator->OnTokenReceived().AddThreadSafeSP(AsShared(), &Lobby::OnTokenReceived); } } @@ -3592,7 +3614,7 @@ void Lobby::InitializeMessaging() auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); if (MessagingSystemPtr.IsValid()) { - OnReceivedQosLatenciesUpdatedDelegate = FOnMessagingSystemReceivedMessage::CreateRaw(this, &Lobby::OnReceivedQosLatencies); + OnReceivedQosLatenciesUpdatedDelegate = FOnMessagingSystemReceivedMessage::CreateThreadSafeSP(AsShared(), &Lobby::OnReceivedQosLatencies); QosLatenciesUpdatedDelegateHandle = MessagingSystemPtr->SubscribeToTopic(EAccelByteMessagingTopic::QosRegionLatenciesUpdated , OnReceivedQosLatenciesUpdatedDelegate); } @@ -3621,9 +3643,6 @@ Lobby::Lobby(Credentials & InCredentialsRef , TimeSinceConnectionLost{.0f} { InitializeV2MatchmakingNotifTopics(); - InitializeMessaging(); - - LobbyTickerHandle = FTickerAlias::GetCoreTicker().AddTicker(FTickerDelegate::CreateRaw(this, &Lobby::Tick), LobbyTickPeriod); auto Strategy = FReconnectionStrategy::CreateBalancedStrategy( FReconnectionStrategy::FBalancedMaxRetryInterval(FTimespan::FromSeconds(InMaxBackoffDelay)), @@ -3680,5 +3699,15 @@ void Lobby::OnReceivedQosLatencies(FString const& Payload) ChangeUserRegion(ClosestRegion); } +void Lobby::Startup() +{ + if (!bIsStarted) + { + InitializeMessaging(); + LobbyTickerHandle = FTickerAlias::GetCoreTicker().AddTicker(FTickerDelegate::CreateThreadSafeSP(AsShared(), &Lobby::Tick), LobbyTickPeriod); + bIsStarted = true; + } +} + } // Namespace Api } // Namespace AccelByte diff --git a/Source/AccelByteUe4Sdk/Private/Api/AccelByteTurnManagerApi.cpp b/Source/AccelByteUe4Sdk/Private/Api/AccelByteTurnManagerApi.cpp index d2bfe999..38589827 100644 --- a/Source/AccelByteUe4Sdk/Private/Api/AccelByteTurnManagerApi.cpp +++ b/Source/AccelByteUe4Sdk/Private/Api/AccelByteTurnManagerApi.cpp @@ -161,7 +161,7 @@ FAccelByteTaskWPtr TurnManager::GetTurnServerLatencyByRegion(const FString& Regi FAccelBytePing::SendUdpPing(*TurnServer->Ip, TurnServer->Qos_port , 10.0f , FPingCompleteDelegate::CreateLambda( - [this, TurnServer, OnSuccess, &Region](FPingResult PingResult) + [OnSuccess](FPingResult PingResult) { const int32 Milliseconds = FMath::RoundToInt(PingResult.AverageRoundTrip * 1000); OnSuccess.ExecuteIfBound(Milliseconds); diff --git a/Source/AccelByteUe4Sdk/Private/Core/AccelByteApiClient.cpp b/Source/AccelByteUe4Sdk/Private/Core/AccelByteApiClient.cpp index 33e966ec..b73d4c21 100644 --- a/Source/AccelByteUe4Sdk/Private/Core/AccelByteApiClient.cpp +++ b/Source/AccelByteUe4Sdk/Private/Core/AccelByteApiClient.cpp @@ -15,6 +15,10 @@ FApiClient::FApiClient() , GameTelemetryPtr(MakeShared(*CredentialsRef, FRegistry::Settings, *HttpRef)) , PredefinedEventPtr( MakeShared(*CredentialsRef, FRegistry::Settings, *HttpRef)) , GameStandardEventPtr(MakeShared(*CredentialsRef, FRegistry::Settings, *HttpRef)) + , LobbyPtr(MakeShared(*CredentialsRef, FRegistry::Settings, *HttpRef, *MessagingSystem.Get(), NetworkConditioner)) + , ChatPtr(MakeShared(*CredentialsRef, FRegistry::Settings, *HttpRef, *MessagingSystem.Get(), NetworkConditioner)) + , Lobby(*LobbyPtr.Get()) + , Chat(*ChatPtr.Get()) , GameTelemetry(*GameTelemetryPtr.Get()) , PredefinedEvent(*PredefinedEventPtr.Get()) , GameStandardEvent(*GameStandardEventPtr.Get()) @@ -25,6 +29,7 @@ FApiClient::FApiClient() PredefinedEventPtr->Startup(); GameStandardEventPtr->Startup(); PresenceBroadcastEvent.Startup(); + LobbyPtr->Startup(); } FApiClient::FApiClient(AccelByte::Credentials& Credentials @@ -37,6 +42,10 @@ FApiClient::FApiClient(AccelByte::Credentials& Credentials , GameTelemetryPtr(MakeShared(*CredentialsRef, FRegistry::Settings, *HttpRef)) , PredefinedEventPtr(MakeShared(*CredentialsRef, FRegistry::Settings, *HttpRef)) , GameStandardEventPtr(MakeShared(*CredentialsRef, FRegistry::Settings, *HttpRef)) + , LobbyPtr(MakeShared(*CredentialsRef, FRegistry::Settings, *HttpRef, *MessagingSystem.Get(), NetworkConditioner)) + , ChatPtr(MakeShared(*CredentialsRef, FRegistry::Settings, *HttpRef, *MessagingSystem.Get(), NetworkConditioner)) + , Lobby(*LobbyPtr.Get()) + , Chat(*ChatPtr.Get()) , GameTelemetry(*GameTelemetryPtr.Get()) , PredefinedEvent(*PredefinedEventPtr.Get()) , GameStandardEvent(*GameStandardEventPtr.Get()) @@ -45,6 +54,7 @@ FApiClient::FApiClient(AccelByte::Credentials& Credentials PredefinedEventPtr->Startup(); GameStandardEventPtr->Startup(); PresenceBroadcastEvent.Startup(); + LobbyPtr->Startup(); } FApiClient::~FApiClient() @@ -78,17 +88,27 @@ FApiClient::~FApiClient() } } -TWeakPtr FApiClient::GetGameTelemetryApi() const +Api::LobbyWPtr FApiClient::GetLobbyApi() const +{ + return LobbyPtr; +} + +Api::ChatWPtr FApiClient::GetChatApi() const +{ + return ChatPtr; +} + +Api::GameTelemetryWPtr FApiClient::GetGameTelemetryApi() const { return GameTelemetryPtr; } -TWeakPtr FApiClient::GetPredefinedEventApi() const +Api::PredefinedEventWPtr FApiClient::GetPredefinedEventApi() const { return PredefinedEventPtr; } -TWeakPtr FApiClient::GetGameStandardEventApi() const +Api::GameStandardEventWPtr FApiClient::GetGameStandardEventApi() const { return GameStandardEventPtr; } diff --git a/Source/AccelByteUe4Sdk/Private/Core/AccelByteRegistry.cpp b/Source/AccelByteUe4Sdk/Private/Core/AccelByteRegistry.cpp index 4a9d2255..857b347d 100644 --- a/Source/AccelByteUe4Sdk/Private/Core/AccelByteRegistry.cpp +++ b/Source/AccelByteUe4Sdk/Private/Core/AccelByteRegistry.cpp @@ -88,6 +88,9 @@ FAccelByteNotificationSender FRegistry::NotificationSender{*MessagingSystem.Get( FHttpClient FRegistry::HttpClient{ Credentials, Settings, HttpRetryScheduler }; #pragma endregion +const Api::LobbyPtr FRegistry::LobbyPtr{ MakeShared(FRegistry::CredentialsRef.Get(), FRegistry::Settings, FRegistry::HttpRetryScheduler, *FRegistry::MessagingSystem.Get(), FRegistry::NetworkConditioner) }; +const Api::ChatPtr FRegistry::ChatPtr{ MakeShared(FRegistry::CredentialsRef.Get(), FRegistry::Settings, FRegistry::HttpRetryScheduler, *FRegistry::MessagingSystem.Get(), FRegistry::NetworkConditioner) }; + const Api::GameTelemetryPtr FRegistry::GameTelemetryPtr{ MakeShared(FRegistry::CredentialsRef.Get(), FRegistry::Settings, FRegistry::HttpRetryScheduler) }; const Api::PredefinedEventPtr FRegistry::PredefinedEventPtr{ MakeShared(FRegistry::CredentialsRef.Get(), FRegistry::Settings, FRegistry::HttpRetryScheduler) }; const Api::GameStandardEventPtr FRegistry::GameStandardEventPtr{ MakeShared(FRegistry::CredentialsRef.Get(), FRegistry::Settings, FRegistry::HttpRetryScheduler) }; @@ -134,8 +137,8 @@ Api::Challenge FRegistry::Challenge{ FRegistry::Credentials, FRegistry::Settings #pragma region Game Client Multiplayer Api::QosManager FRegistry::QosManager{ FRegistry::CredentialsRef.Get(), FRegistry::Settings, FRegistry::HttpRetryScheduler }; Api::Qos FRegistry::Qos{ FRegistry::CredentialsRef.Get(), FRegistry::Settings, *FRegistry::MessagingSystem.Get() }; -Api::Lobby FRegistry::Lobby{ FRegistry::CredentialsRef.Get(), FRegistry::Settings, FRegistry::HttpRetryScheduler, *FRegistry::MessagingSystem.Get(), FRegistry::NetworkConditioner}; -Api::Chat FRegistry::Chat{ FRegistry::CredentialsRef.Get(), FRegistry::Settings, FRegistry::HttpRetryScheduler, *FRegistry::MessagingSystem.Get(), FRegistry::NetworkConditioner}; +Api::Lobby& FRegistry::Lobby{ *FRegistry::LobbyPtr.Get() }; +Api::Chat& FRegistry::Chat{ *FRegistry::ChatPtr.Get() }; Api::SessionBrowser FRegistry::SessionBrowser{ FRegistry::CredentialsRef.Get(), FRegistry::Settings, FRegistry::HttpRetryScheduler }; Api::TurnManager FRegistry::TurnManager{ FRegistry::CredentialsRef.Get(), FRegistry::Settings, HttpRetryScheduler }; Api::Session FRegistry::Session{ FRegistry::CredentialsRef.Get(), FRegistry::Settings, FRegistry::HttpRetryScheduler }; diff --git a/Source/AccelByteUe4Sdk/Private/Core/AccelByteServerSettings.cpp b/Source/AccelByteUe4Sdk/Private/Core/AccelByteServerSettings.cpp index 1d09b734..db6ae845 100644 --- a/Source/AccelByteUe4Sdk/Private/Core/AccelByteServerSettings.cpp +++ b/Source/AccelByteUe4Sdk/Private/Core/AccelByteServerSettings.cpp @@ -5,6 +5,7 @@ #include "Core/AccelByteServerSettings.h" #include "Core/AccelByteRegistry.h" #include "Core/AccelByteUtilities.h" +#include "Core/AccelByteReport.h" using namespace AccelByte; @@ -222,6 +223,8 @@ bool AccelByte::ServerSettings::LoadAMSSettings() // If not exist, then fetch the setting from game default engine ini file if (!GConfig->GetString(*DefaultServerSection, TEXT("WatchdogUrl"), AMSServerWatchdogUrl, GEngineIni)) { + UE_LOG(LogAccelByte, Log, TEXT("Watchdog URL has not been initialised")); + bIsLoadSuccess = false; } } @@ -234,7 +237,8 @@ bool AccelByte::ServerSettings::LoadAMSSettings() { if (!GConfig->GetInt(*DefaultServerSection, TEXT("AMSHeartbeatInterval"), AMSHeartbeatInterval, GEngineIni)) { - bIsLoadSuccess = false; + // Initializing the AMS heartbeat value is optional; the default value is 15. + AMSHeartbeatInterval = 15; } } } @@ -243,6 +247,8 @@ bool AccelByte::ServerSettings::LoadAMSSettings() { if (!FAccelByteUtilities::GetValueFromCommandLineSwitch(TEXT("dsid"), DSId)) { + UE_LOG(LogAccelByte, Log, TEXT("DSID has not been initialised")); + bIsLoadSuccess = false; } } diff --git a/Source/AccelByteUe4Sdk/Public/Api/AccelByteChatApi.h b/Source/AccelByteUe4Sdk/Public/Api/AccelByteChatApi.h index 84d210c8..4f348312 100644 --- a/Source/AccelByteUe4Sdk/Public/Api/AccelByteChatApi.h +++ b/Source/AccelByteUe4Sdk/Public/Api/AccelByteChatApi.h @@ -37,7 +37,10 @@ enum HandleType : uint8; * - public : user can join by knowing topic id * - private: only admin can add or remove member */ -class ACCELBYTEUE4SDK_API Chat : public FApiBase, public IWebsocketConfigurableReconnectStrategy +class ACCELBYTEUE4SDK_API Chat + : public FApiBase + , public IWebsocketConfigurableReconnectStrategy + , public TSharedFromThis { public: Chat(Credentials & InCredentialsRef @@ -1328,6 +1331,9 @@ class ACCELBYTEUE4SDK_API Chat : public FApiBase, public IWebsocketConfigurableR #pragma endregion CHAT CONFIGURATION }; -} // Namespace Api +typedef TSharedRef ChatRef; +typedef TSharedPtr ChatPtr; +typedef TWeakPtr ChatWPtr; +} // Namespace Api } // Namespace AccelByte \ No newline at end of file diff --git a/Source/AccelByteUe4Sdk/Public/Api/AccelByteGameTelemetryApi.h b/Source/AccelByteUe4Sdk/Public/Api/AccelByteGameTelemetryApi.h index b86dfd09..c0dc68ad 100644 --- a/Source/AccelByteUe4Sdk/Public/Api/AccelByteGameTelemetryApi.h +++ b/Source/AccelByteUe4Sdk/Public/Api/AccelByteGameTelemetryApi.h @@ -19,6 +19,7 @@ class Credentials; class Settings; namespace Api { +typedef TSharedPtr< FAccelByteModelsTelemetryBody, ESPMode::ThreadSafe> TelemetryBodyPtr; /** * @brief Send telemetry data securely and the user should be logged in first. @@ -85,7 +86,7 @@ class ACCELBYTEUE4SDK_API GameTelemetry : public FApiBase, public TSharedFromThi bool IsCacheUpdated() { return bCacheUpdated; } private: - void SendProtectedEvents(TArray> const& Events + void SendProtectedEvents(TArray const& Events , FVoidHandler const& OnSuccess , FErrorHandler const& OnError); @@ -93,13 +94,13 @@ class ACCELBYTEUE4SDK_API GameTelemetry : public FApiBase, public TSharedFromThi void LoadCachedEvents(); - void AppendEventToCache(TSharedPtr Telemetry); + void AppendEventToCache(TelemetryBodyPtr Telemetry); void OnLoginSuccess(FOauth2Token const& Response); void OnLogoutSuccess(); - void RemoveEventsFromCache(TArray> const& Events); + void RemoveEventsFromCache(TArray const& Events); bool JobArrayQueueAsJsonString(FString& OutJsonString); @@ -107,7 +108,7 @@ class ACCELBYTEUE4SDK_API GameTelemetry : public FApiBase, public TSharedFromThi protected: bool EventsJsonToArray(FString& InJsonString - , TArray>& OutArray); + , TArray& OutArray); virtual FString GetTelemetryKey(); @@ -123,9 +124,9 @@ class ACCELBYTEUE4SDK_API GameTelemetry : public FApiBase, public TSharedFromThi TSet CriticalEvents; bool bCacheUpdated = false; - TQueue, FVoidHandler, FErrorHandler>> JobQueue{}; + TQueue> JobQueue{}; FString EventPtrArrayAccumulation{};//Contains EventPtrArray that will be written to cache, update by EventPtrArrayAccumulation - TArray> EventPtrArray; + TArray EventPtrArray; mutable FCriticalSection EventPtrArrayLock; bool bTelemetryJobStarted = false; diff --git a/Source/AccelByteUe4Sdk/Public/Api/AccelByteLobbyApi.h b/Source/AccelByteUe4Sdk/Public/Api/AccelByteLobbyApi.h index e3b1e752..5d09b465 100644 --- a/Source/AccelByteUe4Sdk/Public/Api/AccelByteLobbyApi.h +++ b/Source/AccelByteUe4Sdk/Public/Api/AccelByteLobbyApi.h @@ -73,7 +73,10 @@ enum Notif : uint8; * @brief Lobby API for chatting and party management. * Unlike other servers which use HTTP, Lobby server uses WebSocket (RFC 6455). */ -class ACCELBYTEUE4SDK_API Lobby : public FApiBase, public IWebsocketConfigurableReconnectStrategy +class ACCELBYTEUE4SDK_API Lobby + : public FApiBase + , public IWebsocketConfigurableReconnectStrategy + , public TSharedFromThis { public: Lobby(Credentials& InCredentialsRef @@ -1559,7 +1562,7 @@ class ACCELBYTEUE4SDK_API Lobby : public FApiBase, public IWebsocketConfigurable } NotificationMessageDelegateHandle = MessageNotifBroadcaster.AddLambda( - [this, OnNotificationMessage](FAccelByteModelsNotificationMessage const& Message) + [OnNotificationMessage](FAccelByteModelsNotificationMessage const& Message) { OnNotificationMessage.ExecuteIfBound(Message); }); @@ -2838,6 +2841,10 @@ class ACCELBYTEUE4SDK_API Lobby : public FApiBase, public IWebsocketConfigurable */ TSharedPtr LockNotifications(); + /** + * @brief Startup module + */ + void Startup(); private: Lobby(Lobby const&) = delete; // Copy constructor Lobby(Lobby&&) = delete; // Move constructor @@ -3239,10 +3246,18 @@ class ACCELBYTEUE4SDK_API Lobby : public FApiBase, public IWebsocketConfigurable FOnMessagingSystemReceivedMessage NotificationSenderListenerDelegate; FDelegateHandle NotificationSenderListenerDelegateHandle; + bool bIsStarted = false; + void InitializeMessaging(); void OnReceivedQosLatencies(FString const& Payload); + #pragma endregion }; + +typedef TSharedRef LobbyRef; +typedef TSharedPtr LobbyPtr; +typedef TWeakPtr LobbyWPtr; + } // Namespace Api } // Namespace AccelByte diff --git a/Source/AccelByteUe4Sdk/Public/Core/AccelByteApiClient.h b/Source/AccelByteUe4Sdk/Public/Core/AccelByteApiClient.h index e1219d82..118ff751 100644 --- a/Source/AccelByteUe4Sdk/Public/Core/AccelByteApiClient.h +++ b/Source/AccelByteUe4Sdk/Public/Core/AccelByteApiClient.h @@ -65,7 +65,7 @@ class ACCELBYTEUE4SDK_API FApiClient final FApiClient(); FApiClient(AccelByte::Credentials& Credentials , AccelByte::FHttpRetryScheduler& Http - , TSharedPtr InMessagingSystemPtr = nullptr); + , AccelByte::FAccelByteMessagingSystemPtr InMessagingSystemPtr = nullptr); ~FApiClient(); #pragma region Core @@ -79,9 +79,11 @@ class ACCELBYTEUE4SDK_API FApiClient final #pragma endregion private: - const TSharedPtr GameTelemetryPtr; - const TSharedPtr PredefinedEventPtr; - const TSharedPtr GameStandardEventPtr; + const AccelByte::Api::GameTelemetryPtr GameTelemetryPtr; + const AccelByte::Api::PredefinedEventPtr PredefinedEventPtr; + const AccelByte::Api::GameStandardEventPtr GameStandardEventPtr; + const AccelByte::Api::LobbyPtr LobbyPtr; + const AccelByte::Api::ChatPtr ChatPtr; public: #pragma region Access @@ -128,8 +130,21 @@ class ACCELBYTEUE4SDK_API FApiClient final #pragma region Multiplayer Api::QosManager QosManager{ *CredentialsRef, FRegistry::Settings, *HttpRef }; Api::Qos Qos{ *CredentialsRef, FRegistry::Settings, *MessagingSystem.Get() }; - Api::Lobby Lobby{ *CredentialsRef, FRegistry::Settings, *HttpRef, *MessagingSystem.Get(), NetworkConditioner }; - Api::Chat Chat{ *CredentialsRef, FRegistry::Settings, *HttpRef, *MessagingSystem.Get(), NetworkConditioner}; + + /** + * @brief For continuity, this temporary member is included to avoid any build breaks introduced via improvements to the AccelByte Unreal SDK. + * THIS MEMBER IS MARKED FOR DEPRECATION AND WILL BE REMOVED IN A FUTURE RELEASE. + * It is recommended that you update your code as soon as possible, and replace any usage of ApiClient->Lobby with ApiClient->GetLobbyApi().Pin() + */ + Api::Lobby& Lobby; + + /** + * @brief For continuity, this temporary member is included to avoid any build breaks introduced via improvements to the AccelByte Unreal SDK. + * THIS MEMBER IS MARKED FOR DEPRECATION AND WILL BE REMOVED IN A FUTURE RELEASE. + * It is recommended that you update your code as soon as possible, and replace any usage of ApiClient->Chat with ApiClient->GetChatApi().Pin() + */ + Api::Chat& Chat; + Api::SessionBrowser SessionBrowser{ *CredentialsRef, FRegistry::Settings, *HttpRef }; Api::TurnManager TurnManager{ *CredentialsRef, FRegistry::Settings, *HttpRef }; Api::Session Session{ *CredentialsRef, FRegistry::Settings, *HttpRef }; @@ -164,9 +179,12 @@ class ACCELBYTEUE4SDK_API FApiClient final Api::PresenceBroadcastEvent PresenceBroadcastEvent{ *CredentialsRef, FRegistry::Settings, *HttpRef }; #pragma endregion - TWeakPtr GetGameTelemetryApi() const; - TWeakPtr GetPredefinedEventApi() const; - TWeakPtr GetGameStandardEventApi() const; + Api::LobbyWPtr GetLobbyApi() const; + Api::ChatWPtr GetChatApi() const; + + Api::GameTelemetryWPtr GetGameTelemetryApi() const; + Api::PredefinedEventWPtr GetPredefinedEventApi() const; + Api::GameStandardEventWPtr GetGameStandardEventApi() const; template T GetApi(U&&... Args) diff --git a/Source/AccelByteUe4Sdk/Public/Core/AccelByteRegistry.h b/Source/AccelByteUe4Sdk/Public/Core/AccelByteRegistry.h index f3abd154..5c484eb1 100644 --- a/Source/AccelByteUe4Sdk/Public/Core/AccelByteRegistry.h +++ b/Source/AccelByteUe4Sdk/Public/Core/AccelByteRegistry.h @@ -109,6 +109,9 @@ class ACCELBYTEUE4SDK_API FRegistry static FHttpClient HttpClient; #pragma endregion + static const TSharedPtr LobbyPtr; + static const TSharedPtr ChatPtr; + static const TSharedPtr GameTelemetryPtr; static const TSharedPtr PredefinedEventPtr; static const TSharedPtr GameStandardEventPtr; @@ -156,8 +159,8 @@ class ACCELBYTEUE4SDK_API FRegistry #pragma region Game Client Multiplayer static Api::QosManager QosManager; static Api::Qos Qos; - static Api::Lobby Lobby; - static Api::Chat Chat; + static Api::Lobby& Lobby; + static Api::Chat& Chat; static Api::SessionBrowser SessionBrowser; static Api::TurnManager TurnManager; static Api::Session Session; diff --git a/Source/AccelByteUe4Sdk/Public/Models/AccelByteChallengeModels.h b/Source/AccelByteUe4Sdk/Public/Models/AccelByteChallengeModels.h index 8b2c27ea..27e79e1f 100644 --- a/Source/AccelByteUe4Sdk/Public/Models/AccelByteChallengeModels.h +++ b/Source/AccelByteUe4Sdk/Public/Models/AccelByteChallengeModels.h @@ -46,7 +46,8 @@ enum class EAccelByteModelsChallengeAssignmentRule : uint8 NONE = 0, FIXED, RANDOMIZED, - UNSCHEDULED + UNSCHEDULED, + CUSTOM, }; UENUM(BlueprintType) diff --git a/version.json b/version.json index d29c82bf..9d550df5 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "26.3.0" + "version": "26.3.1" }