From 74d1c04387cda1117c3671fea1b4cb153267ee1f Mon Sep 17 00:00:00 2001 From: AccelbyteBuild Date: Wed, 21 Aug 2024 04:16:15 +0000 Subject: [PATCH] Updated from pipeline, Version : 26.1.1 --- .variables | 13 ++-- AccelByteUe4Sdk.uplugin | 4 +- CHANGELOG.md | 13 ++++ .../Private/Api/AccelByteChatApi.cpp | 41 +++++++---- .../Private/Api/AccelByteLobbyApi.cpp | 70 +++++++++++++------ .../Private/Api/AccelByteQos.cpp | 24 +++++-- .../Private/Core/AccelByteApiClient.cpp | 12 ++-- .../Private/Core/AccelByteCredentials.cpp | 6 +- .../Private/Core/AccelByteMessagingSystem.cpp | 1 + .../Core/AccelByteNotificationBuffer.cpp | 42 +++++------ .../Core/AccelByteNotificationSender.cpp | 14 +++- .../Private/Core/AccelByteRegistry.cpp | 2 +- .../Public/Api/AccelByteChatApi.h | 4 +- .../Public/Api/AccelByteLobbyApi.h | 4 +- .../AccelByteUe4Sdk/Public/Api/AccelByteQos.h | 4 +- .../Public/Core/AccelByteApiClient.h | 8 ++- .../Public/Core/AccelByteBaseCredentials.h | 3 +- .../Public/Core/AccelByteCredentials.h | 2 +- .../Public/Core/AccelByteMessagingSystem.h | 6 +- .../Public/Core/AccelByteNotificationBuffer.h | 20 +++--- .../Public/Core/AccelByteNotificationSender.h | 4 +- .../Public/Core/AccelByteRegistry.h | 2 +- .../Public/Models/AccelByteLobbyModels.h | 2 +- .../Models/AccelByteMatchmakingModels.h | 3 + version.json | 2 +- 25 files changed, 199 insertions(+), 107 deletions(-) diff --git a/.variables b/.variables index e7f52304..4203d7b6 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/7560048138/1409583466/ -export COMMIT_HASH=b54b27248f84e97a2c65627e53236a8b7629026b -export GIT_HASH=b54b27248f84e97a2c65627e53236a8b7629026b -export VERSION=26.1.0 -export REVISION_ID=26.1.0 +export WORKDIR=/tmp/pipelines/7627503846/1420842363/ +export COMMIT_HASH=a81081e5766309e4756cf501493ec919be8b655f +export GIT_HASH=a81081e5766309e4756cf501493ec919be8b655f +export VERSION=26.1.1 +export REVISION_ID=26.1.1 export SLACK_EMAIL=build@accelbyte.net -export COMMIT_MESSAGE_BASE64='Y2hvcmUocmVsZWFzZSk6IDI2LjEuMCAtIGNvbW1pdGVkIGFuZCB0YWdnZWQgYnkgSmVua2luc2Fnc1ZlcnNpb246IjMuNzYuMCIKCg==' +export COMMIT_MESSAGE_BASE64='Y2hvcmUocmVsZWFzZSk6IDI2LjEuMSAtIGNvbW1pdGVkIGFuZCB0YWdnZWQgYnkgSmVua2lucwo=' diff --git a/AccelByteUe4Sdk.uplugin b/AccelByteUe4Sdk.uplugin index 71eeb8ef..7609c65e 100644 --- a/AccelByteUe4Sdk.uplugin +++ b/AccelByteUe4Sdk.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 74, - "VersionName": "26.1.0", + "Version": 75, + "VersionName": "26.1.1", "FriendlyName": "AccelByte Unreal Engine SDK", "Description": "Official AccelByte SDK for Unreal Engine 4", "Category": "Online Platform", diff --git a/CHANGELOG.md b/CHANGELOG.md index 3875d5b7..45ab90b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ 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.1.1](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/branches/compare/26.1.1%0D26.1.0) (2024-08-21) + + +### Features + +* Add TicketID in matchmaking v2 canceled notification model ([f76cb17](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/commits/f76cb17b85337a8db5dfd7238b3a5bb139a51544)) + + +### Bug Fixes + +* access violation when accessing MessagingSystem that has been destroyed ([43c8c01](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/commits/43c8c010319ec84b7df4ab6cf2b5e567808f3ca2)) +* lobby notification buffer SortBuffer method consider SequenceId instead of SentAt ([8b00b90](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/commits/8b00b90d42f9a6c394969d44bf09225168b06106)) + ## [26.1.0](https://bitbucket.org/accelbyte/justice-unreal-sdk-plugin/branches/compare/26.1.0%0D26.0.2) (2024-08-12) diff --git a/Source/AccelByteUe4Sdk/Private/Api/AccelByteChatApi.cpp b/Source/AccelByteUe4Sdk/Private/Api/AccelByteChatApi.cpp index eda484a4..d5c9b26d 100644 --- a/Source/AccelByteUe4Sdk/Private/Api/AccelByteChatApi.cpp +++ b/Source/AccelByteUe4Sdk/Private/Api/AccelByteChatApi.cpp @@ -430,7 +430,11 @@ namespace IncomingMessage , TSharedPtr WebSocket) : FApiBase(InCredentialsRef, InSettingsRef, InHttpRef) , ChatCredentialsRef{InCredentialsRef.AsShared()} - , MessagingSystem{InMessagingSystemRef} +#if ENGINE_MAJOR_VERSION < 5 + , MessagingSystemWPtr{InMessagingSystemRef.AsShared()} +#else + , MessagingSystemWPtr{InMessagingSystemRef.AsWeak()} +#endif , NetworkConditioner{InNetworkConditionerRef} , PingDelay{PingDelay} , InitialBackoffDelay{InitialBackoffDelay} @@ -489,7 +493,13 @@ namespace IncomingMessage void Chat::Disconnect() { FReport::Log(FString(__FUNCTION__)); - MessagingSystem.UnsubscribeFromTopic(EAccelByteMessagingTopic::AuthTokenSet, AuthTokenSetDelegateHandle); + + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + MessagingSystemPtr->UnsubscribeFromTopic(EAccelByteMessagingTopic::AuthTokenSet, AuthTokenSetDelegateHandle); + } + if (WebSocket.IsValid()) { WebSocket->Disconnect(); @@ -516,15 +526,18 @@ namespace IncomingMessage void Chat::OnConnected() { UE_LOG(LogAccelByteChat, Log, TEXT("Connected")); - - AuthTokenSetDelegateHandle = MessagingSystem.SubscribeToTopic(EAccelByteMessagingTopic::AuthTokenSet - , FOnMessagingSystemReceivedMessage::CreateLambda( - [this](FString const& Message) - { - FOauth2Token Token; - FJsonObjectConverter::JsonObjectStringToUStruct(Message, &Token); - RefreshToken(Token.Access_token, RefreshTokenResponse); - })); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + AuthTokenSetDelegateHandle = MessagingSystemPtr->SubscribeToTopic(EAccelByteMessagingTopic::AuthTokenSet + , FOnMessagingSystemReceivedMessage::CreateLambda( + [this](FString const& Message) + { + FOauth2Token Token; + FJsonObjectConverter::JsonObjectStringToUStruct(Message, &Token); + RefreshToken(Token.Access_token, RefreshTokenResponse); + })); + } ConnectSuccess.ExecuteIfBound(); } @@ -553,7 +566,11 @@ namespace IncomingMessage WebSocket->Reconnect(); } - MessagingSystem.UnsubscribeFromTopic(EAccelByteMessagingTopic::AuthTokenSet, AuthTokenSetDelegateHandle); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + MessagingSystemPtr->UnsubscribeFromTopic(EAccelByteMessagingTopic::AuthTokenSet, AuthTokenSetDelegateHandle); + } bBanNotifReceived = false; BanType = EBanType::EMPTY; diff --git a/Source/AccelByteUe4Sdk/Private/Api/AccelByteLobbyApi.cpp b/Source/AccelByteUe4Sdk/Private/Api/AccelByteLobbyApi.cpp index c75f41c4..36c76e97 100644 --- a/Source/AccelByteUe4Sdk/Private/Api/AccelByteLobbyApi.cpp +++ b/Source/AccelByteUe4Sdk/Private/Api/AccelByteLobbyApi.cpp @@ -495,10 +495,14 @@ void Lobby::Disconnect(bool ForceCleanup) FReport::Log(FString(__FUNCTION__)); ChannelSlug = ""; - - MessagingSystem.UnsubscribeFromTopic(EAccelByteMessagingTopic::AuthTokenSet, AuthTokenSetDelegateHandle); - MessagingSystem.UnsubscribeFromTopic(EAccelByteMessagingTopic::NotificationSenderLobby, NotificationSenderListenerDelegateHandle); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + MessagingSystemPtr->UnsubscribeFromTopic(EAccelByteMessagingTopic::AuthTokenSet, AuthTokenSetDelegateHandle); + MessagingSystemPtr->UnsubscribeFromTopic(EAccelByteMessagingTopic::NotificationSenderLobby, NotificationSenderListenerDelegateHandle); + } + NotificationSenderListenerDelegate.Unbind(); if(WebSocket.IsValid()) @@ -2150,20 +2154,26 @@ void Lobby::OnConnected() { UE_LOG(LogAccelByteLobby, Log, TEXT("Connected")); - AuthTokenSetDelegateHandle = MessagingSystem.SubscribeToTopic(EAccelByteMessagingTopic::AuthTokenSet, FOnMessagingSystemReceivedMessage::CreateLambda( - [this](FString const& Message) - { - FOauth2Token Token; - FJsonObjectConverter::JsonObjectStringToUStruct(Message, &Token); - RefreshToken(Token.Access_token); - })); - - NotificationSenderListenerDelegate = FOnMessagingSystemReceivedMessage::CreateRaw(this, &Lobby::OnNotificationSenderMessageReceived); - NotificationSenderListenerDelegateHandle = MessagingSystem.SubscribeToTopic(EAccelByteMessagingTopic::NotificationSenderLobby, NotificationSenderListenerDelegate); - ConnectSuccess.ExecuteIfBound(); - MessagingSystem.SendMessage(EAccelByteMessagingTopic::LobbyConnected); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + AuthTokenSetDelegateHandle = MessagingSystemPtr->SubscribeToTopic(EAccelByteMessagingTopic::AuthTokenSet + , FOnMessagingSystemReceivedMessage::CreateLambda( + [this](FString const& Message) + { + FOauth2Token Token; + FJsonObjectConverter::JsonObjectStringToUStruct(Message, &Token); + RefreshToken(Token.Access_token); + })); + + NotificationSenderListenerDelegate = FOnMessagingSystemReceivedMessage::CreateRaw(this + , &Lobby::OnNotificationSenderMessageReceived); + NotificationSenderListenerDelegateHandle = MessagingSystemPtr->SubscribeToTopic(EAccelByteMessagingTopic::NotificationSenderLobby + , NotificationSenderListenerDelegate); + MessagingSystemPtr->SendMessage(EAccelByteMessagingTopic::LobbyConnected); + } } void Lobby::OnConnectionError(FString const& Error) @@ -2185,9 +2195,12 @@ void Lobby::OnClosed(int32 StatusCode Disconnect(); } - MessagingSystem.UnsubscribeFromTopic(EAccelByteMessagingTopic::AuthTokenSet, AuthTokenSetDelegateHandle); - - MessagingSystem.UnsubscribeFromTopic(EAccelByteMessagingTopic::NotificationSenderLobby, NotificationSenderListenerDelegateHandle); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + MessagingSystemPtr->UnsubscribeFromTopic(EAccelByteMessagingTopic::AuthTokenSet, AuthTokenSetDelegateHandle); + MessagingSystemPtr->UnsubscribeFromTopic(EAccelByteMessagingTopic::NotificationSenderLobby, NotificationSenderListenerDelegateHandle); + } NotificationSenderListenerDelegate.Unbind(); BanNotifReceived = false; @@ -3474,8 +3487,13 @@ void Lobby::SetTokenGenerator(TSharedPtr const& TokenG void Lobby::InitializeMessaging() { - OnReceivedQosLatenciesUpdatedDelegate = FOnMessagingSystemReceivedMessage::CreateRaw(this, &Lobby::OnReceivedQosLatencies); - QosLatenciesUpdatedDelegateHandle = MessagingSystem.SubscribeToTopic(EAccelByteMessagingTopic::QosRegionLatenciesUpdated, OnReceivedQosLatenciesUpdatedDelegate); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + OnReceivedQosLatenciesUpdatedDelegate = FOnMessagingSystemReceivedMessage::CreateRaw(this, &Lobby::OnReceivedQosLatencies); + QosLatenciesUpdatedDelegateHandle = MessagingSystemPtr->SubscribeToTopic(EAccelByteMessagingTopic::QosRegionLatenciesUpdated + , OnReceivedQosLatenciesUpdatedDelegate); + } } Lobby::Lobby(Credentials & InCredentialsRef @@ -3490,7 +3508,11 @@ Lobby::Lobby(Credentials & InCredentialsRef , TSharedPtr InWebSocket) : FApiBase(InCredentialsRef, InSettingsRef, InHttpRef) , LobbyCredentialsRef{InCredentialsRef.AsShared()} - , MessagingSystem{InMessagingSystemRef} +#if ENGINE_MAJOR_VERSION < 5 + , MessagingSystemWPtr{InMessagingSystemRef.AsShared()} +#else + , MessagingSystemWPtr{InMessagingSystemRef.AsWeak()} +#endif , NetworkConditioner{InNetworkConditionerRef} , PingDelay{InPingDelay} , InitialBackoffDelay{InInitialBackoffDelay} @@ -3508,7 +3530,11 @@ Lobby::Lobby(Credentials & InCredentialsRef Lobby::~Lobby() { - MessagingSystem.UnsubscribeFromTopic(EAccelByteMessagingTopic::QosRegionLatenciesUpdated, QosLatenciesUpdatedDelegateHandle); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + MessagingSystemPtr->UnsubscribeFromTopic(EAccelByteMessagingTopic::QosRegionLatenciesUpdated, QosLatenciesUpdatedDelegateHandle); + } OnReceivedQosLatenciesUpdatedDelegate.Unbind(); // only disconnect when engine is still valid diff --git a/Source/AccelByteUe4Sdk/Private/Api/AccelByteQos.cpp b/Source/AccelByteUe4Sdk/Private/Api/AccelByteQos.cpp index 2e40bda2..e2e518ac 100644 --- a/Source/AccelByteUe4Sdk/Private/Api/AccelByteQos.cpp +++ b/Source/AccelByteUe4Sdk/Private/Api/AccelByteQos.cpp @@ -24,7 +24,11 @@ Qos::Qos(Credentials& InCredentialsRef , FAccelByteMessagingSystem& InMessagingSystemRef) : CredentialsRef{InCredentialsRef.AsShared()} , SettingsRef{InSettingsRef} - , MessagingSystem{InMessagingSystemRef} +#if ENGINE_MAJOR_VERSION < 5 + , MessagingSystemWPtr{InMessagingSystemRef.AsShared()} +#else + , MessagingSystemWPtr{InMessagingSystemRef.AsWeak()} +#endif , bValidityFlagPtr(MakeShared(true)) { // Credentials is possibly destroyed before we are so we can't remove @@ -40,7 +44,11 @@ Qos::Qos(Credentials& InCredentialsRef OnLobbyConnectedHandle = FOnMessagingSystemReceivedMessage::CreateRaw(this, &Qos::OnLobbyConnected); - LobbyConnectedDelegateHandle = MessagingSystem.SubscribeToTopic(EAccelByteMessagingTopic::LobbyConnected, OnLobbyConnectedHandle); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + LobbyConnectedDelegateHandle = MessagingSystemPtr->SubscribeToTopic(EAccelByteMessagingTopic::LobbyConnected, OnLobbyConnectedHandle); + } QosUpdateCheckerTickerDelegate = FTickerDelegate::CreateRaw(this, &Qos::CheckQosUpdate); QosUpdateCheckerHandle = FTickerAlias::GetCoreTicker().AddTicker(QosUpdateCheckerTickerDelegate, QosUpdateCheckerIntervalSecs); @@ -48,7 +56,11 @@ Qos::Qos(Credentials& InCredentialsRef Qos::~Qos() { - MessagingSystem.UnsubscribeFromTopic(EAccelByteMessagingTopic::QosRegionLatenciesUpdated, LobbyConnectedDelegateHandle); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + MessagingSystemPtr->UnsubscribeFromTopic(EAccelByteMessagingTopic::QosRegionLatenciesUpdated, LobbyConnectedDelegateHandle); + } OnLobbyConnectedHandle.Unbind(); // Indicate to the OnLoginSuccess lambda that we have been destroyed and `this` is no longer valid. @@ -291,7 +303,11 @@ void Qos::SendQosLatenciesMessage() RegionLatencies.Data.Add(RegionLatency); } - MessagingSystem.SendMessage(EAccelByteMessagingTopic::QosRegionLatenciesUpdated, RegionLatencies); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + MessagingSystemPtr->SendMessage(EAccelByteMessagingTopic::QosRegionLatenciesUpdated, RegionLatencies); + } } void Qos::OnLobbyConnected(const FString& Payload) diff --git a/Source/AccelByteUe4Sdk/Private/Core/AccelByteApiClient.cpp b/Source/AccelByteUe4Sdk/Private/Core/AccelByteApiClient.cpp index dcb97e55..28d7070b 100644 --- a/Source/AccelByteUe4Sdk/Private/Core/AccelByteApiClient.cpp +++ b/Source/AccelByteUe4Sdk/Private/Core/AccelByteApiClient.cpp @@ -9,7 +9,7 @@ namespace AccelByte FApiClient::FApiClient() : bUseSharedCredentials(false) - , MessagingSystem(MakeShared()) + , MessagingSystem(MakeShared()) , CredentialsRef(MakeShared(*MessagingSystem.Get())) , HttpRef(MakeShared()) { @@ -21,12 +21,13 @@ FApiClient::FApiClient() PresenceBroadcastEvent.Startup(); } -FApiClient::FApiClient(AccelByte::Credentials& Credentials, AccelByte::FHttpRetryScheduler& Http, TSharedPtr MessagingRef) +FApiClient::FApiClient(AccelByte::Credentials& Credentials + , AccelByte::FHttpRetryScheduler& Http + , FAccelByteMessagingSystemPtr InMessagingPtr) : bUseSharedCredentials(true) - , MessagingSystem(MessagingRef == nullptr ? MakeShared() : MessagingRef) + , MessagingSystem(InMessagingPtr.IsValid() ? InMessagingPtr: MakeShared()) , CredentialsRef(Credentials.AsShared()) - , HttpRef(MakeShareable(&Http, - [](AccelByte::FHttpRetryScheduler*) {})) + , HttpRef(MakeShareable(&Http, [](AccelByte::FHttpRetryScheduler*) {})) { GameTelemetry.Startup(); PredefinedEvent.Startup(); @@ -40,6 +41,7 @@ FApiClient::~FApiClient() PredefinedEvent.Shutdown(); GameStandardEvent.Shutdown(); PresenceBroadcastEvent.Shutdown(); + MessagingSystem.Reset(); if (!bUseSharedCredentials) { diff --git a/Source/AccelByteUe4Sdk/Private/Core/AccelByteCredentials.cpp b/Source/AccelByteUe4Sdk/Private/Core/AccelByteCredentials.cpp index c7900b4d..3f829379 100644 --- a/Source/AccelByteUe4Sdk/Private/Core/AccelByteCredentials.cpp +++ b/Source/AccelByteUe4Sdk/Private/Core/AccelByteCredentials.cpp @@ -23,9 +23,9 @@ namespace AccelByte Credentials::Credentials(FAccelByteMessagingSystem& MessagingRef) : AuthToken() #if ENGINE_MAJOR_VERSION < 5 - , MessagingSystem(MessagingRef.AsShared()) + , MessagingSystemWPtr(MessagingRef.AsShared()) #else - , MessagingSystem(MessagingRef.AsWeak()) + , MessagingSystemWPtr(MessagingRef.AsWeak()) #endif , RefreshTokenTask(nullptr) { @@ -133,7 +133,7 @@ void Credentials::SetAuthToken(const FOauth2Token& NewAuthToken, float CurrentTi BackoffCount = 0; SessionState = ESessionState::Valid; - auto MessagingSystemPtr = MessagingSystem.Pin(); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); if (MessagingSystemPtr.IsValid()) { diff --git a/Source/AccelByteUe4Sdk/Private/Core/AccelByteMessagingSystem.cpp b/Source/AccelByteUe4Sdk/Private/Core/AccelByteMessagingSystem.cpp index ea9363b0..d61d043b 100644 --- a/Source/AccelByteUe4Sdk/Private/Core/AccelByteMessagingSystem.cpp +++ b/Source/AccelByteUe4Sdk/Private/Core/AccelByteMessagingSystem.cpp @@ -22,6 +22,7 @@ FAccelByteMessagingSystem::FAccelByteMessagingSystem() FAccelByteMessagingSystem::~FAccelByteMessagingSystem() { + UnsubscribeAll(); FTickerAlias::GetCoreTicker().RemoveTicker(PollHandle); } diff --git a/Source/AccelByteUe4Sdk/Private/Core/AccelByteNotificationBuffer.cpp b/Source/AccelByteUe4Sdk/Private/Core/AccelByteNotificationBuffer.cpp index 39e76262..60e60753 100644 --- a/Source/AccelByteUe4Sdk/Private/Core/AccelByteNotificationBuffer.cpp +++ b/Source/AccelByteUe4Sdk/Private/Core/AccelByteNotificationBuffer.cpp @@ -48,7 +48,7 @@ bool AccelByte::FAccelByteNotificationBuffer::AddMissingNotifications(const TArr // Add missing notification if it doesn't exist in buffer and its not the last valid notification for (const FAccelByteModelsUserNotification& Notification : Notifications) { - if ( (Notification.SequenceID.Equals(LastSequenceID) && Notification.SequenceNumber <= LastSequenceNumber) + if ( (Notification.SequenceID == LastSequenceID && Notification.SequenceNumber <= LastSequenceNumber) || IsExistInBuffer(Notification.SequenceID, Notification.SequenceNumber)) { continue; @@ -62,17 +62,17 @@ bool AccelByte::FAccelByteNotificationBuffer::AddMissingNotifications(const TArr return true; } -FDateTime AccelByte::FAccelByteNotificationBuffer::GetLastNotificationReceivedTime() +FDateTime AccelByte::FAccelByteNotificationBuffer::GetLastNotificationReceivedTime() const { return LastSentAt; } -FString AccelByte::FAccelByteNotificationBuffer::GetLastNotificationSequenceID() +int32 AccelByte::FAccelByteNotificationBuffer::GetLastNotificationSequenceID() const { return LastSequenceID; } -int32 AccelByte::FAccelByteNotificationBuffer::GetLastNotificationSequenceNumber() +int32 AccelByte::FAccelByteNotificationBuffer::GetLastNotificationSequenceNumber() const { return LastSequenceNumber; } @@ -95,7 +95,7 @@ TArray AccelByte::FAccelByteNotificationBuffer return Buffer; } -bool AccelByte::FAccelByteNotificationBuffer::IsBuffering() +bool AccelByte::FAccelByteNotificationBuffer::IsBuffering() const { return bBuffering; } @@ -107,40 +107,40 @@ void AccelByte::FAccelByteNotificationBuffer::UpdateLastSequence(const FAccelByt LastSentAt = InNotification.SentAt; } -bool AccelByte::FAccelByteNotificationBuffer::HasValidSequence(const FAccelByteModelsUserNotification& InNotification) +bool AccelByte::FAccelByteNotificationBuffer::HasValidSequence(const FAccelByteModelsUserNotification& InNotification) const { - if (InNotification.SequenceNumber <= 0 || InNotification.SequenceID.IsEmpty()) + if (InNotification.SequenceNumber <= 0 || InNotification.SequenceID < 0) { - UE_LOG(LogAccelByteNotificationBuffer, Warning, TEXT("Notification has invalid sequence, sequenceID: %s, sequenceNumber: %d"), *InNotification.SequenceID, InNotification.SequenceNumber) + UE_LOG(LogAccelByteNotificationBuffer, Warning, TEXT("Notification has invalid sequence, sequenceID: %d, sequenceNumber: %d"), InNotification.SequenceID, InNotification.SequenceNumber) return false; } return true; } -bool AccelByte::FAccelByteNotificationBuffer::IsNotificationMissing(const FAccelByteModelsUserNotification& InNotification) +bool AccelByte::FAccelByteNotificationBuffer::IsNotificationMissing(const FAccelByteModelsUserNotification& InNotification) const { // This is the first notification. - if (LastSequenceID.IsEmpty() && LastSequenceNumber == 0 && LastSentAt == FDateTime{0}) + if (LastSequenceID == 0 && LastSequenceNumber == 0 && LastSentAt == FDateTime{0}) { return false; } // No reconnection occured (same SequenceID) and SequenceNumber Incremented by one. - if (LastSequenceID.Equals(InNotification.SequenceID) && LastSequenceNumber == InNotification.SequenceNumber - 1) + if (LastSequenceID == InNotification.SequenceID && LastSequenceNumber == InNotification.SequenceNumber - 1) { return false; } UE_LOG(LogAccelByteNotificationBuffer, Warning - , TEXT("Missing notification detected, last valid notification (LastSequenceID: %s, LastSequenceNumber: %d, LastSentAt: %s), incoming notification (SequenceID: %s, SequenceNumber: %d, SentAt: %s)") - , *LastSequenceID, LastSequenceNumber, *LastSentAt.ToIso8601() - , *InNotification.SequenceID, InNotification.SequenceNumber, *InNotification.SentAt.ToIso8601()) + , TEXT("Missing notification detected, last valid notification (LastSequenceID: %d, LastSequenceNumber: %d, LastSentAt: %s), incoming notification (SequenceID: %d, SequenceNumber: %d, SentAt: %s)") + , LastSequenceID, LastSequenceNumber, *LastSentAt.ToIso8601() + , InNotification.SequenceID, InNotification.SequenceNumber, *InNotification.SentAt.ToIso8601()) return true; } -bool AccelByte::FAccelByteNotificationBuffer::IsDuplicateNotification(const FAccelByteModelsUserNotification& InNotification) +bool AccelByte::FAccelByteNotificationBuffer::IsDuplicateNotification(const FAccelByteModelsUserNotification& InNotification) const { - if (LastSequenceID.Equals(InNotification.SequenceID) && InNotification.SequenceNumber <= LastSequenceNumber) + if (LastSequenceID == InNotification.SequenceID && InNotification.SequenceNumber <= LastSequenceNumber) { FString OutJsonString; FJsonObjectConverter::UStructToJsonObjectString(InNotification, OutJsonString); @@ -150,12 +150,12 @@ bool AccelByte::FAccelByteNotificationBuffer::IsDuplicateNotification(const FAcc return false; } -bool AccelByte::FAccelByteNotificationBuffer::IsExistInBuffer(const FString& InSequenceID, const int32& InSequenceNumber) +bool AccelByte::FAccelByteNotificationBuffer::IsExistInBuffer(const int32 InSequenceID, const int32 InSequenceNumber) const { return Buffer.ContainsByPredicate( - [&InSequenceID, &InSequenceNumber](const FAccelByteModelsUserNotification& Notif) + [InSequenceID, InSequenceNumber](const FAccelByteModelsUserNotification& Notif) { - return Notif.SequenceID.Equals(InSequenceID) && Notif.SequenceNumber == InSequenceNumber; + return Notif.SequenceID == InSequenceID && Notif.SequenceNumber == InSequenceNumber; }); } @@ -169,11 +169,11 @@ void AccelByte::FAccelByteNotificationBuffer::SortBuffer() { Buffer.Sort([](const FAccelByteModelsUserNotification& A, const FAccelByteModelsUserNotification& B) { - if (A.SentAt == B.SentAt) + if (A.SequenceID == B.SequenceID) { return A.SequenceNumber < B.SequenceNumber; } - return A.SentAt < B.SentAt; + return A.SequenceID < B.SequenceID; }); } diff --git a/Source/AccelByteUe4Sdk/Private/Core/AccelByteNotificationSender.cpp b/Source/AccelByteUe4Sdk/Private/Core/AccelByteNotificationSender.cpp index de0e0437..8f15549b 100644 --- a/Source/AccelByteUe4Sdk/Private/Core/AccelByteNotificationSender.cpp +++ b/Source/AccelByteUe4Sdk/Private/Core/AccelByteNotificationSender.cpp @@ -68,13 +68,21 @@ namespace AccelByte return LobbyMessage; } - FAccelByteNotificationSender::FAccelByteNotificationSender(FAccelByteMessagingSystem& MessagingSystem) - : MessagingSystem(MessagingSystem) + FAccelByteNotificationSender::FAccelByteNotificationSender(FAccelByteMessagingSystem& InMessagingSystemRef) +#if ENGINE_MAJOR_VERSION < 5 + : MessagingSystemWPtr{InMessagingSystemRef.AsShared()} +#else + : MessagingSystemWPtr{InMessagingSystemRef.AsWeak()} +#endif { } void FAccelByteNotificationSender::SendLobbyNotification(const FString& Message) const { - MessagingSystem.SendMessage(EAccelByteMessagingTopic::NotificationSenderLobby, Message); + auto MessagingSystemPtr = MessagingSystemWPtr.Pin(); + if (MessagingSystemPtr.IsValid()) + { + MessagingSystemPtr->SendMessage(EAccelByteMessagingTopic::NotificationSenderLobby, Message); + } } } diff --git a/Source/AccelByteUe4Sdk/Private/Core/AccelByteRegistry.cpp b/Source/AccelByteUe4Sdk/Private/Core/AccelByteRegistry.cpp index 068aa8a1..59443270 100644 --- a/Source/AccelByteUe4Sdk/Private/Core/AccelByteRegistry.cpp +++ b/Source/AccelByteUe4Sdk/Private/Core/AccelByteRegistry.cpp @@ -75,7 +75,7 @@ using namespace AccelByte; #pragma region Core FHttpRetryScheduler FRegistry::HttpRetryScheduler; -TSharedPtr FRegistry::MessagingSystem = MakeShared(); +FAccelByteMessagingSystemPtr FRegistry::MessagingSystem = MakeShared(); Settings FRegistry::Settings; FCredentialsRef FRegistry::CredentialsRef { MakeShared(*MessagingSystem.Get()) }; Credentials& FRegistry::Credentials { FRegistry::CredentialsRef.Get() }; diff --git a/Source/AccelByteUe4Sdk/Public/Api/AccelByteChatApi.h b/Source/AccelByteUe4Sdk/Public/Api/AccelByteChatApi.h index 298e237e..97dca862 100644 --- a/Source/AccelByteUe4Sdk/Public/Api/AccelByteChatApi.h +++ b/Source/AccelByteUe4Sdk/Public/Api/AccelByteChatApi.h @@ -55,8 +55,8 @@ class ACCELBYTEUE4SDK_API Chat : public FApiBase private: const FString ChatSessionHeaderName = TEXT("X-Ab-ChatSessionID"); - TSharedRef ChatCredentialsRef; - FAccelByteMessagingSystem& MessagingSystem; + FCredentialsRef ChatCredentialsRef; + FAccelByteMessagingSystemWPtr MessagingSystemWPtr; FAccelByteNetworkConditioner& NetworkConditioner; bool bBanNotifReceived = false; diff --git a/Source/AccelByteUe4Sdk/Public/Api/AccelByteLobbyApi.h b/Source/AccelByteUe4Sdk/Public/Api/AccelByteLobbyApi.h index 047c4390..5b94874c 100644 --- a/Source/AccelByteUe4Sdk/Public/Api/AccelByteLobbyApi.h +++ b/Source/AccelByteUe4Sdk/Public/Api/AccelByteLobbyApi.h @@ -76,8 +76,8 @@ class ACCELBYTEUE4SDK_API Lobby : public FApiBase , TSharedPtr InWebSocket = nullptr); ~Lobby(); private: - TSharedRef LobbyCredentialsRef; - FAccelByteMessagingSystem& MessagingSystem; + FCredentialsRef LobbyCredentialsRef; + FAccelByteMessagingSystemWPtr MessagingSystemWPtr; FAccelByteNetworkConditioner& NetworkConditioner; const FString LobbyPlatformIdHeaderName = "X-Ab-Platform"; diff --git a/Source/AccelByteUe4Sdk/Public/Api/AccelByteQos.h b/Source/AccelByteUe4Sdk/Public/Api/AccelByteQos.h index 3f8eff87..e0bd3b86 100644 --- a/Source/AccelByteUe4Sdk/Public/Api/AccelByteQos.h +++ b/Source/AccelByteUe4Sdk/Public/Api/AccelByteQos.h @@ -72,9 +72,9 @@ class ACCELBYTEUE4SDK_API Qos private: // Constructor - TSharedRef CredentialsRef; + FCredentialsRef CredentialsRef; const Settings& SettingsRef; - FAccelByteMessagingSystem& MessagingSystem; + FAccelByteMessagingSystemWPtr MessagingSystemWPtr; TSharedPtr bValidityFlagPtr = nullptr; static FAccelByteModelsQosServerList QosServers; diff --git a/Source/AccelByteUe4Sdk/Public/Core/AccelByteApiClient.h b/Source/AccelByteUe4Sdk/Public/Core/AccelByteApiClient.h index a25e7edf..101ce9fe 100644 --- a/Source/AccelByteUe4Sdk/Public/Core/AccelByteApiClient.h +++ b/Source/AccelByteUe4Sdk/Public/Core/AccelByteApiClient.h @@ -62,16 +62,18 @@ class ACCELBYTEUE4SDK_API FApiClient final { public: FApiClient(); - FApiClient(AccelByte::Credentials& Credentials, AccelByte::FHttpRetryScheduler& Http, TSharedPtr MessagingSystemRef = nullptr); + FApiClient(AccelByte::Credentials& Credentials + , AccelByte::FHttpRetryScheduler& Http + , TSharedPtr InMessagingSystemPtr = nullptr); ~FApiClient(); #pragma region Core bool bUseSharedCredentials; - TSharedPtr MessagingSystem{}; - FAccelByteNotificationSender NotificationSender{*MessagingSystem.Get()}; + FAccelByteMessagingSystemPtr MessagingSystem{}; FCredentialsRef CredentialsRef; FHttpRetrySchedulerRef HttpRef{}; FAccelByteTimeManager TimeManager{ *HttpRef }; + FAccelByteNotificationSender NotificationSender{ *MessagingSystem.Get() }; FAccelByteNetworkConditioner NetworkConditioner{}; #pragma endregion diff --git a/Source/AccelByteUe4Sdk/Public/Core/AccelByteBaseCredentials.h b/Source/AccelByteUe4Sdk/Public/Core/AccelByteBaseCredentials.h index 61f822a4..b6f118c5 100644 --- a/Source/AccelByteUe4Sdk/Public/Core/AccelByteBaseCredentials.h +++ b/Source/AccelByteUe4Sdk/Public/Core/AccelByteBaseCredentials.h @@ -91,6 +91,7 @@ class ACCELBYTEUE4SDK_API BaseCredentials }; typedef TSharedRef FBaseCredentialsRef; -typedef TSharedPtr FBaseCredentialsPtr; +typedef TSharedPtr FBaseCredentialsPtr; +typedef TWeakPtr FBaseCredentialsWPtr; } // Namespace AccelByte diff --git a/Source/AccelByteUe4Sdk/Public/Core/AccelByteCredentials.h b/Source/AccelByteUe4Sdk/Public/Core/AccelByteCredentials.h index c6907f1a..8a6ac4a6 100644 --- a/Source/AccelByteUe4Sdk/Public/Core/AccelByteCredentials.h +++ b/Source/AccelByteUe4Sdk/Public/Core/AccelByteCredentials.h @@ -90,7 +90,7 @@ class ACCELBYTEUE4SDK_API Credentials FOnLogoutSuccessDelegate LogoutSuccessDelegate{}; FAccountUserData AccountUserData; TMap ThirdPartyPlatformTokenData; - TWeakPtr MessagingSystem; + FAccelByteMessagingSystemWPtr MessagingSystemWPtr; FAccelByteTaskWPtr RefreshTokenTask; diff --git a/Source/AccelByteUe4Sdk/Public/Core/AccelByteMessagingSystem.h b/Source/AccelByteUe4Sdk/Public/Core/AccelByteMessagingSystem.h index 189ce0d3..85f47bd5 100644 --- a/Source/AccelByteUe4Sdk/Public/Core/AccelByteMessagingSystem.h +++ b/Source/AccelByteUe4Sdk/Public/Core/AccelByteMessagingSystem.h @@ -19,7 +19,7 @@ DECLARE_DELEGATE_OneParam(FOnMessagingSystemReceivedMessage, const FString& /* P DECLARE_MULTICAST_DELEGATE_OneParam(FOnMessagingSystemReceivedMessageMulti, const FString& /* Payload */) class ACCELBYTEUE4SDK_API FAccelByteMessagingSystem - : public TSharedFromThis + : public TSharedFromThis { public: FAccelByteMessagingSystem(); @@ -121,4 +121,8 @@ class ACCELBYTEUE4SDK_API FAccelByteMessagingSystem return Payload; } }; + +typedef TSharedRef FAccelByteMessagingSystemRef; +typedef TSharedPtr FAccelByteMessagingSystemPtr; +typedef TWeakPtr FAccelByteMessagingSystemWPtr; } diff --git a/Source/AccelByteUe4Sdk/Public/Core/AccelByteNotificationBuffer.h b/Source/AccelByteUe4Sdk/Public/Core/AccelByteNotificationBuffer.h index 8185c263..1a717887 100644 --- a/Source/AccelByteUe4Sdk/Public/Core/AccelByteNotificationBuffer.h +++ b/Source/AccelByteUe4Sdk/Public/Core/AccelByteNotificationBuffer.h @@ -36,21 +36,21 @@ namespace AccelByte * * @return The FDateTime object representing the time last notification received. */ - FDateTime GetLastNotificationReceivedTime(); + FDateTime GetLastNotificationReceivedTime() const; /** * @brief Get the sequence ID of the last valid notification. * - * @return String representing last valid sequence ID. + * @return integer representing last valid sequence ID. */ - FString GetLastNotificationSequenceID(); + int32 GetLastNotificationSequenceID() const; /** * @brief Get the sequence number of the last valid notification. * * @return integer representing last valid sequence number. */ - int32 GetLastNotificationSequenceNumber(); + int32 GetLastNotificationSequenceNumber() const; /** * @brief Clear all buffered notifications. @@ -69,12 +69,12 @@ namespace AccelByte * * @return true if buffering. */ - bool IsBuffering(); + bool IsBuffering() const; private: bool bBuffering{false}; - FString LastSequenceID{}; + int32 LastSequenceID{0}; int32 LastSequenceNumber{0}; FDateTime LastSentAt{0}; @@ -82,10 +82,10 @@ namespace AccelByte TArray Buffer; void UpdateLastSequence(const FAccelByteModelsUserNotification& InNotification); - bool HasValidSequence(const FAccelByteModelsUserNotification& InNotification); - bool IsNotificationMissing(const FAccelByteModelsUserNotification& InNotification); - bool IsDuplicateNotification(const FAccelByteModelsUserNotification& InNotification); - bool IsExistInBuffer(const FString& InSequenceID, const int32& InSequenceNumber); + bool HasValidSequence(const FAccelByteModelsUserNotification& InNotification) const; + bool IsNotificationMissing(const FAccelByteModelsUserNotification& InNotification) const; + bool IsDuplicateNotification(const FAccelByteModelsUserNotification& InNotification) const; + bool IsExistInBuffer(const int32 InSequenceID, const int32 InSequenceNumber) const; void AddToBuffer(const FAccelByteModelsUserNotification& InNotification); void SortBuffer(); }; diff --git a/Source/AccelByteUe4Sdk/Public/Core/AccelByteNotificationSender.h b/Source/AccelByteUe4Sdk/Public/Core/AccelByteNotificationSender.h index 6b47caf4..761e9be0 100644 --- a/Source/AccelByteUe4Sdk/Public/Core/AccelByteNotificationSender.h +++ b/Source/AccelByteUe4Sdk/Public/Core/AccelByteNotificationSender.h @@ -46,12 +46,12 @@ class ACCELBYTEUE4SDK_API FAccelByteNotificationSenderUtility class ACCELBYTEUE4SDK_API FAccelByteNotificationSender { public: - explicit FAccelByteNotificationSender(FAccelByteMessagingSystem& MessagingSystem); + explicit FAccelByteNotificationSender(FAccelByteMessagingSystem& InMessagingSystemRef); void SendLobbyNotification(const FString& Message) const; private: - FAccelByteMessagingSystem& MessagingSystem; + FAccelByteMessagingSystemWPtr MessagingSystemWPtr; }; } \ No newline at end of file diff --git a/Source/AccelByteUe4Sdk/Public/Core/AccelByteRegistry.h b/Source/AccelByteUe4Sdk/Public/Core/AccelByteRegistry.h index 5a3946a2..05fd6c09 100644 --- a/Source/AccelByteUe4Sdk/Public/Core/AccelByteRegistry.h +++ b/Source/AccelByteUe4Sdk/Public/Core/AccelByteRegistry.h @@ -103,7 +103,7 @@ class ACCELBYTEUE4SDK_API FRegistry static FServerCredentialsRef ServerCredentialsRef; static ServerCredentials& ServerCredentials; static FAccelByteTimeManager TimeManager; - static TSharedPtr MessagingSystem; + static FAccelByteMessagingSystemPtr MessagingSystem; static FAccelByteNetworkConditioner NetworkConditioner; static FAccelByteNotificationSender NotificationSender; static FHttpClient HttpClient; diff --git a/Source/AccelByteUe4Sdk/Public/Models/AccelByteLobbyModels.h b/Source/AccelByteUe4Sdk/Public/Models/AccelByteLobbyModels.h index d84da2ac..19b29afd 100644 --- a/Source/AccelByteUe4Sdk/Public/Models/AccelByteLobbyModels.h +++ b/Source/AccelByteUe4Sdk/Public/Models/AccelByteLobbyModels.h @@ -1524,7 +1524,7 @@ struct ACCELBYTEUE4SDK_API FAccelByteModelsUserNotification UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AccelByte | Category | Models | Lobby | UserNotification") FDateTime SentAt{0}; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AccelByte | Category | Models | Lobby | UserNotification") - FString SequenceID{}; + int32 SequenceID{0}; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AccelByte | Category | Models | Lobby | UserNotification") int32 SequenceNumber{0}; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AccelByte | Category | Models | Lobby | UserNotification") diff --git a/Source/AccelByteUe4Sdk/Public/Models/AccelByteMatchmakingModels.h b/Source/AccelByteUe4Sdk/Public/Models/AccelByteMatchmakingModels.h index 7842f87b..3362ed60 100644 --- a/Source/AccelByteUe4Sdk/Public/Models/AccelByteMatchmakingModels.h +++ b/Source/AccelByteUe4Sdk/Public/Models/AccelByteMatchmakingModels.h @@ -262,6 +262,9 @@ struct ACCELBYTEUE4SDK_API FAccelByteModelsV2MatchmakingCanceledNotif UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AccelByte | Server | Matchmaking | v2 | Models | MatchmakingCanceledNotif") FString Reason{}; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AccelByte | Server | Matchmaking | v2 | Models | MatchmakingCanceledNotif") + FString TicketID{}; }; USTRUCT(BlueprintType) diff --git a/version.json b/version.json index 83b1aa6c..b69fe517 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "26.1.0" + "version": "26.1.1" }