From db1c29067dad5c03c897c207428e1aaa20564154 Mon Sep 17 00:00:00 2001 From: Joshua Date: Thu, 7 Aug 2025 15:01:34 -0400 Subject: [PATCH] Added a control bool for the auto travel setup Added a control bool for the auto travel setup, and exposed two new variables to the Update Session node --- .../Classes/AdvancedFriendsGameInstance.h | 5 +++++ .../Classes/UpdateSessionCallbackProxyAdvanced.h | 8 +++++++- .../Private/AdvancedFriendsGameInstance.cpp | 7 +++++++ .../Private/UpdateSessionCallbackProxyAdvanced.cpp | 9 +++++++-- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/AdvancedFriendsGameInstance.h b/AdvancedSessions/Source/AdvancedSessions/Classes/AdvancedFriendsGameInstance.h index 29d5018..5a98cb6 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/AdvancedFriendsGameInstance.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/AdvancedFriendsGameInstance.h @@ -44,6 +44,11 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedVoiceInterface) bool bEnableTalkingStatusDelegate; + // If true we will auto travel to a game session when an invite is received. + // This can get in the way of Beacon Sessions, you may want to disable it. + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface) + bool bAutoTravelOnAcceptedUserInviteReceived = true; + //virtual void PostLoad() override; virtual void Shutdown() override; virtual void Init() override; diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/UpdateSessionCallbackProxyAdvanced.h b/AdvancedSessions/Source/AdvancedSessions/Classes/UpdateSessionCallbackProxyAdvanced.h index afdc181..b45ccf3 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/UpdateSessionCallbackProxyAdvanced.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/UpdateSessionCallbackProxyAdvanced.h @@ -21,7 +21,7 @@ class UUpdateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase // Creates a session with the default online subsystem with advanced optional inputs, you MUST fill in all categories or it will pass in values that you didn't want as default values UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions") - static UUpdateSessionCallbackProxyAdvanced* UpdateSession(UObject* WorldContextObject, const TArray &ExtraSettings, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = false, bool bAllowJoinInProgress = false, bool bRefreshOnlineData = true, bool bIsDedicatedServer = false, bool bShouldAdvertise = true); + static UUpdateSessionCallbackProxyAdvanced* UpdateSession(UObject* WorldContextObject, const TArray &ExtraSettings, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = false, bool bAllowJoinInProgress = false, bool bRefreshOnlineData = true, bool bIsDedicatedServer = false, bool bShouldAdvertise = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false); // UOnlineBlueprintCallProxyBase interface virtual void Activate() override; @@ -58,6 +58,12 @@ private: // Allow joining in progress bool bAllowJoinInProgress = true; + // Allow joining in progress + bool bAllowJoinViaPresence = true; + + // Allow joining in progress + bool bAllowJoinViaPresenceFriendsOnly = false; + // Update whether this is a dedicated server or not bool bDedicatedServer = false; diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedFriendsGameInstance.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedFriendsGameInstance.cpp index 706bae5..aa04850 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedFriendsGameInstance.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedFriendsGameInstance.cpp @@ -36,6 +36,13 @@ void UAdvancedFriendsGameInstance::OnSessionUserInviteAccepted(const bool bWasSu void UAdvancedFriendsGameInstance::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type Result) { + + // If we don't want to auto travel to the session instance then exit out + if (!bAutoTravelOnAcceptedUserInviteReceived) + { + return; + } + IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(GetWorld()); if (SessionInterface.IsValid()) { diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp index 31aa9d9..c105aa6 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp @@ -12,7 +12,7 @@ UUpdateSessionCallbackProxyAdvanced::UUpdateSessionCallbackProxyAdvanced(const F { } -UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer, bool bShouldAdvertise) +UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer, bool bShouldAdvertise, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly) { UUpdateSessionCallbackProxyAdvanced* Proxy = NewObject(); Proxy->NumPublicConnections = PublicConnections; @@ -25,6 +25,8 @@ UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::Update Proxy->bAllowJoinInProgress = bAllowJoinInProgress; Proxy->bDedicatedServer = bIsDedicatedServer; Proxy->bShouldAdvertise = bShouldAdvertise; + Proxy->bAllowJoinViaPresence = bAllowJoinViaPresence; + Proxy->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly; return Proxy; } @@ -65,11 +67,14 @@ void UUpdateSessionCallbackProxyAdvanced::Activate() Settings->bAllowJoinInProgress = bAllowJoinInProgress; Settings->bIsLANMatch = bUseLAN; //Settings->bUsesPresence = true; - //Settings->bAllowJoinViaPresence = true; Settings->bAllowInvites = bAllowInvites; Settings->bAllowJoinInProgress = bAllowJoinInProgress; Settings->bIsDedicated = bDedicatedServer; + // Added in 5.6 + Settings->bAllowJoinViaPresence = bAllowJoinViaPresence; + Settings->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly; + FOnlineSessionSetting * fSetting = NULL; FOnlineSessionSetting ExtraSetting; for (int i = 0; i < ExtraSettings.Num(); i++)