From 156025af2d864c9b64d6573fcb8ea3c272a06f43 Mon Sep 17 00:00:00 2001 From: Joshua Date: Thu, 10 Jun 2021 09:50:13 -0400 Subject: [PATCH 01/13] update for new session option update for new session option --- .../Classes/CreateSessionCallbackProxyAdvanced.h | 6 +++++- .../Private/CreateSessionCallbackProxyAdvanced.cpp | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h b/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h index 067d6e1..6be8624 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h @@ -24,10 +24,11 @@ class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase * @param PublicConnections When doing a 'listen' server, this must be >=2 (ListenServer itself counts as a connection) * @param bUseLAN When you want to play LAN, the level to play on must be loaded with option 'bIsLanMatch' * @param bUsePresence Must be true for a 'listen' server (Map must be loaded with option 'listen'), false for a 'dedicated' server. + * @param bUseLobbiesIfAvailable Used to flag the subsystem to use a lobby api instead of general hosting if the API supports it. * @param bShouldAdvertise Set to true when the OnlineSubsystem should list your server when someone is searching for servers. Otherwise the server is hidden and only join via invite is possible. */ UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions") - static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true); + static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bUseLobbiesIfAvailable = false, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true); // UOnlineBlueprintCallProxyBase interface virtual void Activate() override; @@ -71,6 +72,9 @@ private: // Whether to use the presence option bool bUsePresence; + // Whether to prefer the use of lobbies for hosting if the api supports them + bool bUseLobbiesIfAvailable; + // Whether to allow joining via presence bool bAllowJoinViaPresence; diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp index 086b8f6..e6b46ee 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp @@ -13,7 +13,7 @@ UCreateSessionCallbackProxyAdvanced::UCreateSessionCallbackProxyAdvanced(const F { } -UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise) +UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bUseLobbiesIfAvailable, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise) { UCreateSessionCallbackProxyAdvanced* Proxy = NewObject(); Proxy->PlayerControllerWeakPtr = PlayerController; @@ -25,6 +25,7 @@ UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::Create Proxy->ExtraSettings = ExtraSettings; Proxy->bDedicatedServer = bIsDedicatedServer; Proxy->bUsePresence = bUsePresence; + Proxy->bUseLobbiesIfAvailable = bUseLobbiesIfAvailable; Proxy->bAllowJoinViaPresence = bAllowJoinViaPresence; Proxy->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly; Proxy->bAntiCheatProtected = bAntiCheatProtected; @@ -57,9 +58,15 @@ void UCreateSessionCallbackProxyAdvanced::Activate() Settings.bIsDedicated = bDedicatedServer; if (bDedicatedServer) + { Settings.bUsesPresence = false; + Settings.bUseLobbiesIfAvailable = false; + } else + { Settings.bUsesPresence = bUsePresence; + Settings.bUseLobbiesIfAvailable = bUseLobbiesIfAvailable; + } Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly; Settings.bAntiCheatProtected = bAntiCheatProtected; From c391737812dea7594d885bdbfab1c260838b1d1a Mon Sep 17 00:00:00 2001 From: Joshua Date: Mon, 9 Aug 2021 15:35:20 -0400 Subject: [PATCH 02/13] fix ADmissing properties fix ADmissing properties --- .../Classes/BlueprintDataDefinitions.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/BlueprintDataDefinitions.h b/AdvancedSessions/Source/AdvancedSessions/Classes/BlueprintDataDefinitions.h index 267f6ea..7e7436b 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/BlueprintDataDefinitions.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/BlueprintDataDefinitions.h @@ -264,10 +264,18 @@ public: EBPOnlinePresenceState PresenceState; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") FString StatusString; + + FBPFriendPresenceInfo() + { + bIsOnline = false; + bIsPlaying = false; + bIsPlayingThisGame = false; + bIsJoinable = false; + bHasVoiceSupport = false; + PresenceState = EBPOnlinePresenceState::Offline; + } }; - - USTRUCT(BlueprintType) struct FBPFriendInfo { @@ -287,8 +295,15 @@ public: bool bIsPlayingSameGame; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") FBPFriendPresenceInfo PresenceInfo; + + FBPFriendInfo() + { + OnlineState = EBPOnlinePresenceState::Offline; + bIsPlayingSameGame = false; + } }; + /** The types of comparison operations for a given search query */ // Used to compare session properties UENUM(BlueprintType) From 1f6b7dbb3b46f1c65e800a4370fc087b947b1f14 Mon Sep 17 00:00:00 2001 From: Joshua Date: Mon, 16 Aug 2021 12:52:44 -0400 Subject: [PATCH 03/13] Added new steam sessions functions IsOverlay Enabled InitTextFiltering FilterText IsSteamInBigPictureMode --- .../Classes/AdvancedSteamFriendsLibrary.h | 34 +++++++++ .../Private/AdvancedSteamFriendsLibrary.cpp | 75 +++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h index 0a35350..aaa37cf 100644 --- a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h +++ b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h @@ -305,6 +305,19 @@ public: }; +UENUM(Blueprintable) +enum class EBPTextFilteringContext : uint8 +{ + /*Unknown context.*/ + FContext_Unknown = 0, + /*Game content, only legally required filtering is performed.*/ + FContext_GameContent = 1, + /*Char from another player.*/ + FContext_Chat = 2, + /*Character or item name.*/ + FContext_Name = 3 +}; + UCLASS() class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary { @@ -325,6 +338,10 @@ public: UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") static bool OpenSteamUserOverlay(const FBPUniqueNetId UniqueNetId, ESteamUserOverlayType DialogType); + // Returns if the steam overlay is currently active (this can return false during initial overlay hooking) + UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI") + static bool IsOverlayEnabled(); + // Gets the level of a friends steam account, STEAM ONLY, Returns -1 if the steam level is not known, might need RequestSteamFriendInfo called first. UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") static int32 GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId); @@ -350,4 +367,21 @@ public: // Get a full list of steam groups UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|SteamGroups") static void GetSteamGroups(TArray & SteamGroups); + + // Initializes text filtering (pre-loading dictonaries) + // Returns if it succeeded, false if filtering is unavailable for the games language + UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering") + static bool InitTextFiltering(); + + // Attempts to filter a string with the given filtering context + // Returns true if the text has been filtered, false if it hasn't (no filtering required or operation failed) + // If false it will still output the original text + // Textsource is the steam id that is the source of the text (player name / chat) + // Requires that InitTextFiltering be called first!! + UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering") + static bool FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText); + + // Returns if steam is running in big picture mode + UFUNCTION(BlueprintPure, Category = "Online|SteamAPI") + static bool IsSteamInBigPictureMode(); }; diff --git a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp index 4c2dc00..1422d17 100644 --- a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp +++ b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp @@ -255,6 +255,19 @@ bool UAdvancedSteamFriendsLibrary::OpenSteamUserOverlay(const FBPUniqueNetId Uni return false; } +bool UAdvancedSteamFriendsLibrary::IsOverlayEnabled() +{ +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX + if (SteamAPI_Init()) + { + return SteamUtils()->IsOverlayEnabled(); + } +#endif + + UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Couldn't init steamAPI!")); + return false; +} + UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize) { #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX @@ -350,4 +363,66 @@ UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueN UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("STEAM Couldn't be verified as initialized")); Result = EBlueprintAsyncResultSwitch::OnFailure; return nullptr; +} + +bool UAdvancedSteamFriendsLibrary::InitTextFiltering() +{ +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX + + if (SteamAPI_Init()) + { + return SteamUtils()->InitFilterText(); + } + +#endif + + return false; +} + +bool UAdvancedSteamFriendsLibrary::FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText) +{ +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX + + if (SteamAPI_Init()) + { + uint32 BufferLen = TextToFilter.Len() + 10; // Docs say 1 byte excess min, going with 10 + char* OutText = new char[BufferLen]; + + uint64 id = 0; + + if (TextSourceID.IsValid()) + { + id = *((uint64*)TextSourceID.UniqueNetId->GetBytes()); + } + + int FilterCount = SteamUtils()->FilterText((ETextFilteringContext)Context, id, TCHAR_TO_ANSI(*TextToFilter), OutText, BufferLen); + + if (FilterCount > 0) + { + FilteredText = FString(UTF8_TO_TCHAR(OutText)); + delete[] OutText; + return true; + } + + delete[] OutText; + } + +#endif + + FilteredText = TextToFilter; + return false; +} + +bool UAdvancedSteamFriendsLibrary::IsSteamInBigPictureMode() +{ +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX + + if (SteamAPI_Init()) + { + return SteamUtils()->IsSteamInBigPictureMode(); + } + +#endif + + return false; } \ No newline at end of file From be6f532c1ef5366375604770b6547835413759da Mon Sep 17 00:00:00 2001 From: Joshua Date: Mon, 16 Aug 2021 12:52:44 -0400 Subject: [PATCH 04/13] Added new steam sessions functions IsOverlay Enabled InitTextFiltering FilterText IsSteamInBigPictureMode --- .../Classes/AdvancedSteamFriendsLibrary.h | 34 +++++++++ .../Private/AdvancedSteamFriendsLibrary.cpp | 75 +++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h index 0a35350..aaa37cf 100644 --- a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h +++ b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h @@ -305,6 +305,19 @@ public: }; +UENUM(Blueprintable) +enum class EBPTextFilteringContext : uint8 +{ + /*Unknown context.*/ + FContext_Unknown = 0, + /*Game content, only legally required filtering is performed.*/ + FContext_GameContent = 1, + /*Char from another player.*/ + FContext_Chat = 2, + /*Character or item name.*/ + FContext_Name = 3 +}; + UCLASS() class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary { @@ -325,6 +338,10 @@ public: UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") static bool OpenSteamUserOverlay(const FBPUniqueNetId UniqueNetId, ESteamUserOverlayType DialogType); + // Returns if the steam overlay is currently active (this can return false during initial overlay hooking) + UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI") + static bool IsOverlayEnabled(); + // Gets the level of a friends steam account, STEAM ONLY, Returns -1 if the steam level is not known, might need RequestSteamFriendInfo called first. UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") static int32 GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId); @@ -350,4 +367,21 @@ public: // Get a full list of steam groups UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|SteamGroups") static void GetSteamGroups(TArray & SteamGroups); + + // Initializes text filtering (pre-loading dictonaries) + // Returns if it succeeded, false if filtering is unavailable for the games language + UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering") + static bool InitTextFiltering(); + + // Attempts to filter a string with the given filtering context + // Returns true if the text has been filtered, false if it hasn't (no filtering required or operation failed) + // If false it will still output the original text + // Textsource is the steam id that is the source of the text (player name / chat) + // Requires that InitTextFiltering be called first!! + UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering") + static bool FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText); + + // Returns if steam is running in big picture mode + UFUNCTION(BlueprintPure, Category = "Online|SteamAPI") + static bool IsSteamInBigPictureMode(); }; diff --git a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp index 4c2dc00..1422d17 100644 --- a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp +++ b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp @@ -255,6 +255,19 @@ bool UAdvancedSteamFriendsLibrary::OpenSteamUserOverlay(const FBPUniqueNetId Uni return false; } +bool UAdvancedSteamFriendsLibrary::IsOverlayEnabled() +{ +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX + if (SteamAPI_Init()) + { + return SteamUtils()->IsOverlayEnabled(); + } +#endif + + UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Couldn't init steamAPI!")); + return false; +} + UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize) { #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX @@ -350,4 +363,66 @@ UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueN UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("STEAM Couldn't be verified as initialized")); Result = EBlueprintAsyncResultSwitch::OnFailure; return nullptr; +} + +bool UAdvancedSteamFriendsLibrary::InitTextFiltering() +{ +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX + + if (SteamAPI_Init()) + { + return SteamUtils()->InitFilterText(); + } + +#endif + + return false; +} + +bool UAdvancedSteamFriendsLibrary::FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText) +{ +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX + + if (SteamAPI_Init()) + { + uint32 BufferLen = TextToFilter.Len() + 10; // Docs say 1 byte excess min, going with 10 + char* OutText = new char[BufferLen]; + + uint64 id = 0; + + if (TextSourceID.IsValid()) + { + id = *((uint64*)TextSourceID.UniqueNetId->GetBytes()); + } + + int FilterCount = SteamUtils()->FilterText((ETextFilteringContext)Context, id, TCHAR_TO_ANSI(*TextToFilter), OutText, BufferLen); + + if (FilterCount > 0) + { + FilteredText = FString(UTF8_TO_TCHAR(OutText)); + delete[] OutText; + return true; + } + + delete[] OutText; + } + +#endif + + FilteredText = TextToFilter; + return false; +} + +bool UAdvancedSteamFriendsLibrary::IsSteamInBigPictureMode() +{ +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX + + if (SteamAPI_Init()) + { + return SteamUtils()->IsSteamInBigPictureMode(); + } + +#endif + + return false; } \ No newline at end of file From e9bea6cac0737b37d6d5d61cbcd35dede91b653a Mon Sep 17 00:00:00 2001 From: Joshua Date: Mon, 23 Aug 2021 08:39:21 -0400 Subject: [PATCH 05/13] fix default value for lobby sessions on create session fix default value for lobby sessions on create session --- .../Classes/CreateSessionCallbackProxyAdvanced.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h b/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h index 6be8624..b91a7db 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h @@ -24,11 +24,11 @@ class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase * @param PublicConnections When doing a 'listen' server, this must be >=2 (ListenServer itself counts as a connection) * @param bUseLAN When you want to play LAN, the level to play on must be loaded with option 'bIsLanMatch' * @param bUsePresence Must be true for a 'listen' server (Map must be loaded with option 'listen'), false for a 'dedicated' server. - * @param bUseLobbiesIfAvailable Used to flag the subsystem to use a lobby api instead of general hosting if the API supports it. + * @param bUseLobbiesIfAvailable Used to flag the subsystem to use a lobby api instead of general hosting if the API supports it, generally true on steam for listen servers and false for dedicated * @param bShouldAdvertise Set to true when the OnlineSubsystem should list your server when someone is searching for servers. Otherwise the server is hidden and only join via invite is possible. */ UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions") - static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bUseLobbiesIfAvailable = false, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true); + static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bUseLobbiesIfAvailable = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true); // UOnlineBlueprintCallProxyBase interface virtual void Activate() override; From 816b701963638a9c8307a398ebe07e87aeb855b4 Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 24 Aug 2021 09:22:34 -0400 Subject: [PATCH 06/13] add lobby search to find add lobby search to find --- .../FindSessionsCallbackProxyAdvanced.h | 5 ++++- .../FindSessionsCallbackProxyAdvanced.cpp | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/FindSessionsCallbackProxyAdvanced.h b/AdvancedSessions/Source/AdvancedSessions/Classes/FindSessionsCallbackProxyAdvanced.h index c48994a..713b7c6 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/FindSessionsCallbackProxyAdvanced.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/FindSessionsCallbackProxyAdvanced.h @@ -22,7 +22,7 @@ class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase // Searches for advertised sessions with the default online subsystem and includes an array of filters UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", AutoCreateRefTerm="Filters"), Category = "Online|AdvancedSessions") - static UFindSessionsCallbackProxyAdvanced* FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int32 MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray &Filters, bool bEmptyServersOnly = false, bool bNonEmptyServersOnly = false, bool bSecureServersOnly = false, int MinSlotsAvailable = 0); + static UFindSessionsCallbackProxyAdvanced* FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int32 MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray &Filters, bool bEmptyServersOnly = false, bool bNonEmptyServersOnly = false, bool bSecureServersOnly = false, bool bSearchLobbies = true, int MinSlotsAvailable = 0); static bool CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator); @@ -92,6 +92,9 @@ private: // Search for secure servers only bool bSecureServersOnly; + // Search through lobbies + bool bSearchLobbies; + // Min slots requires to search int MinSlotsAvailable; diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/FindSessionsCallbackProxyAdvanced.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/FindSessionsCallbackProxyAdvanced.cpp index 3f62d81..ff6944c 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/FindSessionsCallbackProxyAdvanced.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/FindSessionsCallbackProxyAdvanced.cpp @@ -15,7 +15,7 @@ UFindSessionsCallbackProxyAdvanced::UFindSessionsCallbackProxyAdvanced(const FOb bIsOnSecondSearch = false; } -UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, int MinSlotsAvailable) +UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, bool bSearchLobbies, int MinSlotsAvailable) { UFindSessionsCallbackProxyAdvanced* Proxy = NewObject(); Proxy->PlayerControllerWeakPtr = PlayerController; @@ -27,6 +27,7 @@ UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSess Proxy->bEmptyServersOnly = bEmptyServersOnly, Proxy->bNonEmptyServersOnly = bNonEmptyServersOnly; Proxy->bSecureServersOnly = bSecureServersOnly; + Proxy->bSearchLobbies = bSearchLobbies; Proxy->MinSlotsAvailable = MinSlotsAvailable; return Proxy; } @@ -73,6 +74,17 @@ void UFindSessionsCallbackProxyAdvanced::Activate() #define SEARCH_USER FName(TEXT("SEARCHUSER")) // Keywords to match in session search #define SEARCH_KEYWORDS FName(TEXT("SEARCHKEYWORDS"))*/ + /** Keywords to match in session search */ + /** The matchmaking queue name to matchmake in, e.g. "TeamDeathmatch" (value is string) */ + /** #define SEARCH_MATCHMAKING_QUEUE FName(TEXT("MATCHMAKINGQUEUE"))*/ + /** If set, use the named Xbox Live hopper to find a session via matchmaking (value is a string) */ + /** #define SEARCH_XBOX_LIVE_HOPPER_NAME FName(TEXT("LIVEHOPPERNAME"))*/ + /** Which session template from the service configuration to use */ + /** #define SEARCH_XBOX_LIVE_SESSION_TEMPLATE_NAME FName(TEXT("LIVESESSIONTEMPLATE"))*/ + /** Selection method used to determine which match to join when multiple are returned (valid only on Switch) */ + /** #define SEARCH_SWITCH_SELECTION_METHOD FName(TEXT("SWITCHSELECTIONMETHOD"))*/ + /** Whether to use lobbies vs sessions */ + /** #define SEARCH_LOBBIES FName(TEXT("LOBBYSEARCH"))*/ if (bEmptyServersOnly) tem.Set(SEARCH_EMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals); @@ -86,8 +98,6 @@ void UFindSessionsCallbackProxyAdvanced::Activate() if (MinSlotsAvailable != 0) tem.Set(SEARCH_MINSLOTSAVAILABLE, MinSlotsAvailable, EOnlineComparisonOp::GreaterThanEquals); - - // Filter results if (SearchSettings.Num() > 0) { @@ -104,6 +114,9 @@ void UFindSessionsCallbackProxyAdvanced::Activate() case EBPServerPresenceSearchType::ClientServersOnly: { tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals); + + if (bSearchLobbies) + tem.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals); } break; From 0be6427845614e8346307e71a79ab9a0f96aa4ff Mon Sep 17 00:00:00 2001 From: Joshua Date: Wed, 1 Sep 2021 13:24:33 -0400 Subject: [PATCH 07/13] corrected uplugin versions corrected uplugin versions --- AdvancedSessions/AdvancedSessions.uplugin | 4 ++-- AdvancedSteamSessions/AdvancedSteamSessions.uplugin | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AdvancedSessions/AdvancedSessions.uplugin b/AdvancedSessions/AdvancedSessions.uplugin index 6227fd4..079213e 100644 --- a/AdvancedSessions/AdvancedSessions.uplugin +++ b/AdvancedSessions/AdvancedSessions.uplugin @@ -2,8 +2,8 @@ "FileVersion" : 3, "FriendlyName" : "Advanced Sessions", - "Version" : 4.26, - "VersionName": "4.26", + "Version" : 4.27, + "VersionName": "4.27", "Description" : "Adds new blueprint functions to handle more advanced session operations.", "Category" : "Advanced Sessions Plugin", "CreatedBy" : "Joshua Statzer", diff --git a/AdvancedSteamSessions/AdvancedSteamSessions.uplugin b/AdvancedSteamSessions/AdvancedSteamSessions.uplugin index 6aca147..8cab794 100644 --- a/AdvancedSteamSessions/AdvancedSteamSessions.uplugin +++ b/AdvancedSteamSessions/AdvancedSteamSessions.uplugin @@ -2,8 +2,8 @@ "FileVersion" : 3, "FriendlyName" : "Advanced Steam Sessions", - "Version" : 4.26, - "VersionName": "4.26", + "Version" : 4.27, + "VersionName": "4.27", "Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS", "Category" : "Advanced Sessions Plugin", "CreatedBy" : "Joshua Statzer", From d67c039088802353c11bf12970c9a1cdb4b57360 Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 12 Oct 2021 10:01:02 -0400 Subject: [PATCH 08/13] support steam bug on mac support steam bug on mac --- .../Private/AdvancedSteamFriendsLibrary.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp index 1422d17..bd31497 100644 --- a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp +++ b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp @@ -395,7 +395,18 @@ bool UAdvancedSteamFriendsLibrary::FilterText(FString TextToFilter, EBPTextFilte id = *((uint64*)TextSourceID.UniqueNetId->GetBytes()); } + // MAC is bugged with current steam version according to epic, they forced it to be the old steam ver +#if PLATFORM_MAC + // Filters the provided input message and places the filtered result into pchOutFilteredText. + // pchOutFilteredText is where the output will be placed, even if no filtering or censoring is performed + // nByteSizeOutFilteredText is the size (in bytes) of pchOutFilteredText + // pchInputText is the input string that should be filtered, which can be ASCII or UTF-8 + // bLegalOnly should be false if you want profanity and legally required filtering (where required) and true if you want legally required filtering only + // Returns the number of characters (not bytes) filtered. + int FilterCount = SteamUtils()->FilterText(OutText, BufferLen, TCHAR_TO_ANSI(*TextToFilter), Context == EBPTextFilteringContext::FContext_GameContent); +#else int FilterCount = SteamUtils()->FilterText((ETextFilteringContext)Context, id, TCHAR_TO_ANSI(*TextToFilter), OutText, BufferLen); +#endif if (FilterCount > 0) { From 94fb993ad70a7a497b827180a66a66d18e769db6 Mon Sep 17 00:00:00 2001 From: Joshua Date: Mon, 23 Aug 2021 08:39:21 -0400 Subject: [PATCH 09/13] fix default value for lobby sessions on create session fix default value for lobby sessions on create session From 444b632a725ac5b440f1f60809f314c77cd8c175 Mon Sep 17 00:00:00 2001 From: Ji-Rath Date: Fri, 17 Dec 2021 15:27:22 -0600 Subject: [PATCH 10/13] Add type parameter to LoginUser Add type parameter so EOS can use "accountportal" to authenticate, falls back to default implementation if left blank --- .../AdvancedSessions/Classes/LoginUserCallbackProxy.h | 6 ++++-- .../Private/LoginUserCallbackProxy.cpp | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/LoginUserCallbackProxy.h b/AdvancedSessions/Source/AdvancedSessions/Classes/LoginUserCallbackProxy.h index 72433f6..db6dc34 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/LoginUserCallbackProxy.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/LoginUserCallbackProxy.h @@ -21,8 +21,8 @@ class ULoginUserCallbackProxy : public UOnlineBlueprintCallProxyBase FEmptyOnlineDelegate OnFailure; // Logs into the identity interface - UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity") - static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken); + UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject", AdvancedDisplay = "Type"), Category = "Online|AdvancedIdentity") + static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken, FString Type); // UOnlineBlueprintCallProxyBase interface virtual void Activate() override; @@ -42,6 +42,8 @@ private: // The user pass / token FString UserToken; + FString Type; + // The delegate executed by the online subsystem FOnLoginCompleteDelegate Delegate; diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/LoginUserCallbackProxy.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/LoginUserCallbackProxy.cpp index 7d805eb..3c9fb54 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/LoginUserCallbackProxy.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/LoginUserCallbackProxy.cpp @@ -12,12 +12,13 @@ ULoginUserCallbackProxy::ULoginUserCallbackProxy(const FObjectInitializer& Objec { } -ULoginUserCallbackProxy* ULoginUserCallbackProxy::LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken) +ULoginUserCallbackProxy* ULoginUserCallbackProxy::LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken, FString Type) { ULoginUserCallbackProxy* Proxy = NewObject(); Proxy->PlayerControllerWeakPtr = PlayerController; Proxy->UserID = UserID; Proxy->UserToken = UserToken; + Proxy->Type = Type; Proxy->WorldContextObject = WorldContextObject; return Proxy; } @@ -43,8 +44,13 @@ void ULoginUserCallbackProxy::Activate() if (Identity.IsValid()) { + // Fallback to default AuthType if nothing is specified + if (Type.IsEmpty()) + { + Type = Identity->GetAuthType(); + } DelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(Player->GetControllerId(), Delegate); - FOnlineAccountCredentials AccountCreds(Identity->GetAuthType(), UserID, UserToken); + FOnlineAccountCredentials AccountCreds(Type, UserID, UserToken); Identity->Login(Player->GetControllerId(), AccountCreds); return; } From 7b8bebac66b96acdbecef682a31ad98009c76508 Mon Sep 17 00:00:00 2001 From: Ji-Rath Date: Fri, 17 Dec 2021 15:45:18 -0600 Subject: [PATCH 11/13] Add AutoLoginUserCallbackProxy Implement AutoLogin function, can be used to login automatically using the EOS SDK Dev Auth Tool --- .../Classes/AutoLoginUserCallbackProxy.h | 55 +++++++++++++++++++ .../Private/AutoLoginUserCallbackProxy.cpp | 55 +++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 AdvancedSessions/Source/AdvancedSessions/Classes/AutoLoginUserCallbackProxy.h create mode 100644 AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/AutoLoginUserCallbackProxy.h b/AdvancedSessions/Source/AdvancedSessions/Classes/AutoLoginUserCallbackProxy.h new file mode 100644 index 0000000..dc91cff --- /dev/null +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/AutoLoginUserCallbackProxy.h @@ -0,0 +1,55 @@ +// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. +#pragma once + +#include "CoreMinimal.h" +#include "BlueprintDataDefinitions.h" +#include "Interfaces/OnlineIdentityInterface.h" +#include "Engine/LocalPlayer.h" +#include "AutoLoginUserCallbackProxy.generated.h" + +UCLASS(MinimalAPI) +class UAutoLoginUserCallbackProxy : public UOnlineBlueprintCallProxyBase +{ + GENERATED_UCLASS_BODY() + + // Called when there is a successful destroy + UPROPERTY(BlueprintAssignable) + FEmptyOnlineDelegate OnSuccess; + + // Called when there is an unsuccessful destroy + UPROPERTY(BlueprintAssignable) + FEmptyOnlineDelegate OnFailure; + + /** + * Logs the player into the online service using parameters passed on the + * command line. Expects -AUTH_LOGIN= -AUTH_PASSWORD=. If either + * are missing, the function returns false and doesn't start the login + * process + * + * @param LocalUserNum the controller number of the associated user + * + */ + UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity") + static UAutoLoginUserCallbackProxy* AutoLoginUser(UObject* WorldContextObject, int32 LocalUserNum); + + // UOnlineBlueprintCallProxyBase interface + virtual void Activate() override; + // End of UOnlineBlueprintCallProxyBase interface + +private: + // Internal callback when the operation completes, calls out to the public success/failure callbacks + void OnCompleted(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& ErrorVal); + +private: + // The controller number of the associated user + int32 LocalUserNumber; + + // The delegate executed by the online subsystem + FOnLoginCompleteDelegate Delegate; + + // Handle to the registered OnDestroySessionComplete delegate + FDelegateHandle DelegateHandle; + + // The world context object in which this call is taking place + UObject* WorldContextObject; +}; diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp new file mode 100644 index 0000000..de3225d --- /dev/null +++ b/AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp @@ -0,0 +1,55 @@ +// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. + +#include "AutoLoginUserCallbackProxy.h" + + +////////////////////////////////////////////////////////////////////////// +// ULoginUserCallbackProxy + +UAutoLoginUserCallbackProxy::UAutoLoginUserCallbackProxy(const FObjectInitializer& ObjectInitializer) + : Super(ObjectInitializer) + , Delegate(FOnLoginCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted)) +{ +} + +UAutoLoginUserCallbackProxy* UAutoLoginUserCallbackProxy::AutoLoginUser(UObject* WorldContextObject, int32 LocalUserNum) +{ + UAutoLoginUserCallbackProxy* Proxy = NewObject(); + Proxy->LocalUserNumber = LocalUserNum; + Proxy->WorldContextObject = WorldContextObject; + return Proxy; +} + +void UAutoLoginUserCallbackProxy::Activate() +{ + auto Identity = Online::GetIdentityInterface(); + + if (Identity.IsValid()) + { + DelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(LocalUserNumber, Delegate); + Identity->AutoLogin(LocalUserNumber); + return; + } + + // Fail immediately + OnFailure.Broadcast(); +} + +void UAutoLoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& ErrorVal) +{ + auto Identity = Online::GetIdentityInterface(); + + if (Identity.IsValid()) + { + Identity->ClearOnLoginCompleteDelegate_Handle(LocalUserNum, DelegateHandle); + } + + if (bWasSuccessful) + { + OnSuccess.Broadcast(); + } + else + { + OnFailure.Broadcast(); + } +} From 21b5b139d9b8900ddea6dafb2b5a7b39216f88a0 Mon Sep 17 00:00:00 2001 From: Ji-Rath Date: Fri, 17 Dec 2021 15:47:39 -0600 Subject: [PATCH 12/13] Add UseLobbiesVoiceChat option for CreateSession Allows the user to setup voice chat lobbies if the API supports it --- .../CreateSessionCallbackProxyAdvanced.h | 188 +++++++++--------- .../CreateSessionCallbackProxyAdvanced.cpp | 4 +- 2 files changed, 99 insertions(+), 93 deletions(-) diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h b/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h index b91a7db..0250956 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h @@ -1,24 +1,24 @@ -// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. -#pragma once - -#include "CoreMinimal.h" -#include "Engine/Engine.h" -#include "BlueprintDataDefinitions.h" -#include "CreateSessionCallbackProxyAdvanced.generated.h" - -UCLASS(MinimalAPI) -class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase -{ - GENERATED_UCLASS_BODY() - - // Called when the session was created successfully - UPROPERTY(BlueprintAssignable) - FEmptyOnlineDelegate OnSuccess; - - // Called when there was an error creating the session - UPROPERTY(BlueprintAssignable) - FEmptyOnlineDelegate OnFailure; - +// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. +#pragma once + +#include "CoreMinimal.h" +#include "Engine/Engine.h" +#include "BlueprintDataDefinitions.h" +#include "CreateSessionCallbackProxyAdvanced.generated.h" + +UCLASS(MinimalAPI) +class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase +{ + GENERATED_UCLASS_BODY() + + // Called when the session was created successfully + UPROPERTY(BlueprintAssignable) + FEmptyOnlineDelegate OnSuccess; + + // Called when there was an error creating the session + UPROPERTY(BlueprintAssignable) + FEmptyOnlineDelegate OnFailure; + /** * Creates a session with the default online subsystem with advanced optional inputs, for dedicated servers leave UsePresence as false and set IsDedicatedServer to true. Dedicated servers don't use presence. * @param PublicConnections When doing a 'listen' server, this must be >=2 (ListenServer itself counts as a connection) @@ -26,74 +26,78 @@ class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase * @param bUsePresence Must be true for a 'listen' server (Map must be loaded with option 'listen'), false for a 'dedicated' server. * @param bUseLobbiesIfAvailable Used to flag the subsystem to use a lobby api instead of general hosting if the API supports it, generally true on steam for listen servers and false for dedicated * @param bShouldAdvertise Set to true when the OnlineSubsystem should list your server when someone is searching for servers. Otherwise the server is hidden and only join via invite is possible. - */ - UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions") - static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bUseLobbiesIfAvailable = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true); - - // UOnlineBlueprintCallProxyBase interface - virtual void Activate() override; - // End of UOnlineBlueprintCallProxyBase interface - -private: - // Internal callback when session creation completes, calls StartSession - void OnCreateCompleted(FName SessionName, bool bWasSuccessful); - - // Internal callback when session creation completes, calls StartSession - void OnStartCompleted(FName SessionName, bool bWasSuccessful); - - // The player controller triggering things - TWeakObjectPtr PlayerControllerWeakPtr; - - // The delegate executed by the online subsystem - FOnCreateSessionCompleteDelegate CreateCompleteDelegate; - - // The delegate executed by the online subsystem - FOnStartSessionCompleteDelegate StartCompleteDelegate; - - // Handles to the registered delegates above - FDelegateHandle CreateCompleteDelegateHandle; - FDelegateHandle StartCompleteDelegateHandle; - - // Number of public connections - int NumPublicConnections; - - // Number of private connections - int NumPrivateConnections; - - // Whether or not to search LAN - bool bUseLAN; - - // Whether or not to allow invites - bool bAllowInvites; - - // Whether this is a dedicated server or not - bool bDedicatedServer; - - // Whether to use the presence option - bool bUsePresence; - - // Whether to prefer the use of lobbies for hosting if the api supports them - bool bUseLobbiesIfAvailable; - - // Whether to allow joining via presence - bool bAllowJoinViaPresence; - - // Allow joining via presence for friends only - bool bAllowJoinViaPresenceFriendsOnly; - - // Delcare the server to be anti cheat protected - bool bAntiCheatProtected; - - // Record Stats - bool bUsesStats; - - // Should advertise server? - bool bShouldAdvertise; - - // Store extra settings - TArray ExtraSettings; - - // The world context object in which this call is taking place - UObject* WorldContextObject; -}; - + * @param bUseLobbiesVoiceChatIfAvailable Set to true to setup voice chat lobbies if the API supports it + */ + UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions") + static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bUseLobbiesIfAvailable = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true, bool bUseLobbiesVoiceChatIfAvailable = false); + + // UOnlineBlueprintCallProxyBase interface + virtual void Activate() override; + // End of UOnlineBlueprintCallProxyBase interface + +private: + // Internal callback when session creation completes, calls StartSession + void OnCreateCompleted(FName SessionName, bool bWasSuccessful); + + // Internal callback when session creation completes, calls StartSession + void OnStartCompleted(FName SessionName, bool bWasSuccessful); + + // The player controller triggering things + TWeakObjectPtr PlayerControllerWeakPtr; + + // The delegate executed by the online subsystem + FOnCreateSessionCompleteDelegate CreateCompleteDelegate; + + // The delegate executed by the online subsystem + FOnStartSessionCompleteDelegate StartCompleteDelegate; + + // Handles to the registered delegates above + FDelegateHandle CreateCompleteDelegateHandle; + FDelegateHandle StartCompleteDelegateHandle; + + // Number of public connections + int NumPublicConnections; + + // Number of private connections + int NumPrivateConnections; + + // Whether or not to search LAN + bool bUseLAN; + + // Whether or not to allow invites + bool bAllowInvites; + + // Whether this is a dedicated server or not + bool bDedicatedServer; + + // Whether to use the presence option + bool bUsePresence; + + // Whether to prefer the use of lobbies for hosting if the api supports them + bool bUseLobbiesIfAvailable; + + // Whether to allow joining via presence + bool bAllowJoinViaPresence; + + // Allow joining via presence for friends only + bool bAllowJoinViaPresenceFriendsOnly; + + // Delcare the server to be anti cheat protected + bool bAntiCheatProtected; + + // Record Stats + bool bUsesStats; + + // Should advertise server? + bool bShouldAdvertise; + + // Whether to prefer the use of voice chat lobbies if the api supports them + bool bUseLobbiesVoiceChatIfAvailable; + + // Store extra settings + TArray ExtraSettings; + + // The world context object in which this call is taking place + UObject* WorldContextObject; +}; + diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp index e6b46ee..72b6ab8 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp @@ -13,7 +13,7 @@ UCreateSessionCallbackProxyAdvanced::UCreateSessionCallbackProxyAdvanced(const F { } -UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bUseLobbiesIfAvailable, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise) +UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bUseLobbiesIfAvailable, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise, bool bUseLobbiesVoiceChatIfAvailable) { UCreateSessionCallbackProxyAdvanced* Proxy = NewObject(); Proxy->PlayerControllerWeakPtr = PlayerController; @@ -31,6 +31,7 @@ UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::Create Proxy->bAntiCheatProtected = bAntiCheatProtected; Proxy->bUsesStats = bUsesStats; Proxy->bShouldAdvertise = bShouldAdvertise; + Proxy->bUseLobbiesVoiceChatIfAvailable = bUseLobbiesVoiceChatIfAvailable; return Proxy; } @@ -68,6 +69,7 @@ void UCreateSessionCallbackProxyAdvanced::Activate() Settings.bUseLobbiesIfAvailable = bUseLobbiesIfAvailable; } + Settings.bUseLobbiesVoiceChatIfAvailable = bUseLobbiesIfAvailable ? bUseLobbiesVoiceChatIfAvailable : false; Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly; Settings.bAntiCheatProtected = bAntiCheatProtected; Settings.bUsesStats = bUsesStats; From 82b2f9f594ce62d46e0912bbc9bb2ff4ed515761 Mon Sep 17 00:00:00 2001 From: MrCodesX Date: Sun, 9 Jan 2022 00:54:42 -0600 Subject: [PATCH 13/13] Fix: Issue #18 Update session not finding sessions to update --- .../UpdateSessionCallbackProxyAdvanced.cpp | 136 +++++++++--------- 1 file changed, 72 insertions(+), 64 deletions(-) diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp index 90c8a7f..0155c64 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp @@ -29,70 +29,73 @@ UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::Update void UUpdateSessionCallbackProxyAdvanced::Activate() { + const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSession"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull)); - IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld()); - - if (Sessions.IsValid()) + if (Helper.OnlineSub != nullptr) { - if (Sessions->GetNumSessions() < 1) + const auto Sessions = Helper.OnlineSub->GetSessionInterface(); + if (Sessions.IsValid()) { - OnFailure.Broadcast(); - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("NO REGISTERED SESSIONS!")); + if (Sessions->GetNumSessions() < 1) + { + OnFailure.Broadcast(); + GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("NO REGISTERED SESSIONS!")); + return; + } + + // This gets the actual session itself + //FNamedOnlineSession * curSession = Sessions->GetNamedSession(NAME_GameSession); + FOnlineSessionSettings* Settings = Sessions->GetSessionSettings(NAME_GameSession); + + if (!Settings) + { + // Fail immediately + OnFailure.Broadcast(); + return; + } + + OnUpdateSessionCompleteDelegateHandle = Sessions->AddOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegate); + + // FOnlineSessionSettings Settings; + //Settings->BuildUniqueId = GetBuildUniqueId(); + Settings->NumPublicConnections = NumPublicConnections; + Settings->NumPrivateConnections = NumPrivateConnections; + //Settings->bShouldAdvertise = true; + Settings->bAllowJoinInProgress = bAllowJoinInProgress; + Settings->bIsLANMatch = bUseLAN; + //Settings->bUsesPresence = true; + //Settings->bAllowJoinViaPresence = true; + Settings->bAllowInvites = bAllowInvites; + Settings->bAllowJoinInProgress = bAllowJoinInProgress; + Settings->bIsDedicated = bDedicatedServer; + + FOnlineSessionSetting * fSetting = NULL; + FOnlineSessionSetting ExtraSetting; + for (int i = 0; i < ExtraSettings.Num(); i++) + { + fSetting = Settings->Settings.Find(ExtraSettings[i].Key); + + if (fSetting) + { + fSetting->Data = ExtraSettings[i].Data; + } + else + { + ExtraSetting.Data = ExtraSettings[i].Data; + ExtraSetting.AdvertisementType = EOnlineDataAdvertisementType::ViaOnlineService; + Settings->Settings.Add(ExtraSettings[i].Key, ExtraSetting); + } + } + + Sessions->UpdateSession(NAME_GameSession, *Settings, bRefreshOnlineData); + + // OnUpdateCompleted will get called, nothing more to do now return; } - - // This gets the actual session itself - //FNamedOnlineSession * curSession = Sessions->GetNamedSession(NAME_GameSession); - FOnlineSessionSettings* Settings = Sessions->GetSessionSettings(NAME_GameSession); - - if (!Settings) + else { - // Fail immediately - OnFailure.Broadcast(); - return; + FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning); } - - OnUpdateSessionCompleteDelegateHandle = Sessions->AddOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegate); - - // FOnlineSessionSettings Settings; - //Settings->BuildUniqueId = GetBuildUniqueId(); - Settings->NumPublicConnections = NumPublicConnections; - Settings->NumPrivateConnections = NumPrivateConnections; - //Settings->bShouldAdvertise = true; - Settings->bAllowJoinInProgress = bAllowJoinInProgress; - Settings->bIsLANMatch = bUseLAN; - //Settings->bUsesPresence = true; - //Settings->bAllowJoinViaPresence = true; - Settings->bAllowInvites = bAllowInvites; - Settings->bAllowJoinInProgress = bAllowJoinInProgress; - Settings->bIsDedicated = bDedicatedServer; - - FOnlineSessionSetting * fSetting = NULL; - FOnlineSessionSetting ExtraSetting; - for (int i = 0; i < ExtraSettings.Num(); i++) - { - fSetting = Settings->Settings.Find(ExtraSettings[i].Key); - - if (fSetting) - { - fSetting->Data = ExtraSettings[i].Data; - } - else - { - ExtraSetting.Data = ExtraSettings[i].Data; - ExtraSetting.AdvertisementType = EOnlineDataAdvertisementType::ViaOnlineService; - Settings->Settings.Add(ExtraSettings[i].Key, ExtraSetting); - } - } - - Sessions->UpdateSession(NAME_GameSession, *Settings, bRefreshOnlineData); - - // OnUpdateCompleted will get called, nothing more to do now - return; - } - else - { - FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning); } // Fail immediately OnFailure.Broadcast(); @@ -101,15 +104,20 @@ void UUpdateSessionCallbackProxyAdvanced::Activate() void UUpdateSessionCallbackProxyAdvanced::OnUpdateCompleted(FName SessionName, bool bWasSuccessful) { - IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld()); - if (Sessions.IsValid()) + const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull)); + + if (Helper.OnlineSub != nullptr) { - Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle); - - if (bWasSuccessful) + const auto Sessions = Helper.OnlineSub->GetSessionInterface(); + if (Sessions.IsValid()) { - OnSuccess.Broadcast(); - return; + Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle); + + if (bWasSuccessful) + { + OnSuccess.Broadcast(); + return; + } } }