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
This commit is contained in:
Joshua
2025-08-07 15:01:34 -04:00
parent a6f91c874c
commit ca9797b112
4 changed files with 26 additions and 3 deletions

View File

@@ -44,6 +44,11 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedVoiceInterface) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedVoiceInterface)
bool bEnableTalkingStatusDelegate; 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 PostLoad() override;
virtual void Shutdown() override; virtual void Shutdown() override;
virtual void Init() override; virtual void Init() override;

View File

@@ -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 // 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") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
static UUpdateSessionCallbackProxyAdvanced* UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &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<FSessionPropertyKeyPair> &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 // UOnlineBlueprintCallProxyBase interface
virtual void Activate() override; virtual void Activate() override;
@@ -58,6 +58,12 @@ private:
// Allow joining in progress // Allow joining in progress
bool bAllowJoinInProgress = true; 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 // Update whether this is a dedicated server or not
bool bDedicatedServer = false; bool bDedicatedServer = false;

View File

@@ -47,6 +47,13 @@ void UAdvancedFriendsGameInstance::OnSessionUserInviteAccepted(const bool bWasSu
void UAdvancedFriendsGameInstance::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type Result) 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()); IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(GetWorld());
if (SessionInterface.IsValid()) if (SessionInterface.IsValid())
{ {

View File

@@ -12,7 +12,7 @@ UUpdateSessionCallbackProxyAdvanced::UUpdateSessionCallbackProxyAdvanced(const F
{ {
} }
UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer, bool bShouldAdvertise) UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer, bool bShouldAdvertise, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly)
{ {
UUpdateSessionCallbackProxyAdvanced* Proxy = NewObject<UUpdateSessionCallbackProxyAdvanced>(); UUpdateSessionCallbackProxyAdvanced* Proxy = NewObject<UUpdateSessionCallbackProxyAdvanced>();
Proxy->NumPublicConnections = PublicConnections; Proxy->NumPublicConnections = PublicConnections;
@@ -25,6 +25,8 @@ UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::Update
Proxy->bAllowJoinInProgress = bAllowJoinInProgress; Proxy->bAllowJoinInProgress = bAllowJoinInProgress;
Proxy->bDedicatedServer = bIsDedicatedServer; Proxy->bDedicatedServer = bIsDedicatedServer;
Proxy->bShouldAdvertise = bShouldAdvertise; Proxy->bShouldAdvertise = bShouldAdvertise;
Proxy->bAllowJoinViaPresence = bAllowJoinViaPresence;
Proxy->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
return Proxy; return Proxy;
} }
@@ -65,11 +67,14 @@ void UUpdateSessionCallbackProxyAdvanced::Activate()
Settings->bAllowJoinInProgress = bAllowJoinInProgress; Settings->bAllowJoinInProgress = bAllowJoinInProgress;
Settings->bIsLANMatch = bUseLAN; Settings->bIsLANMatch = bUseLAN;
//Settings->bUsesPresence = true; //Settings->bUsesPresence = true;
//Settings->bAllowJoinViaPresence = true;
Settings->bAllowInvites = bAllowInvites; Settings->bAllowInvites = bAllowInvites;
Settings->bAllowJoinInProgress = bAllowJoinInProgress; Settings->bAllowJoinInProgress = bAllowJoinInProgress;
Settings->bIsDedicated = bDedicatedServer; Settings->bIsDedicated = bDedicatedServer;
// Added in 5.6
Settings->bAllowJoinViaPresence = bAllowJoinViaPresence;
Settings->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
FOnlineSessionSetting * fSetting = NULL; FOnlineSessionSetting * fSetting = NULL;
FOnlineSessionSetting ExtraSetting; FOnlineSessionSetting ExtraSetting;
for (int i = 0; i < ExtraSettings.Num(); i++) for (int i = 0; i < ExtraSettings.Num(); i++)