mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-22 16:04:18 +00:00
commit to bring to parity
This commit is contained in:
@@ -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",
|
||||
|
@@ -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=<UserName> -AUTH_PASSWORD=<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;
|
||||
};
|
@@ -264,10 +264,18 @@ public:
|
||||
EBPOnlinePresenceState PresenceState = EBPOnlinePresenceState::Offline;
|
||||
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 = false;
|
||||
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)
|
||||
|
@@ -1,95 +1,103 @@
|
||||
// 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)
|
||||
* @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, 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<FSessionPropertyKeyPair> &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);
|
||||
|
||||
// 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<APlayerController> 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 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<FSessionPropertyKeyPair> 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<FSessionPropertyKeyPair> &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<APlayerController> 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<FSessionPropertyKeyPair> ExtraSettings;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
||||
|
||||
|
@@ -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<FSessionsSearchSetting> &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<FSessionsSearchSetting> &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;
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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<UAutoLoginUserCallbackProxy>();
|
||||
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();
|
||||
}
|
||||
}
|
@@ -13,7 +13,7 @@ UCreateSessionCallbackProxyAdvanced::UCreateSessionCallbackProxyAdvanced(const F
|
||||
{
|
||||
}
|
||||
|
||||
UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &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<FSessionPropertyKeyPair> &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<UCreateSessionCallbackProxyAdvanced>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
@@ -25,11 +25,13 @@ UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::Create
|
||||
Proxy->ExtraSettings = ExtraSettings;
|
||||
Proxy->bDedicatedServer = bIsDedicatedServer;
|
||||
Proxy->bUsePresence = bUsePresence;
|
||||
Proxy->bUseLobbiesIfAvailable = bUseLobbiesIfAvailable;
|
||||
Proxy->bAllowJoinViaPresence = bAllowJoinViaPresence;
|
||||
Proxy->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
|
||||
Proxy->bAntiCheatProtected = bAntiCheatProtected;
|
||||
Proxy->bUsesStats = bUsesStats;
|
||||
Proxy->bShouldAdvertise = bShouldAdvertise;
|
||||
Proxy->bUseLobbiesVoiceChatIfAvailable = bUseLobbiesVoiceChatIfAvailable;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
@@ -57,10 +59,17 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
|
||||
Settings.bIsDedicated = bDedicatedServer;
|
||||
|
||||
if (bDedicatedServer)
|
||||
{
|
||||
Settings.bUsesPresence = false;
|
||||
Settings.bUseLobbiesIfAvailable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.bUsesPresence = bUsePresence;
|
||||
Settings.bUseLobbiesIfAvailable = bUseLobbiesIfAvailable;
|
||||
}
|
||||
|
||||
Settings.bUseLobbiesVoiceChatIfAvailable = bUseLobbiesIfAvailable ? bUseLobbiesVoiceChatIfAvailable : false;
|
||||
Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
|
||||
Settings.bAntiCheatProtected = bAntiCheatProtected;
|
||||
Settings.bUsesStats = bUsesStats;
|
||||
|
@@ -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<FSessionsSearchSetting> &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<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, bool bSearchLobbies, int MinSlotsAvailable)
|
||||
{
|
||||
UFindSessionsCallbackProxyAdvanced* Proxy = NewObject<UFindSessionsCallbackProxyAdvanced>();
|
||||
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;
|
||||
|
||||
|
@@ -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<ULoginUserCallbackProxy>();
|
||||
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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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<FBPSteamGroupInfo> & 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();
|
||||
};
|
||||
|
@@ -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,77 @@ 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());
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user