mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-23 08:24:18 +00:00
Split plugin into two modules
One is for the general AdvancedSessions The second is for Steam specific implementations This makes it easier to package without steam included, as the default setup always packaged steam out on PC platforms. Unchecking the AdvancedSteamSessions plugin should allow for totally removing any steam reliance from the plugin. You would also have to remove steam specific nodes from your blueprints as well however as they will no longer exist. Former-commit-id: 0bf1fc80dff7be0cc2b9cebaf5affed4918cea49
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
|
||||
public class AdvancedSessions : ModuleRules
|
||||
{
|
||||
public AdvancedSessions(TargetInfo Target)
|
||||
{
|
||||
PrivateIncludePaths.AddRange(new string[] { "AdvancedSessions/Private"/*, "OnlineSubsystemSteam/Private"*/ });
|
||||
PublicIncludePaths.AddRange(new string[] { "AdvancedSessions/Public" });
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets"/*"Voice", "OnlineSubsystemSteam"*/ });
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "Sockets", "Networking", "OnlineSubsystemUtils" /*"Voice", "Steamworks","OnlineSubsystemSteam"*/});
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
//#include "OnlineFriendsInterface.h"
|
||||
//#include "OnlineUserInterface.h"
|
||||
//#include "OnlineMessageInterface.h"
|
||||
//#include "OnlinePresenceInterface.h"
|
||||
//#include "Engine/GameInstance.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
|
||||
//#include "UObjectIterator.h"
|
||||
|
||||
#include "AdvancedExternalUILibrary.generated.h"
|
||||
|
||||
|
||||
//General Advanced Sessions Log
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedExternalUILog, Log, All);
|
||||
|
||||
UCLASS()
|
||||
class UAdvancedExternalUILibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
//********* External UI Functions *************//
|
||||
|
||||
// Show the UI that handles the Friends list
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void ShowFriendsUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Show the UI that handles inviting people to your game
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void ShowInviteUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Show the UI that shows the leaderboard (doesn't work with steam)
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void ShowLeaderBoardUI(FString LeaderboardName, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Show the UI that shows a web URL
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result", AutoCreateRefTerm = "AllowedDomains"))
|
||||
static void ShowWebURLUI(FString URLToShow, EBlueprintResultSwitch &Result, TArray<FString>& AllowedDomains, bool bEmbedded = false , bool bShowBackground = false, bool bShowCloseButton = false, int32 OffsetX = 0, int32 OffsetY = 0, int32 SizeX = 0, int32 SizeY = 0);
|
||||
|
||||
// Show the UI that shows a web URL
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI")
|
||||
static void CloseWebURLUI();
|
||||
|
||||
|
||||
// Show the UI that shows the profile of a uniquenetid
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void ShowProfileUI(const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Show the UI that shows the account upgrade UI (doesn't work with steam)
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void ShowAccountUpgradeUI(const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, EBlueprintResultSwitch &Result);
|
||||
|
||||
};
|
@@ -0,0 +1,141 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineFriendsInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlineMessageInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "OnlineSessionSettings.h"
|
||||
#include "UObjectIterator.h"
|
||||
#include "AdvancedFriendsInterface.h"
|
||||
|
||||
#include "AdvancedFriendsGameInstance.generated.h"
|
||||
|
||||
|
||||
//General Advanced Sessions Log
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsInterfaceLog, Log, All);
|
||||
|
||||
UCLASS()
|
||||
class ADVANCEDSESSIONS_API UAdvancedFriendsGameInstance : public UGameInstance
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
UAdvancedFriendsGameInstance(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
|
||||
bool bCallFriendInterfaceEventsOnPlayerControllers;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
|
||||
bool bCallIdentityInterfaceEventsOnPlayerControllers;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
|
||||
bool bCallVoiceInterfaceEventsOnPlayerControllers;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedVoiceInterface)
|
||||
bool bEnableTalkingStatusDelegate;
|
||||
|
||||
//virtual void PostLoad() override;
|
||||
virtual void Shutdown() override;
|
||||
virtual void Init() override;
|
||||
|
||||
//*** Session invite received by local ***//
|
||||
FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate;
|
||||
FDelegateHandle SessionInviteReceivedDelegateHandle;
|
||||
|
||||
//const FUniqueNetId& /*UserId*/, const FUniqueNetId& /*FromId*/, const FString& /*AppId*/, const FOnlineSessionSearchResult& /*InviteResult*/
|
||||
void OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString & AppId, const FOnlineSessionSearchResult& SessionToJoin);
|
||||
|
||||
// After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
|
||||
void OnSessionInviteReceived(int32 LocalPlayerNum, FBPUniqueNetId PersonInviting, const FString& AppId, const FBlueprintSessionResult& SessionToJoin);
|
||||
|
||||
//*** Session invite accepted by local ***//
|
||||
FOnSessionUserInviteAcceptedDelegate SessionInviteAcceptedDelegate;
|
||||
FDelegateHandle SessionInviteAcceptedDelegateHandle;
|
||||
|
||||
void OnSessionInviteAcceptedMaster(const bool bWasSuccessful, int32 LocalPlayer, TSharedPtr<const FUniqueNetId> PersonInviting, const FOnlineSessionSearchResult& SessionToJoin);
|
||||
|
||||
// After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
|
||||
void OnSessionInviteAccepted(int32 LocalPlayerNum, FBPUniqueNetId PersonInviting, const FBlueprintSessionResult& SessionToJoin);
|
||||
|
||||
|
||||
// After a voice status has changed this event is triggered if the bEnableTalkingStatusDelegate property is true
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedVoice")
|
||||
void OnPlayerTalkingStateChanged(FBPUniqueNetId PlayerId, bool bIsTalking);
|
||||
|
||||
void OnPlayerTalkingStateChangedMaster(TSharedRef<const FUniqueNetId> PlayerId, bool bIsTalking);
|
||||
|
||||
FOnPlayerTalkingStateChangedDelegate PlayerTalkingStateChangedDelegate;
|
||||
FDelegateHandle PlayerTalkingStateChangedDelegateHandle;
|
||||
|
||||
|
||||
// Called when the designated LocalUser has changed login state
|
||||
UFUNCTION(BlueprintImplementableEvent , Category = "AdvancedIdentity", meta = (DisplayName = "OnPlayerLoginChanged"))
|
||||
void OnPlayerLoginChanged(int32 PlayerNum);
|
||||
|
||||
void OnPlayerLoginChangedMaster(int32 PlayerNum);
|
||||
FOnLoginChangedDelegate PlayerLoginChangedDelegate;
|
||||
FDelegateHandle PlayerLoginChangedDelegateHandle;
|
||||
|
||||
// Called when the designated LocalUser has changed login status
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedIdentity", meta = (DisplayName = "OnPlayerLoginStatusChanged"))
|
||||
void OnPlayerLoginStatusChanged(int32 PlayerNum, EBPLoginStatus &PreviousStatus, EBPLoginStatus &NewStatus, FBPUniqueNetId & NewPlayerUniqueNetID);
|
||||
|
||||
void OnPlayerLoginStatusChangedMaster(int32 PlayerNum, ELoginStatus::Type PreviousStatus, ELoginStatus::Type NewStatus, const FUniqueNetId & NewPlayerUniqueNetID);
|
||||
FOnLoginStatusChangedDelegate PlayerLoginStatusChangedDelegate;
|
||||
FDelegateHandle PlayerLoginStatusChangedDelegateHandle;
|
||||
|
||||
|
||||
//*** Session Invite Received From Friend ***//
|
||||
// REMOVED BECAUSE IT NEVER GETS CALLED
|
||||
/*FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate;
|
||||
FDelegateHandle SessionInviteReceivedDelegateHandle;
|
||||
|
||||
void OnSessionInviteReceivedMaster(const FUniqueNetId &InvitedPlayer, const FUniqueNetId &FriendInviting, const FOnlineSessionSearchResult& Session);
|
||||
|
||||
// After a session invite has been sent from a friend this event is triggered, call JoinSession on the session result to join it
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
|
||||
void OnSessionInviteReceived(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &FriendInviting, const FBlueprintSessionResult &Session);
|
||||
*/
|
||||
|
||||
//*** Friend Invite Accepted ***//
|
||||
/*FOnInviteAcceptedDelegate FriendInviteAcceptedDelegate;
|
||||
FDelegateHandle FriendInviteAcceptedDelegateHandle;
|
||||
|
||||
void OnFriendInviteAcceptedDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &PlayerInvited);
|
||||
|
||||
// After a session invite has been accepted by a friend this event is triggered
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
|
||||
void OnFriendInviteAccepted(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &PlayerInvited);
|
||||
*/
|
||||
|
||||
//*** Friend Invite Rejected ***//
|
||||
/*FOnInviteRejectedDelegate SessionInviteRejectedByFriendDelegate;
|
||||
FDelegateHandle InviteRejectedByFriendDelegateHandle;
|
||||
|
||||
void OnFriendInviteRejectedDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &PlayerDeclined);
|
||||
|
||||
// After a friend invite has been rejected this event is triggered
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
|
||||
void OnFriendInviteRejected(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &PlayerDeclined);
|
||||
*/
|
||||
|
||||
//*** Removed By Friend ***//
|
||||
/*FOnFriendRemovedDelegate RemovedByFriendDelegate;
|
||||
FDelegateHandle RemovedByFriendDelegateHandle;
|
||||
|
||||
void OnRemovedByFriendDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &FriendRemoved);
|
||||
|
||||
// After a friend removed the player this event is triggered
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
|
||||
void OnRemovedByFriend(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &FriendRemoved);*/
|
||||
};
|
||||
|
@@ -0,0 +1,56 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineFriendsInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlineMessageInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "OnlineSessionSettings.h"
|
||||
#include "UObjectIterator.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "AdvancedFriendsInterface.generated.h"
|
||||
|
||||
|
||||
UINTERFACE(MinimalAPI)
|
||||
class UAdvancedFriendsInterface : public UInterface
|
||||
{
|
||||
GENERATED_UINTERFACE_BODY()
|
||||
};
|
||||
|
||||
class IAdvancedFriendsInterface
|
||||
{
|
||||
GENERATED_IINTERFACE_BODY()
|
||||
public:
|
||||
|
||||
// Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect
|
||||
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnSessionInviteReceived"))
|
||||
void OnSessionInviteReceived(FBPUniqueNetId PersonInviting, const FBlueprintSessionResult& SearchResult);
|
||||
|
||||
// Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect
|
||||
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnSessionInviteAccepted"))
|
||||
void OnSessionInviteAccepted(FBPUniqueNetId PersonInviting, const FBlueprintSessionResult& SearchResult);
|
||||
|
||||
// Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect
|
||||
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerVoiceStateChanged"))
|
||||
void OnPlayerVoiceStateChanged(FBPUniqueNetId PlayerId, bool bIsTalking);
|
||||
|
||||
// Called when the designated LocalUser has changed login state
|
||||
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerLoginChanged"))
|
||||
void OnPlayerLoginChanged(int32 PlayerNum);
|
||||
|
||||
// Called when the designated LocalUser has changed login state
|
||||
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerLoginStatusChanged"))
|
||||
void OnPlayerLoginStatusChanged(EBPLoginStatus &PreviousStatus, EBPLoginStatus &NewStatus, FBPUniqueNetId & PlayerUniqueNetID);
|
||||
|
||||
// REMOVED BECAUSE IT WAS NEVER BEING CALLED
|
||||
// Called when the designated LocalUser has received a session invite, use JoinSession on result to connect
|
||||
//UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "OnSessionInviteReceived"))
|
||||
//void OnSessionInviteReceived(const FBPUniqueNetId &FriendInviting, const FBlueprintSessionResult &Session);
|
||||
|
||||
};
|
@@ -0,0 +1,54 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineFriendsInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlineMessageInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
|
||||
#include "UObjectIterator.h"
|
||||
|
||||
#include "AdvancedFriendsLibrary.generated.h"
|
||||
|
||||
|
||||
//General Advanced Sessions Log
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsLog, Log, All);
|
||||
|
||||
UCLASS()
|
||||
class UAdvancedFriendsLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
//********* Friend List Functions *************//
|
||||
|
||||
// Sends an Invite to the current online session to a list of friends
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Sends an Invite to the current online session to a friend
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Get a friend from the previously read/saved friends list (Must Call GetFriends first for this to return anything)
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList")
|
||||
static void GetFriend(APlayerController *PlayerController, const FBPUniqueNetId FriendUniqueNetId, FBPFriendInfo &Friend);
|
||||
|
||||
// Get the previously read/saved friends list (Must Call GetFriends first for this to return anything)
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList")
|
||||
static void GetStoredFriendsList(APlayerController *PlayerController, TArray<FBPFriendInfo> &FriendsList);
|
||||
|
||||
// Get the previously read/saved recent players list (Must Call GetRecentPlayers first for this to return anything)
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|RecentPlayersList")
|
||||
static void GetStoredRecentPlayersList(FBPUniqueNetId UniqueNetId, TArray<FBPOnlineRecentPlayer> &PlayersList);
|
||||
|
||||
// Check if a UniqueNetId is a friend
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|FriendsList")
|
||||
static void IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend);
|
||||
};
|
@@ -0,0 +1,79 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineIdentityInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
|
||||
#include "UObjectIterator.h"
|
||||
|
||||
#include "AdvancedIdentityLibrary.generated.h"
|
||||
|
||||
|
||||
//General Advanced Sessions Log
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedIdentityLog, Log, All);
|
||||
|
||||
UCLASS()
|
||||
class UAdvancedIdentityLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
//********* Identity Functions *************//
|
||||
|
||||
// Get the login status of a local player
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void GetLoginStatus(const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Get the auth token for a local player
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void GetPlayerAuthToken(APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Get a players nickname
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity")
|
||||
static void GetPlayerNickname(const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname);
|
||||
|
||||
//********* User Account Functions *************//
|
||||
|
||||
// Get a users account
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void GetUserAccount(const FBPUniqueNetId & UniqueNetId, FBPUserOnlineAccount & AccountInfo, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Get all known users accounts
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void GetAllUserAccounts(TArray<FBPUserOnlineAccount> & AccountInfos, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Get a user account access token
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
|
||||
static void GetUserAccountAccessToken(const FBPUserOnlineAccount & AccountInfo, FString & AccessToken);
|
||||
|
||||
// Get a user account Auth attribute (depends on subsystem)
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void GetUserAccountAuthAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AuthAttribute, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Set a user account attribute (depends on subsystem)
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void SetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, const FString & NewAttributeValue, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Get user ID
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
|
||||
static void GetUserID(const FBPUserOnlineAccount & AccountInfo, FBPUniqueNetId & UniqueNetID);
|
||||
|
||||
// Get user accounts real name if possible
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
|
||||
static void GetUserAccountRealName(const FBPUserOnlineAccount & AccountInfo, FString & UserName);
|
||||
|
||||
// Get user account display name if possible
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
|
||||
static void GetUserAccountDisplayName(const FBPUserOnlineAccount & AccountInfo, FString & DisplayName);
|
||||
|
||||
// Get user account attribute (depends on subsystem)
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void GetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AttributeValue, EBlueprintResultSwitch &Result);
|
||||
|
||||
|
||||
};
|
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "ModuleManager.h"
|
||||
|
||||
class AdvancedSessions : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
/** IModuleInterface implementation */
|
||||
void StartupModule();
|
||||
void ShutdownModule();
|
||||
};
|
@@ -0,0 +1,159 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineFriendsInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlineMessageInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
|
||||
#include "UObjectIterator.h"
|
||||
|
||||
#include "AdvancedSessionsLibrary.generated.h"
|
||||
|
||||
|
||||
//General Advanced Sessions Log
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSessionsLog, Log, All);
|
||||
|
||||
|
||||
UCLASS()
|
||||
class UAdvancedSessionsLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
//********* Session Search Functions *************//
|
||||
|
||||
// Adds or modifies session settings in an existing array depending on if they exist already or not
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void AddOrModifyExtraSettings(UPARAM(ref) TArray<FSessionPropertyKeyPair> & SettingsArray, UPARAM(ref) TArray<FSessionPropertyKeyPair> & NewOrChangedSettings, TArray<FSessionPropertyKeyPair> & ModifiedSettingsArray);
|
||||
|
||||
// Get an array of the session settings from a session search result
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void GetExtraSettings(FBlueprintSessionResult SessionResult, TArray<FSessionPropertyKeyPair> & ExtraSettings);
|
||||
|
||||
// Get the current session state
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void GetSessionState(EBPOnlineSessionState &SessionState);
|
||||
|
||||
// Get the current session settings
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void GetSessionSettings(int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Check if someone is in the current session
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void IsPlayerInSession(const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession);
|
||||
|
||||
// Make a literal session search parameter
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
|
||||
static FSessionsSearchSetting MakeLiteralSessionSearchProperty(FSessionPropertyKeyPair SessionSearchProperty, EOnlineComparisonOpRedux ComparisonOp);
|
||||
|
||||
|
||||
//********* Session Information Functions ***********//
|
||||
|
||||
// Check if a session result is valid or not
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static bool IsValidSession(const FBlueprintSessionResult & SessionResult);
|
||||
|
||||
// Get the Unique Current Build ID
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void GetCurrentUniqueBuildID(int32 &UniqueBuildId);
|
||||
|
||||
// Get the Unique Build ID from a session search result
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void GetUniqueBuildID(FBlueprintSessionResult SessionResult, int32 &UniqueBuildId);
|
||||
|
||||
// Get session custom information key/value as Byte (For Enums)
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
|
||||
static void GetSessionPropertyByte(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, uint8 &SettingValue);
|
||||
|
||||
// Get session custom information key/value as Bool
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
|
||||
static void GetSessionPropertyBool(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, bool &SettingValue);
|
||||
|
||||
// Get session custom information key/value as String
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
|
||||
static void GetSessionPropertyString(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, FString &SettingValue);
|
||||
|
||||
// Get session custom information key/value as Int
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
|
||||
static void GetSessionPropertyInt(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, int32 &SettingValue);
|
||||
|
||||
// Get session custom information key/value as Float
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
|
||||
static void GetSessionPropertyFloat(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, float &SettingValue);
|
||||
|
||||
|
||||
// Make a literal session custom information key/value pair from Byte (For Enums)
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
|
||||
static FSessionPropertyKeyPair MakeLiteralSessionPropertyByte(FName Key, uint8 Value);
|
||||
|
||||
// Make a literal session custom information key/value pair from Bool
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
|
||||
static FSessionPropertyKeyPair MakeLiteralSessionPropertyBool(FName Key, bool Value);
|
||||
|
||||
// Make a literal session custom information key/value pair from String
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
|
||||
static FSessionPropertyKeyPair MakeLiteralSessionPropertyString(FName Key, FString Value);
|
||||
|
||||
// Make a literal session custom information key/value pair from Int
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
|
||||
static FSessionPropertyKeyPair MakeLiteralSessionPropertyInt(FName Key, int32 Value);
|
||||
|
||||
// Make a literal session custom information key/value pair from Float
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
|
||||
static FSessionPropertyKeyPair MakeLiteralSessionPropertyFloat(FName Key, float Value);
|
||||
|
||||
|
||||
//******* Player ID functions *********//
|
||||
|
||||
// Get the unique net id of a network player attached to the given controller
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||
static void GetUniqueNetID(APlayerController *PlayerController, FBPUniqueNetId &UniqueNetId);
|
||||
|
||||
// Get the unique net id of a network player who is assigned the the given player state
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||
static void GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId);
|
||||
|
||||
// Return True if Unique Net ID is valid
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||
static bool IsValidUniqueNetID(const FBPUniqueNetId &UniqueNetId);
|
||||
|
||||
/* Returns true if the values are equal (A == B) */
|
||||
UFUNCTION(BlueprintPure, meta = (DisplayName = "Equal Unique Net ID", CompactNodeTitle = "==", Keywords = "== equal"), Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||
static bool EqualEqual_UNetIDUnetID(const FBPUniqueNetId &A, const FBPUniqueNetId &B);
|
||||
|
||||
// Check if a UniqueNetId is a friend
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|UniqueNetId")
|
||||
static void UniqueNetIdToString(const FBPUniqueNetId &UniqueNetId, FString &String);
|
||||
|
||||
//******** Player Name Functions **********//
|
||||
|
||||
// Get the player name of a network player attached to the given controller
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerName")
|
||||
static void GetPlayerName(APlayerController *PlayerController, FString &PlayerName);
|
||||
|
||||
// Set the player name of a network player attached to the given controller
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|PlayerInfo|PlayerName")
|
||||
static void SetPlayerName(APlayerController *PlayerController, FString PlayerName);
|
||||
|
||||
//********** Misc Player Info Functions *********//
|
||||
|
||||
// Get the number of network players
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|Misc", meta = (bIgnoreSelf = "true", WorldContext = "WorldContextObject", DisplayName = "GetNumNetworkPlayers"))
|
||||
static void GetNumberOfNetworkPlayers(UObject* WorldContextObject, int32 &NumNetPlayers);
|
||||
|
||||
// Get the network player index of the given controller
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|Misc")
|
||||
static void GetNetPlayerIndex(APlayerController *PlayerController, int32 &NetPlayerIndex);
|
||||
|
||||
// Checks if the stated session subsystem is active
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc")
|
||||
static bool HasOnlineSubsystem(FName SubSystemName);
|
||||
|
||||
|
||||
};
|
@@ -0,0 +1,96 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "VoiceInterface.h"
|
||||
//#include "OnlineFriendsInterface.h"
|
||||
//#include "OnlineUserInterface.h"
|
||||
//#include "OnlineMessageInterface.h"
|
||||
//#include "OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
//#include "OnlineSessionInterface.h"
|
||||
|
||||
#include "UObjectIterator.h"
|
||||
|
||||
#include "AdvancedVoiceLibrary.generated.h"
|
||||
|
||||
|
||||
//General Advanced Sessions Log
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedVoiceLog, Log, All);
|
||||
|
||||
|
||||
UCLASS()
|
||||
class UAdvancedVoiceLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
//********* Voice Library Functions *************//
|
||||
|
||||
// Get if a headset is present for the specified local user
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
|
||||
static void IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlayerNum = 0);
|
||||
|
||||
// Starts networked voice, allows push to talk in coordination with StopNetworkedVoice
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static void StartNetworkedVoice(uint8 LocalPlayerNum = 0);
|
||||
|
||||
// Stops networked voice, allows push to talk in coordination with StartNetworkedVoice
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static void StopNetworkedVoice(uint8 LocalPlayerNum = 0);
|
||||
|
||||
// Registers a local player as someone interested in voice data
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static bool RegisterLocalTalker(uint8 LocalPlayerNum = 0);
|
||||
|
||||
// Registers all signed in players as local talkers
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static void RegisterAllLocalTalkers();
|
||||
|
||||
// UnRegisters local player as a local talker
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static void UnRegisterLocalTalker(uint8 LocalPlayerNum = 0);
|
||||
|
||||
// UnRegisters all signed in players as local talkers
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static void UnRegisterAllLocalTalkers();
|
||||
|
||||
// Registers a remote player as a talker
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static bool RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId);
|
||||
|
||||
// UnRegisters a remote player as a talker
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static bool UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId);
|
||||
|
||||
// UnRegisters all remote players as talkers
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static void RemoveAllRemoteTalkers();
|
||||
|
||||
// Returns whether a local player is currently talking
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
|
||||
static bool IsLocalPlayerTalking(uint8 LocalPlayerNum);
|
||||
|
||||
// Returns whether a remote player is currently talking
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
|
||||
static bool IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId);
|
||||
|
||||
// Returns whether a player is muted for the specified local player
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
|
||||
static bool IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId);
|
||||
|
||||
// Mutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to mute globally for the player
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static bool MuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false);
|
||||
|
||||
// UnMutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to unmute globally for the player
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static bool UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false);
|
||||
|
||||
// Gets the number of local talkers for this system
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
|
||||
static void GetNumLocalTalkers(int32 & NumLocalTalkers);
|
||||
};
|
@@ -0,0 +1,406 @@
|
||||
#pragma once
|
||||
|
||||
#include "Engine.h"
|
||||
#include "Core.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "OnlineSessionSettings.h"
|
||||
#include "OnlineDelegateMacros.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineSubsystemImpl.h"
|
||||
#include "OnlineSubsystemUtils.h"
|
||||
#include "OnlineSubsystemUtilsModule.h"
|
||||
#include "ModuleManager.h"
|
||||
#include "OnlineSubsystemUtilsClasses.h"
|
||||
#include "BlueprintDataDefinitions.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EBPUserPrivileges : uint8
|
||||
{
|
||||
/** Whether the user can play at all, online or offline - may be age restricted */
|
||||
CanPlay,
|
||||
/** Whether the user can play in online modes */
|
||||
CanPlayOnline,
|
||||
/** Whether the user can use voice and text chat */
|
||||
CanCommunicateOnline,
|
||||
/** Whether the user can use content generated by other users */
|
||||
CanUseUserGeneratedContent
|
||||
};
|
||||
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EBPLoginStatus : uint8
|
||||
{
|
||||
/** Player has not logged in or chosen a local profile */
|
||||
NotLoggedIn,
|
||||
/** Player is using a local profile but is not logged in */
|
||||
UsingLocalProfile,
|
||||
/** Player has been validated by the platform specific authentication service */
|
||||
LoggedIn
|
||||
};
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBPUserOnlineAccount
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
public:
|
||||
TSharedPtr<FUserOnlineAccount> UserAccountInfo;
|
||||
|
||||
FBPUserOnlineAccount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FBPUserOnlineAccount(TSharedPtr<FUserOnlineAccount> UserAccount)
|
||||
{
|
||||
UserAccountInfo = UserAccount;
|
||||
}
|
||||
};
|
||||
|
||||
UENUM()
|
||||
enum class ESessionSettingSearchResult : uint8
|
||||
{
|
||||
// Found the setting
|
||||
Found,
|
||||
|
||||
// Did not find the setting
|
||||
NotFound,
|
||||
|
||||
// Was not the correct type
|
||||
WrongType
|
||||
};
|
||||
|
||||
// This makes a lot of the blueprint functions cleaner
|
||||
UENUM()
|
||||
enum class EBlueprintResultSwitch : uint8
|
||||
{
|
||||
// On Success
|
||||
OnSuccess,
|
||||
|
||||
// On Failure
|
||||
OnFailure
|
||||
};
|
||||
|
||||
// This makes a lot of the blueprint functions cleaner
|
||||
UENUM()
|
||||
enum class EBlueprintAsyncResultSwitch : uint8
|
||||
{
|
||||
// On Success
|
||||
OnSuccess,
|
||||
|
||||
// Still loading
|
||||
AsyncLoading,
|
||||
// On Failure
|
||||
OnFailure
|
||||
};
|
||||
|
||||
// This is to define server type searches
|
||||
UENUM(BlueprintType)
|
||||
enum class EBPServerPresenceSearchType : uint8
|
||||
{
|
||||
AllServers,
|
||||
ClientServersOnly,
|
||||
DedicatedServersOnly
|
||||
};
|
||||
|
||||
// Wanted this to be switchable in the editor
|
||||
UENUM(BlueprintType)
|
||||
enum class EBPOnlinePresenceState : uint8
|
||||
{
|
||||
Online,
|
||||
Offline,
|
||||
Away,
|
||||
ExtendedAway,
|
||||
DoNotDisturb,
|
||||
Chat
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EBPOnlineSessionState : uint8
|
||||
{
|
||||
/** An online session has not been created yet */
|
||||
NoSession,
|
||||
/** An online session is in the process of being created */
|
||||
Creating,
|
||||
/** Session has been created but the session hasn't started (pre match lobby) */
|
||||
Pending,
|
||||
/** Session has been asked to start (may take time due to communication with backend) */
|
||||
Starting,
|
||||
/** The current session has started. Sessions with join in progress disabled are no longer joinable */
|
||||
InProgress,
|
||||
/** The session is still valid, but the session is no longer being played (post match lobby) */
|
||||
Ending,
|
||||
/** The session is closed and any stats committed */
|
||||
Ended,
|
||||
/** The session is being destroyed */
|
||||
Destroying
|
||||
};
|
||||
|
||||
// Boy oh boy is this a dirty hack, but I can't figure out a good way to do it otherwise at the moment
|
||||
// The UniqueNetId is an abstract class so I can't exactly re-initialize it to make a shared pointer on some functions
|
||||
// So I made the blueprintable UniqueNetID into a dual variable struct with access functions and I am converting the const var for the pointer
|
||||
// I really need to re-think this later
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBPUniqueNetId
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
private:
|
||||
bool bUseDirectPointer;
|
||||
|
||||
|
||||
public:
|
||||
TSharedPtr<const FUniqueNetId> UniqueNetId;
|
||||
const FUniqueNetId * UniqueNetIdPtr;
|
||||
|
||||
void SetUniqueNetId(const TSharedPtr<const FUniqueNetId> &ID)
|
||||
{
|
||||
bUseDirectPointer = false;
|
||||
UniqueNetIdPtr = nullptr;
|
||||
UniqueNetId = ID;
|
||||
}
|
||||
|
||||
void SetUniqueNetId(const FUniqueNetId *ID)
|
||||
{
|
||||
bUseDirectPointer = true;
|
||||
UniqueNetIdPtr = ID;
|
||||
}
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
if (bUseDirectPointer && UniqueNetIdPtr != nullptr && UniqueNetIdPtr->IsValid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (UniqueNetId.IsValid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
const FUniqueNetId* GetUniqueNetId() const
|
||||
{
|
||||
if (bUseDirectPointer && UniqueNetIdPtr != nullptr)
|
||||
{
|
||||
// No longer converting to non const as all functions now pass const UniqueNetIds
|
||||
return /*const_cast<FUniqueNetId*>*/(UniqueNetIdPtr);
|
||||
}
|
||||
else if (UniqueNetId.IsValid())
|
||||
{
|
||||
return UniqueNetId.Get();
|
||||
}
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FBPUniqueNetId()
|
||||
{
|
||||
bUseDirectPointer = false;
|
||||
UniqueNetIdPtr = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
USTRUCT(BluePrintType)
|
||||
struct FBPOnlineUser
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
FBPUniqueNetId UniqueNetId;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
FString DisplayName;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
FString RealName;
|
||||
};
|
||||
|
||||
USTRUCT(BluePrintType)
|
||||
struct FBPOnlineRecentPlayer : public FBPOnlineUser
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
FString LastSeen;
|
||||
};
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBPFriendPresenceInfo
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
bool bIsOnline;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
bool bIsPlaying;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
bool bIsPlayingThisGame;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
bool bIsJoinable;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
bool bHasVoiceSupport;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
EBPOnlinePresenceState PresenceState;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
FString StatusString;
|
||||
};
|
||||
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBPFriendInfo
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
FString DisplayName;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
FString RealName;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
EBPOnlinePresenceState OnlineState;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
FBPUniqueNetId UniqueNetId;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
bool bIsPlayingSameGame;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||
FBPFriendPresenceInfo PresenceInfo;
|
||||
};
|
||||
|
||||
/** The types of comparison operations for a given search query */
|
||||
// Used to compare session properties
|
||||
UENUM(BlueprintType)
|
||||
enum class EOnlineComparisonOpRedux : uint8
|
||||
{
|
||||
Equals,
|
||||
NotEquals,
|
||||
GreaterThan,
|
||||
GreaterThanEquals,
|
||||
LessThan,
|
||||
LessThanEquals,
|
||||
};
|
||||
|
||||
|
||||
// Used to store session properties before converting to FVariantData
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSessionPropertyKeyPair
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
FName Key;
|
||||
FVariantData Data;
|
||||
};
|
||||
|
||||
|
||||
// Sent to the FindSessionsAdvanced to filter the end results
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSessionsSearchSetting
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
//UPROPERTY()
|
||||
|
||||
|
||||
// Had to make a copy of this to account for the original not being exposed to blueprints
|
||||
/** How is this session setting compared on the backend searches */
|
||||
EOnlineComparisonOpRedux ComparisonOp;
|
||||
|
||||
// The key pair to search for
|
||||
FSessionPropertyKeyPair PropertyKeyPair;
|
||||
};
|
||||
|
||||
// Couldn't use the default one as it is not exposed to other modules, had to re-create it here
|
||||
// Helper class for various methods to reduce the call hierarchy
|
||||
struct FOnlineSubsystemBPCallHelperAdvanced
|
||||
{
|
||||
public:
|
||||
FOnlineSubsystemBPCallHelperAdvanced(const TCHAR* CallFunctionContext, UWorld* World, FName SystemName = NAME_None)
|
||||
: OnlineSub(Online::GetSubsystem(World, SystemName))
|
||||
, FunctionContext(CallFunctionContext)
|
||||
{
|
||||
if (OnlineSub == nullptr)
|
||||
{
|
||||
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Invalid or uninitialized OnlineSubsystem"), FunctionContext), ELogVerbosity::Warning);
|
||||
}
|
||||
}
|
||||
|
||||
void QueryIDFromPlayerController(APlayerController* PlayerController)
|
||||
{
|
||||
UserID.Reset();
|
||||
//return const_cast<FUniqueNetId*>(UniqueNetIdPtr);
|
||||
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
|
||||
{
|
||||
UserID = PlayerState->UniqueId.GetUniqueNetId();
|
||||
if (!UserID.IsValid())
|
||||
{
|
||||
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Cannot map local player to unique net ID"), FunctionContext), ELogVerbosity::Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Invalid player state"), FunctionContext), ELogVerbosity::Warning);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
return UserID.IsValid() && (OnlineSub != nullptr);
|
||||
}
|
||||
|
||||
public:
|
||||
//TSharedPtr<const FUniqueNetId>& GetUniqueNetId()
|
||||
TSharedPtr</*class*/ const FUniqueNetId> UserID;
|
||||
IOnlineSubsystem* const OnlineSub;
|
||||
const TCHAR* FunctionContext;
|
||||
};
|
||||
class FOnlineSearchSettingsEx : public FOnlineSearchSettings
|
||||
{
|
||||
/**
|
||||
* Sets a key value pair combination that defines a search parameter
|
||||
*
|
||||
* @param Key key for the setting
|
||||
* @param Value value of the setting
|
||||
* @param InType type of comparison
|
||||
*/
|
||||
public:
|
||||
|
||||
void HardSet(FName Key, const FVariantData& Value, EOnlineComparisonOpRedux CompOp)
|
||||
{
|
||||
FOnlineSessionSearchParam* SearchParam = SearchParams.Find(Key);
|
||||
|
||||
TEnumAsByte<EOnlineComparisonOp::Type> op;
|
||||
|
||||
switch (CompOp)
|
||||
{
|
||||
case EOnlineComparisonOpRedux::Equals: op = EOnlineComparisonOp::Equals; break;
|
||||
case EOnlineComparisonOpRedux::GreaterThan: op = EOnlineComparisonOp::GreaterThan; break;
|
||||
case EOnlineComparisonOpRedux::GreaterThanEquals: op = EOnlineComparisonOp::GreaterThanEquals; break;
|
||||
case EOnlineComparisonOpRedux::LessThan: op = EOnlineComparisonOp::LessThan; break;
|
||||
case EOnlineComparisonOpRedux::LessThanEquals: op = EOnlineComparisonOp::LessThanEquals; break;
|
||||
case EOnlineComparisonOpRedux::NotEquals: op = EOnlineComparisonOp::NotEquals; break;
|
||||
default: op = EOnlineComparisonOp::Equals; break;
|
||||
}
|
||||
|
||||
if (SearchParam)
|
||||
{
|
||||
SearchParam->Data = Value;
|
||||
SearchParam->ComparisonOp = op;
|
||||
}
|
||||
else
|
||||
{
|
||||
FOnlineSessionSearchParam searchSetting((int)0, op);
|
||||
searchSetting.Data = Value;
|
||||
SearchParams.Add(Key, searchSetting);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#define INVALID_INDEX -1
|
@@ -0,0 +1,44 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "CancelFindSessionsCallbackProxy.generated.h"
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UCancelFindSessionsCallbackProxy : 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;
|
||||
|
||||
// Cancels finding sessions
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedSessions")
|
||||
static UCancelFindSessionsCallbackProxy* CancelFindSessions(UObject* WorldContextObject, class APlayerController* PlayerController);
|
||||
|
||||
// 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(bool bWasSuccessful);
|
||||
|
||||
private:
|
||||
// The player controller triggering things
|
||||
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
|
||||
|
||||
// The delegate executed by the online subsystem
|
||||
FOnCancelFindSessionsCompleteDelegate Delegate;
|
||||
|
||||
// Handle to the registered OnDestroySessionComplete delegate
|
||||
FDelegateHandle DelegateHandle;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
@@ -0,0 +1,88 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSubSystemHeader.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.
|
||||
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;
|
||||
};
|
||||
|
@@ -0,0 +1,44 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "EndSessionCallbackProxy.generated.h"
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UEndSessionCallbackProxy : 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;
|
||||
|
||||
// Ends the current session
|
||||
UFUNCTION(BlueprintCallable, meta=(DeprecatedFunction,DeprecationMessage = "This function is deprecated, I realized that people have been using it wrong and it doesn't have much use in blueprints. Use Destroy Session only instead.",BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedSessions|Deprecated")
|
||||
static UEndSessionCallbackProxy* EndSession(UObject* WorldContextObject, class APlayerController* PlayerController);
|
||||
|
||||
// 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(FName SessionName, bool bWasSuccessful);
|
||||
|
||||
private:
|
||||
// The player controller triggering things
|
||||
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
|
||||
|
||||
// The delegate executed by the online subsystem
|
||||
FOnEndSessionCompleteDelegate Delegate;
|
||||
|
||||
// Handle to the registered OnDestroySessionComplete delegate
|
||||
FDelegateHandle DelegateHandle;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
@@ -0,0 +1,50 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
|
||||
#include "FindFriendSessionCallbackProxy.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFindFriendSessionLog, Log, All);
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintFindFriendSessionDelegate, const FBlueprintSessionResult&, SessionInfo);
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UFindFriendSessionCallbackProxy : public UOnlineBlueprintCallProxyBase
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
// Called when the friends list successfully was retrieved
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintFindFriendSessionDelegate OnSuccess;
|
||||
|
||||
// Called when there was an error retrieving the friends list
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintFindFriendSessionDelegate OnFailure;
|
||||
|
||||
// Attempts to get the current session that a friend is in
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
|
||||
static UFindFriendSessionCallbackProxy* FindFriendSession(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId);
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
private:
|
||||
// Internal callback when the friends list is retrieved
|
||||
void OnFindFriendSessionCompleted(int32 LocalPlayer, bool bWasSuccessful, const FOnlineSessionSearchResult& SessionInfo);
|
||||
|
||||
// The player controller triggering things
|
||||
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
|
||||
|
||||
// The UniqueNetID of the person to invite
|
||||
FBPUniqueNetId cUniqueNetId;
|
||||
|
||||
// The delegate to call on completion
|
||||
FOnFindFriendSessionCompleteDelegate OnFindFriendSessionCompleteDelegate;
|
||||
|
||||
// Handles to the registered delegates above
|
||||
FDelegateHandle FindFriendSessionCompleteDelegateHandle;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
||||
|
@@ -0,0 +1,99 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "FindSessionsCallbackProxy.h"
|
||||
#include "FindSessionsCallbackProxyAdvanced.generated.h"
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
// Called when there is a successful query
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintFindSessionsResultDelegate OnSuccess;
|
||||
|
||||
// Called when there is an unsuccessful query
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintFindSessionsResultDelegate OnFailure;
|
||||
|
||||
// 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 bool CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator);
|
||||
|
||||
// Filters an array of session results by the given search parameters, returns a new array with the filtered results
|
||||
UFUNCTION(BluePrintCallable, meta = (Category = "Online|AdvancedSessions"))
|
||||
static void FilterSessionResults(const TArray<FBlueprintSessionResult> &SessionResults, const TArray<FSessionsSearchSetting> &Filters, TArray<FBlueprintSessionResult> &FilteredResults);
|
||||
|
||||
// Removed, the default built in versions work fine in the normal FindSessionsCallbackProxy
|
||||
/*UFUNCTION(BlueprintPure, Category = "Online|Session")
|
||||
static int32 GetPingInMs(const FBlueprintSessionResult& Result);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "Online|Session")
|
||||
static FString GetServerName(const FBlueprintSessionResult& Result);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "Online|Session")
|
||||
static int32 GetCurrentPlayers(const FBlueprintSessionResult& Result);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "Online|Session")
|
||||
static int32 GetMaxPlayers(const FBlueprintSessionResult& Result);*/
|
||||
|
||||
|
||||
// UOnlineBlueprintCallProxyBase interface
|
||||
virtual void Activate() override;
|
||||
// End of UOnlineBlueprintCallProxyBase interface
|
||||
|
||||
private:
|
||||
// Internal callback when the session search completes, calls out to the public success/failure callbacks
|
||||
void OnCompleted(bool bSuccess);
|
||||
|
||||
bool bRunSecondSearch;
|
||||
bool bIsOnSecondSearch;
|
||||
|
||||
TArray<FBlueprintSessionResult> SessionSearchResults;
|
||||
|
||||
private:
|
||||
// The player controller triggering things
|
||||
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
|
||||
|
||||
// The delegate executed by the online subsystem
|
||||
FOnFindSessionsCompleteDelegate Delegate;
|
||||
|
||||
// Handle to the registered OnFindSessionsComplete delegate
|
||||
FDelegateHandle DelegateHandle;
|
||||
|
||||
// Object to track search results
|
||||
TSharedPtr<FOnlineSessionSearch> SearchObject;
|
||||
TSharedPtr<FOnlineSessionSearch> SearchObjectDedicated;
|
||||
|
||||
// Whether or not to search LAN
|
||||
bool bUseLAN;
|
||||
|
||||
// Whether or not to search for dedicated servers
|
||||
EBPServerPresenceSearchType ServerSearchType;
|
||||
|
||||
// Maximum number of results to return
|
||||
int MaxResults;
|
||||
|
||||
// Store extra settings
|
||||
TArray<FSessionsSearchSetting> SearchSettings;
|
||||
|
||||
// Search for empty servers only
|
||||
bool bEmptyServersOnly;
|
||||
|
||||
// Search for non empty servers only
|
||||
bool bNonEmptyServersOnly;
|
||||
|
||||
// Search for secure servers only
|
||||
bool bSecureServersOnly;
|
||||
|
||||
// Min slots requires to search
|
||||
int MinSlotsAvailable;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
@@ -0,0 +1,48 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
|
||||
#include "GetFriendsCallbackProxy.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedGetFriendsLog, Log, All);
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGetFriendsListDelegate, const TArray<FBPFriendInfo>&, Results);
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UGetFriendsCallbackProxy : public UOnlineBlueprintCallProxyBase
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
// Called when the friends list successfully was retrieved
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintGetFriendsListDelegate OnSuccess;
|
||||
|
||||
// Called when there was an error retrieving the friends list
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintGetFriendsListDelegate OnFailure;
|
||||
|
||||
// Gets the players list of friends from the OnlineSubsystem and returns it, can be retrieved later with GetStoredFriendsList
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
|
||||
static UGetFriendsCallbackProxy* GetAndStoreFriendsList(UObject* WorldContextObject, class APlayerController* PlayerController);
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
private:
|
||||
// Internal callback when the friends list is retrieved
|
||||
void OnReadFriendsListCompleted(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorString);
|
||||
|
||||
// The player controller triggering things
|
||||
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
|
||||
|
||||
// The delegate executed
|
||||
FOnReadFriendsListComplete FriendListReadCompleteDelegate;
|
||||
|
||||
// The Type of friends list to get
|
||||
// Removed because all but the facebook interfaces don't even currently support anything but the default friends list.
|
||||
//EBPFriendsLists FriendListToGet;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
||||
|
@@ -0,0 +1,49 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
|
||||
#include "GetRecentPlayersCallbackProxy.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedGetRecentPlayersLog, Log, All);
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGetRecentPlayersDelegate, const TArray<FBPOnlineRecentPlayer>&, Results);
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UGetRecentPlayersCallbackProxy : public UOnlineBlueprintCallProxyBase
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
// Called when the friends list successfully was retrieved
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintGetRecentPlayersDelegate OnSuccess;
|
||||
|
||||
// Called when there was an error retrieving the friends list
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintGetRecentPlayersDelegate OnFailure;
|
||||
|
||||
// Gets the list of recent players from the OnlineSubsystem and returns it, can be retrieved later with GetStoredRecentPlayersList, can fail if no recent players are found
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
|
||||
static UGetRecentPlayersCallbackProxy* GetAndStoreRecentPlayersList(UObject* WorldContextObject, const FBPUniqueNetId &UniqueNetId);
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
private:
|
||||
// Internal callback when the friends list is retrieved
|
||||
void OnQueryRecentPlayersCompleted(const FUniqueNetId &UserID, const FString &Namespace, bool bWasSuccessful, const FString& ErrorString);
|
||||
// Handle to the registered OnFindSessionsComplete delegate
|
||||
FDelegateHandle DelegateHandle;
|
||||
|
||||
// The player controller triggering things
|
||||
//TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
|
||||
|
||||
// The UniqueNetID of the person to get recent players for
|
||||
FBPUniqueNetId cUniqueNetId;
|
||||
|
||||
// The delegate executed
|
||||
FOnQueryRecentPlayersCompleteDelegate QueryRecentPlayersCompleteDelegate;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
||||
|
@@ -0,0 +1,45 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "OnlineIdentityInterface.h"
|
||||
#include "GetUserPrivilegeCallbackProxy.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FBlueprintGetUserPrivilegeDelegate,/* const &FBPUniqueNetId, PlayerID,*/ EBPUserPrivileges, QueriedPrivilege, bool, HadPrivilege);
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UGetUserPrivilegeCallbackProxy : public UOnlineBlueprintCallProxyBase
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
// Called when there is a successful destroy
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintGetUserPrivilegeDelegate OnSuccess;
|
||||
|
||||
// Called when there is an unsuccessful destroy
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FEmptyOnlineDelegate OnFailure;
|
||||
|
||||
// Logs out of the identity interface
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity")
|
||||
static UGetUserPrivilegeCallbackProxy* GetUserPrivilege(UObject* WorldContextObject, const EBPUserPrivileges & PrivilegeToCheck, const FBPUniqueNetId & PlayerUniqueNetID);
|
||||
|
||||
// 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(const FUniqueNetId& PlayerID, EUserPrivileges::Type Privilege, uint32 Result);
|
||||
|
||||
private:
|
||||
// The player controller triggering things
|
||||
FBPUniqueNetId PlayerUniqueNetID;
|
||||
|
||||
// Privilege to check
|
||||
EBPUserPrivileges UserPrivilege;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
@@ -0,0 +1,51 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "OnlineIdentityInterface.h"
|
||||
#include "LoginUserCallbackProxy.generated.h"
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class ULoginUserCallbackProxy : 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 out of 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);
|
||||
|
||||
// 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 player controller triggering things
|
||||
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
|
||||
|
||||
// The user ID
|
||||
FString UserID;
|
||||
|
||||
// The user pass / token
|
||||
FString UserToken;
|
||||
|
||||
// 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;
|
||||
};
|
@@ -0,0 +1,45 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "OnlineIdentityInterface.h"
|
||||
#include "LogoutUserCallbackProxy.generated.h"
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class ULogoutUserCallbackProxy : 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 out of the identity interface
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity")
|
||||
static ULogoutUserCallbackProxy* LogoutUser(UObject* WorldContextObject, class APlayerController* PlayerController);
|
||||
|
||||
// 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(int LocalUserNum, bool bWasSuccessful);
|
||||
|
||||
private:
|
||||
// The player controller triggering things
|
||||
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
|
||||
|
||||
// The delegate executed by the online subsystem
|
||||
FOnLogoutCompleteDelegate Delegate;
|
||||
|
||||
// Handle to the registered OnDestroySessionComplete delegate
|
||||
FDelegateHandle DelegateHandle;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "Engine.h"
|
||||
#include "Core.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "OnlineSessionSettings.h"
|
||||
#include "OnlineDelegateMacros.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineSubsystemImpl.h"
|
||||
#include "OnlineSubsystemUtils.h"
|
||||
#include "OnlineSubsystemUtilsModule.h"
|
||||
#include "ModuleManager.h"
|
||||
#include "OnlineSubsystemUtilsClasses.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
|
||||
|
||||
/*#include "VoiceEngineImpl.h"
|
||||
#include "VoiceInterfaceImpl.h"
|
||||
#include "Voice.h""
|
||||
*/
|
||||
|
||||
// Found this in the steam controller, seems like a nice thought since steam is throwing errors
|
||||
// Disable crazy warnings that claim that standard C library is "deprecated".
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
@@ -0,0 +1,48 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
|
||||
#include "SendFriendInviteCallbackProxy.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSendFriendInviteLog, Log, All);
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBlueprintSendFriendInviteDelegate);
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class USendFriendInviteCallbackProxy : public UOnlineBlueprintCallProxyBase
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
// Called when the friends list successfully was retrieved
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintSendFriendInviteDelegate OnSuccess;
|
||||
|
||||
// Called when there was an error retrieving the friends list
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintSendFriendInviteDelegate OnFailure;
|
||||
|
||||
// Adds a friend who is using the defined UniqueNetId, some interfaces do now allow this function to be called (INCLUDING STEAM)
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
|
||||
static USendFriendInviteCallbackProxy* SendFriendInvite(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &UniqueNetIDInvited);
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
private:
|
||||
// Internal callback when the friends list is retrieved
|
||||
void OnSendInviteComplete(int32 LocalPlayerNum, bool bWasSuccessful, const FUniqueNetId &InvitedPlayer, const FString &ListName, const FString &ErrorString);
|
||||
|
||||
|
||||
// The player controller triggering things
|
||||
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
|
||||
|
||||
// The UniqueNetID of the person to invite
|
||||
FBPUniqueNetId cUniqueNetId;
|
||||
|
||||
// The delegate to call on completion
|
||||
FOnSendInviteComplete OnSendInviteCompleteDelegate;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
||||
|
@@ -0,0 +1,66 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
|
||||
#include "UpdateSessionCallbackProxyAdvanced.generated.h"
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UUpdateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
// Called when the session was updated successfully
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FEmptyOnlineDelegate OnSuccess;
|
||||
|
||||
// Called when there was an error updating the session
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FEmptyOnlineDelegate OnFailure;
|
||||
|
||||
// Creates a session with the default online subsystem with advanced optional inputs, you MUST fill in all categories or it will pass in values that you didn't want as default values
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
|
||||
static UUpdateSessionCallbackProxyAdvanced* UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = false, bool bAllowJoinInProgress = false, bool bRefreshOnlineData = true, bool bIsDedicatedServer = false);
|
||||
|
||||
// UOnlineBlueprintCallProxyBase interface
|
||||
virtual void Activate() override;
|
||||
// End of UOnlineBlueprintCallProxyBase interface
|
||||
|
||||
private:
|
||||
// Internal callback when session creation completes, calls StartSession
|
||||
void OnUpdateCompleted(FName SessionName, bool bWasSuccessful);
|
||||
|
||||
// The delegate executed by the online subsystem
|
||||
FOnUpdateSessionCompleteDelegate OnUpdateSessionCompleteDelegate;
|
||||
|
||||
// Handles to the registered delegates above
|
||||
FDelegateHandle OnUpdateSessionCompleteDelegateHandle;
|
||||
|
||||
// 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;
|
||||
|
||||
// Store extra settings
|
||||
TArray<FSessionPropertyKeyPair> ExtraSettings;
|
||||
|
||||
// Whether to update the online data
|
||||
bool bRefreshOnlineData;
|
||||
|
||||
// Allow joining in progress
|
||||
bool bAllowJoinInProgress;
|
||||
|
||||
// Update whether this is a dedicated server or not
|
||||
bool bDedicatedServer;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
||||
|
@@ -0,0 +1,159 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "AdvancedExternalUILibrary.h"
|
||||
|
||||
//General Log
|
||||
DEFINE_LOG_CATEGORY(AdvancedExternalUILog);
|
||||
|
||||
void UAdvancedExternalUILibrary::ShowAccountUpgradeUI(const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
|
||||
|
||||
if (!ExternalUIInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowAccountUpgradeUI Failed to get External UI interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
ExternalUIInterface->ShowAccountUpgradeUI(*PlayerRequestingAccountUpgradeUI.GetUniqueNetId());
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
void UAdvancedExternalUILibrary::ShowProfileUI(const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
|
||||
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
|
||||
|
||||
if (!ExternalUIInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowProfileUI Failed to get External UI interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
ExternalUIInterface->ShowProfileUI(*PlayerViewingProfile.GetUniqueNetId(), *PlayerToViewProfileOf.GetUniqueNetId(), NULL);
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void UAdvancedExternalUILibrary::ShowWebURLUI(FString URLToShow, EBlueprintResultSwitch &Result, TArray<FString>& AllowedDomains, bool bEmbedded, bool bShowBackground, bool bShowCloseButton, int32 OffsetX, int32 OffsetY, int32 SizeX, int32 SizeY)
|
||||
{
|
||||
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
|
||||
|
||||
if (!ExternalUIInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowWebURLUI Failed to get External UI interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
URLToShow = URLToShow.Replace(TEXT("http://"), TEXT(""));
|
||||
URLToShow = URLToShow.Replace(TEXT("https://"), TEXT(""));
|
||||
|
||||
FShowWebUrlParams Params;
|
||||
Params.AllowedDomains = AllowedDomains;
|
||||
Params.bEmbedded = bEmbedded;
|
||||
Params.bShowBackground = bShowBackground;
|
||||
Params.bShowCloseButton = bShowCloseButton;
|
||||
Params.OffsetX = OffsetX;
|
||||
Params.OffsetY = OffsetY;
|
||||
Params.SizeX = SizeX;
|
||||
Params.SizeY = SizeY;
|
||||
|
||||
ExternalUIInterface->ShowWebURL(URLToShow, Params);
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
void UAdvancedExternalUILibrary::CloseWebURLUI()
|
||||
{
|
||||
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
|
||||
|
||||
if (!ExternalUIInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedExternalUILog, Warning, TEXT("CloseWebURLUI Failed to get External UI interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
ExternalUIInterface->CloseWebURL();
|
||||
}
|
||||
|
||||
void UAdvancedExternalUILibrary::ShowLeaderBoardUI(FString LeaderboardName, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
|
||||
|
||||
if (!ExternalUIInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowLeaderboardsUI Failed to get External UI interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
ExternalUIInterface->ShowLeaderboardUI(LeaderboardName);
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void UAdvancedExternalUILibrary::ShowInviteUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Had a bad Player Controller!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
|
||||
|
||||
if (!ExternalUIInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get External UI interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get ULocalPlayer for the given PlayerController!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
ExternalUIInterface->ShowInviteUI(Player->GetControllerId(), GameSessionName);
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
void UAdvancedExternalUILibrary::ShowFriendsUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Had a bad Player Controller!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
|
||||
|
||||
if (!ExternalUIInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get External UI interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get ULocalPlayer for the given PlayerController!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
ExternalUIInterface->ShowFriendsUI(Player->GetControllerId());
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
@@ -0,0 +1,333 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "AdvancedFriendsGameInstance.h"
|
||||
|
||||
//General Log
|
||||
DEFINE_LOG_CATEGORY(AdvancedFriendsInterfaceLog);
|
||||
|
||||
UAdvancedFriendsGameInstance::UAdvancedFriendsGameInstance(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, bCallFriendInterfaceEventsOnPlayerControllers(true)
|
||||
, bCallIdentityInterfaceEventsOnPlayerControllers(true)
|
||||
, bCallVoiceInterfaceEventsOnPlayerControllers(true)
|
||||
, bEnableTalkingStatusDelegate(true)
|
||||
, SessionInviteReceivedDelegate(FOnSessionInviteReceivedDelegate::CreateUObject(this, &ThisClass::OnSessionInviteReceivedMaster))
|
||||
, SessionInviteAcceptedDelegate(FOnSessionUserInviteAcceptedDelegate::CreateUObject(this, &ThisClass::OnSessionInviteAcceptedMaster))
|
||||
, PlayerTalkingStateChangedDelegate(FOnPlayerTalkingStateChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerTalkingStateChangedMaster))
|
||||
, PlayerLoginChangedDelegate(FOnLoginChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerLoginChangedMaster))
|
||||
, PlayerLoginStatusChangedDelegate(FOnLoginStatusChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerLoginStatusChangedMaster))
|
||||
{
|
||||
}
|
||||
|
||||
void UAdvancedFriendsGameInstance::Shutdown()
|
||||
{
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsGameInstance Failed to get session system!"));
|
||||
//return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear all of the delegate handles here
|
||||
SessionInterface->ClearOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegateHandle);
|
||||
SessionInterface->ClearOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegateHandle);
|
||||
}
|
||||
|
||||
|
||||
if (bEnableTalkingStatusDelegate)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (VoiceInterface.IsValid())
|
||||
{
|
||||
VoiceInterface->ClearOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegateHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!"));
|
||||
}
|
||||
}
|
||||
|
||||
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
|
||||
|
||||
if (IdentityInterface.IsValid())
|
||||
{
|
||||
IdentityInterface->ClearOnLoginChangedDelegate_Handle(PlayerLoginChangedDelegateHandle);
|
||||
|
||||
|
||||
// I am just defaulting to player 1
|
||||
IdentityInterface->ClearOnLoginStatusChangedDelegate_Handle(0, PlayerLoginStatusChangedDelegateHandle);
|
||||
}
|
||||
|
||||
|
||||
Super::Shutdown();
|
||||
}
|
||||
|
||||
void UAdvancedFriendsGameInstance::Init()
|
||||
{
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();//OnlineSub->GetSessionInterface();
|
||||
|
||||
if (SessionInterface.IsValid())
|
||||
{
|
||||
// Currently doesn't store a handle or assign a delegate to any local player beyond the first.....should handle?
|
||||
// Thought about directly handling it but friends for multiple players probably isn't required
|
||||
// Iterating through the local player TArray only works if it has had players assigned to it, most of the online interfaces don't support
|
||||
// Multiple logins either (IE: Steam)
|
||||
SessionInviteAcceptedDelegateHandle = SessionInterface->AddOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegate);
|
||||
|
||||
SessionInviteReceivedDelegateHandle = SessionInterface->AddOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegate);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get session interface!"));
|
||||
//return;
|
||||
}
|
||||
|
||||
// Beginning work on the voice interface
|
||||
if (bEnableTalkingStatusDelegate)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (VoiceInterface.IsValid())
|
||||
{
|
||||
PlayerTalkingStateChangedDelegateHandle = VoiceInterface->AddOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegate);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!"));
|
||||
}
|
||||
}
|
||||
|
||||
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
|
||||
|
||||
if (IdentityInterface.IsValid())
|
||||
{
|
||||
PlayerLoginChangedDelegateHandle = IdentityInterface->AddOnLoginChangedDelegate_Handle(PlayerLoginChangedDelegate);
|
||||
|
||||
// Just defaulting to player 1
|
||||
PlayerLoginStatusChangedDelegateHandle = IdentityInterface->AddOnLoginStatusChangedDelegate_Handle(0, PlayerLoginStatusChangedDelegate);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get identity interface!"));
|
||||
}
|
||||
|
||||
|
||||
Super::Init();
|
||||
}
|
||||
|
||||
/*void UAdvancedFriendsGameInstance::PostLoad()
|
||||
{
|
||||
Super::PostLoad();
|
||||
}*/
|
||||
|
||||
|
||||
// Removed because it never gets called by the online subsystems
|
||||
/*void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNetId &InvitedPlayer, const FUniqueNetId &FriendInviting, const FOnlineSessionSearchResult& Session)
|
||||
{
|
||||
// Just call the blueprint event to let the user handle this
|
||||
|
||||
FBPUniqueNetId IP, FI;
|
||||
|
||||
IP.SetUniqueNetId(&InvitedPlayer);
|
||||
|
||||
FI.SetUniqueNetId(&FriendInviting);
|
||||
|
||||
FBlueprintSessionResult BPS;
|
||||
BPS.OnlineResult = Session;
|
||||
OnSessionInviteReceived(IP,FI,BPS);
|
||||
|
||||
TArray<class APlayerState*>& PlayerArray = GetWorld()->GetGameState()->PlayerArray;
|
||||
const TArray<class ULocalPlayer*>&ControllerArray = this->GetLocalPlayers();
|
||||
|
||||
for (int i = 0; i < ControllerArray.Num(); i++)
|
||||
{
|
||||
if (*PlayerArray[ControllerArray[i]->PlayerController->NetPlayerIndex]->UniqueId.GetUniqueNetId().Get() == InvitedPlayer)
|
||||
{
|
||||
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore
|
||||
if (ControllerArray[i]->PlayerController->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
|
||||
{
|
||||
IAdvancedFriendsInterface::Execute_OnSessionInviteReceived(ControllerArray[i]->PlayerController, FI, BPS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
void UAdvancedFriendsGameInstance::OnPlayerLoginStatusChangedMaster(int32 PlayerNum, ELoginStatus::Type PreviousStatus, ELoginStatus::Type NewStatus, const FUniqueNetId & NewPlayerUniqueNetID)
|
||||
{
|
||||
EBPLoginStatus OrigStatus = (EBPLoginStatus)PreviousStatus;
|
||||
EBPLoginStatus CurrentStatus = (EBPLoginStatus)NewStatus;
|
||||
FBPUniqueNetId PlayerID;
|
||||
PlayerID.SetUniqueNetId(&NewPlayerUniqueNetID);
|
||||
|
||||
OnPlayerLoginStatusChanged(PlayerNum, OrigStatus,CurrentStatus,PlayerID);
|
||||
|
||||
|
||||
if (bCallIdentityInterfaceEventsOnPlayerControllers)
|
||||
{
|
||||
APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), PlayerNum);
|
||||
|
||||
if (Player != NULL)
|
||||
{
|
||||
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore
|
||||
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
|
||||
{
|
||||
IAdvancedFriendsInterface::Execute_OnPlayerLoginStatusChanged(Player, OrigStatus, CurrentStatus, PlayerID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnPlayerLoginStatusChangedMaster!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAdvancedFriendsGameInstance::OnPlayerLoginChangedMaster(int32 PlayerNum)
|
||||
{
|
||||
OnPlayerLoginChanged(PlayerNum);
|
||||
|
||||
if (bCallIdentityInterfaceEventsOnPlayerControllers)
|
||||
{
|
||||
APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), PlayerNum);
|
||||
|
||||
if (Player != NULL)
|
||||
{
|
||||
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore
|
||||
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
|
||||
{
|
||||
IAdvancedFriendsInterface::Execute_OnPlayerLoginChanged(Player, PlayerNum);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnPlayerLoginChanged!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAdvancedFriendsGameInstance::OnPlayerTalkingStateChangedMaster(TSharedRef<const FUniqueNetId> PlayerId, bool bIsTalking)
|
||||
{
|
||||
FBPUniqueNetId PlayerTalking;
|
||||
PlayerTalking.SetUniqueNetId(PlayerId);
|
||||
OnPlayerTalkingStateChanged(PlayerTalking, bIsTalking);
|
||||
|
||||
if (bCallVoiceInterfaceEventsOnPlayerControllers)
|
||||
{
|
||||
APlayerController* Player = NULL;
|
||||
|
||||
for (const ULocalPlayer* LPlayer : LocalPlayers)
|
||||
{
|
||||
Player = UGameplayStatics::GetPlayerController(GetWorld(), LPlayer->GetControllerId());
|
||||
|
||||
if (Player != NULL)
|
||||
{
|
||||
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore
|
||||
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
|
||||
{
|
||||
IAdvancedFriendsInterface::Execute_OnPlayerVoiceStateChanged(Player, PlayerTalking, bIsTalking);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnVoiceStateChanged!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString& AppId, const FOnlineSessionSearchResult& SessionToJoin)
|
||||
{
|
||||
if (SessionToJoin.IsValid())
|
||||
{
|
||||
FBlueprintSessionResult BluePrintResult;
|
||||
BluePrintResult.OnlineResult = SessionToJoin;
|
||||
|
||||
FBPUniqueNetId PInvited;
|
||||
PInvited.SetUniqueNetId(&PersonInvited);
|
||||
|
||||
FBPUniqueNetId PInviting;
|
||||
PInviting.SetUniqueNetId(&PersonInviting);
|
||||
|
||||
|
||||
TArray<APlayerController*> PlayerList;
|
||||
GEngine->GetAllLocalPlayerControllers(PlayerList);
|
||||
|
||||
APlayerController* Player = NULL;
|
||||
|
||||
int32 LocalPlayer = 0;
|
||||
for (int i = 0; i < PlayerList.Num(); i++)
|
||||
{
|
||||
if (*PlayerList[i]->PlayerState->UniqueId.GetUniqueNetId() == PersonInvited)
|
||||
{
|
||||
LocalPlayer = i;
|
||||
Player = PlayerList[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OnSessionInviteReceived(LocalPlayer, PInviting, AppId, BluePrintResult);
|
||||
|
||||
//IAdvancedFriendsInterface* TheInterface = NULL;
|
||||
|
||||
if (Player != NULL)
|
||||
{
|
||||
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore
|
||||
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
|
||||
{
|
||||
IAdvancedFriendsInterface::Execute_OnSessionInviteReceived(Player, PInviting, BluePrintResult);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnSessionInviteReceived!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Return a bad search result in OnSessionInviteReceived!"));
|
||||
}
|
||||
}
|
||||
|
||||
void UAdvancedFriendsGameInstance::OnSessionInviteAcceptedMaster(const bool bWasSuccessful, int32 LocalPlayer, TSharedPtr<const FUniqueNetId> PersonInviting, const FOnlineSessionSearchResult& SessionToJoin)
|
||||
{
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
if (SessionToJoin.IsValid())
|
||||
{
|
||||
|
||||
FBlueprintSessionResult BluePrintResult;
|
||||
BluePrintResult.OnlineResult = SessionToJoin;
|
||||
|
||||
FBPUniqueNetId PInviting;
|
||||
PInviting.SetUniqueNetId(PersonInviting);
|
||||
|
||||
OnSessionInviteAccepted(LocalPlayer,PInviting, BluePrintResult);
|
||||
|
||||
APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), LocalPlayer);
|
||||
|
||||
//IAdvancedFriendsInterface* TheInterface = NULL;
|
||||
|
||||
if (Player != NULL)
|
||||
{
|
||||
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore
|
||||
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
|
||||
{
|
||||
IAdvancedFriendsInterface::Execute_OnSessionInviteAccepted(Player,PInviting, BluePrintResult);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnSessionInviteAccepted!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Return a bad search result in OnSessionInviteAccepted!"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "AdvancedFriendsInterface.h"
|
||||
|
||||
|
||||
UAdvancedFriendsInterface::UAdvancedFriendsInterface(const class FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
}
|
@@ -0,0 +1,274 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "AdvancedFriendsLibrary.h"
|
||||
|
||||
|
||||
// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro
|
||||
|
||||
//General Log
|
||||
DEFINE_LOG_CATEGORY(AdvancedFriendsLog);
|
||||
|
||||
void UAdvancedFriendsLibrary::SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad Player Controller!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Friends.Num() < 1)
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had no friends in invitation array!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Failed to get session interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend failed to get LocalPlayer!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
TArray<TSharedRef<const FUniqueNetId>> List;
|
||||
for (int i = 0; i < Friends.Num(); i++)
|
||||
{
|
||||
TSharedRef<const FUniqueNetId> val(Friends[i].UniqueNetId.ToSharedRef());
|
||||
//TSharedRef<const FUniqueNetId> val(Friends[i].GetUniqueNetId());
|
||||
List.Add(val);
|
||||
}
|
||||
|
||||
if (SessionInterface->SendSessionInviteToFriends(Player->GetControllerId(), GameSessionName, List))
|
||||
{
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
return;
|
||||
}
|
||||
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
void UAdvancedFriendsLibrary::SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad Player Controller!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FriendUniqueNetId.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad UniqueNetId!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Failed to get session interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend failed to get LocalPlayer!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
if (SessionInterface->SendSessionInviteToFriend(Player->GetControllerId(), GameSessionName, *FriendUniqueNetId.GetUniqueNetId()))
|
||||
{
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
return;
|
||||
}
|
||||
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
void UAdvancedFriendsLibrary::GetFriend(APlayerController *PlayerController, const FBPUniqueNetId FriendUniqueNetId, FBPFriendInfo &Friend)
|
||||
{
|
||||
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Had a bad Player Controller!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FriendUniqueNetId.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Had a bad UniqueNetId!"));
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
|
||||
|
||||
if (!FriendsInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Failed to get friends interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend failed to get LocalPlayer!"));
|
||||
return;
|
||||
}
|
||||
|
||||
TSharedPtr<FOnlineFriend> fr = FriendsInterface->GetFriend(Player->GetControllerId(), *FriendUniqueNetId.GetUniqueNetId(), EFriendsLists::ToString(EFriendsLists::Default));
|
||||
if (fr.IsValid())
|
||||
{
|
||||
FOnlineUserPresence pres = fr->GetPresence();
|
||||
Friend.DisplayName = fr->GetDisplayName();
|
||||
Friend.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
|
||||
Friend.RealName = fr->GetRealName();
|
||||
Friend.UniqueNetId.SetUniqueNetId(fr->GetUserId());
|
||||
Friend.bIsPlayingSameGame = pres.bIsPlayingThisGame;
|
||||
|
||||
Friend.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport;
|
||||
Friend.PresenceInfo.bIsJoinable = pres.bIsJoinable;
|
||||
Friend.PresenceInfo.bIsOnline = pres.bIsOnline;
|
||||
Friend.PresenceInfo.bIsPlaying = pres.bIsPlaying;
|
||||
Friend.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame;
|
||||
Friend.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
|
||||
Friend.PresenceInfo.StatusString = pres.Status.StatusStr;
|
||||
}
|
||||
}
|
||||
|
||||
void UAdvancedFriendsLibrary::IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend)
|
||||
{
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad Player Controller!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UniqueNetId.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
|
||||
|
||||
if (!FriendsInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get friends interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get LocalPlayer!"));
|
||||
return;
|
||||
}
|
||||
|
||||
IsFriend = FriendsInterface->IsFriend(Player->GetControllerId(), *UniqueNetId.GetUniqueNetId(), EFriendsLists::ToString(EFriendsLists::Default));
|
||||
}
|
||||
|
||||
void UAdvancedFriendsLibrary::GetStoredRecentPlayersList(FBPUniqueNetId UniqueNetId, TArray<FBPOnlineRecentPlayer> &PlayersList)
|
||||
{
|
||||
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
|
||||
|
||||
if (!FriendsInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetRecentPlayersList Failed to get friends interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UniqueNetId.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetRecentPlayersList Failed was given an invalid UniqueNetId!"));
|
||||
return;
|
||||
}
|
||||
|
||||
TArray< TSharedRef<FOnlineRecentPlayer> > PlayerList;
|
||||
|
||||
// For now getting all namespaces
|
||||
FriendsInterface->GetRecentPlayers(*(UniqueNetId.GetUniqueNetId()),"", PlayerList);
|
||||
|
||||
for (int32 i = 0; i < PlayerList.Num(); i++)
|
||||
{
|
||||
TSharedRef<FOnlineRecentPlayer> Player = PlayerList[i];
|
||||
FBPOnlineRecentPlayer BPF;
|
||||
BPF.DisplayName = Player->GetDisplayName();
|
||||
BPF.RealName = Player->GetRealName();
|
||||
BPF.UniqueNetId.SetUniqueNetId(Player->GetUserId());
|
||||
PlayersList.Add(BPF);
|
||||
}
|
||||
}
|
||||
|
||||
void UAdvancedFriendsLibrary::GetStoredFriendsList(APlayerController *PlayerController, TArray<FBPFriendInfo> &FriendsList)
|
||||
{
|
||||
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Had a bad Player Controller!"));
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
|
||||
|
||||
if (!FriendsInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Failed to get friends interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Failed to get LocalPlayer!"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
TArray< TSharedRef<FOnlineFriend> > FriendList;
|
||||
FriendsInterface->GetFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendList);
|
||||
|
||||
for (int32 i = 0; i < FriendList.Num(); i++)
|
||||
{
|
||||
TSharedRef<FOnlineFriend> Friend = FriendList[i];
|
||||
FBPFriendInfo BPF;
|
||||
FOnlineUserPresence pres = Friend->GetPresence();
|
||||
|
||||
BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
|
||||
BPF.DisplayName = Friend->GetDisplayName();
|
||||
BPF.RealName = Friend->GetRealName();
|
||||
BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId());
|
||||
BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame;
|
||||
|
||||
BPF.PresenceInfo.bIsOnline = pres.bIsOnline;
|
||||
BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport;
|
||||
BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying;
|
||||
BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
|
||||
BPF.PresenceInfo.StatusString = pres.Status.StatusStr;
|
||||
BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable;
|
||||
BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame;
|
||||
|
||||
FriendsList.Add(BPF);
|
||||
}
|
||||
}
|
@@ -0,0 +1,228 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "AdvancedIdentityLibrary.h"
|
||||
//General Log
|
||||
DEFINE_LOG_CATEGORY(AdvancedIdentityLog);
|
||||
|
||||
|
||||
void UAdvancedIdentityLibrary::GetPlayerAuthToken(APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken was passed a bad player controller!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken failed to get LocalPlayer!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
|
||||
|
||||
if (!IdentityInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken Failed to get identity interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
AuthToken = IdentityInterface->GetAuthToken(Player->GetControllerId());
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
void UAdvancedIdentityLibrary::GetPlayerNickname(const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname)
|
||||
{
|
||||
if (!UniqueNetID.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname was passed a bad player uniquenetid!"));
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
|
||||
|
||||
if (!IdentityInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname Failed to get identity interface!"));
|
||||
return;
|
||||
}
|
||||
PlayerNickname = IdentityInterface->GetPlayerNickname(*UniqueNetID.GetUniqueNetId());
|
||||
}
|
||||
|
||||
|
||||
void UAdvancedIdentityLibrary::GetLoginStatus(const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
if(!UniqueNetID.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus was passed a bad player uniquenetid!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
|
||||
|
||||
if (!IdentityInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus Failed to get identity interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
LoginStatus = (EBPLoginStatus)IdentityInterface->GetLoginStatus(*UniqueNetID.GetUniqueNetId());
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
|
||||
void UAdvancedIdentityLibrary::GetAllUserAccounts(TArray<FBPUserOnlineAccount> & AccountInfos, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
|
||||
|
||||
if (!IdentityInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetAllUserAccounts Failed to get identity interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
TArray<TSharedPtr<FUserOnlineAccount>> accountInfos = IdentityInterface->GetAllUserAccounts();
|
||||
|
||||
for (int i = 0; i < accountInfos.Num(); ++i)
|
||||
{
|
||||
AccountInfos.Add(FBPUserOnlineAccount(accountInfos[i]));
|
||||
}
|
||||
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
void UAdvancedIdentityLibrary::GetUserAccount(const FBPUniqueNetId & UniqueNetId, FBPUserOnlineAccount & AccountInfo, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
|
||||
|
||||
if (!IdentityInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get identity interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
TSharedPtr<FUserOnlineAccount> accountInfo = IdentityInterface->GetUserAccount(*UniqueNetId.GetUniqueNetId());
|
||||
|
||||
if (!accountInfo.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get the account!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
AccountInfo.UserAccountInfo = accountInfo;
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
void UAdvancedIdentityLibrary::GetUserAccountAccessToken(const FBPUserOnlineAccount & AccountInfo, FString & AccessToken)
|
||||
{
|
||||
if (!AccountInfo.UserAccountInfo.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAccessToken was passed an invalid account!"));
|
||||
return;
|
||||
}
|
||||
|
||||
AccessToken = AccountInfo.UserAccountInfo->GetAccessToken();
|
||||
}
|
||||
|
||||
void UAdvancedIdentityLibrary::GetUserAccountAuthAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AuthAttribute, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
if (!AccountInfo.UserAccountInfo.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute was passed an invalid account!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AccountInfo.UserAccountInfo->GetAuthAttribute(AttributeName, AuthAttribute))
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute couldn't find the attribute!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
void UAdvancedIdentityLibrary::SetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, const FString & NewAttributeValue, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
if (!AccountInfo.UserAccountInfo.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was passed an invalid account!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AccountInfo.UserAccountInfo->SetUserAttribute(AttributeName, NewAttributeValue))
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was unable to set the attribute!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
void UAdvancedIdentityLibrary::GetUserID(const FBPUserOnlineAccount & AccountInfo, FBPUniqueNetId & UniqueNetID)
|
||||
{
|
||||
if (!AccountInfo.UserAccountInfo.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserID was passed an invalid account!"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
UniqueNetID.SetUniqueNetId(AccountInfo.UserAccountInfo->GetUserId());
|
||||
}
|
||||
|
||||
void UAdvancedIdentityLibrary::GetUserAccountRealName(const FBPUserOnlineAccount & AccountInfo, FString & UserName)
|
||||
{
|
||||
if (!AccountInfo.UserAccountInfo.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountRealName was passed an invalid account!"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
UserName = AccountInfo.UserAccountInfo->GetRealName();
|
||||
}
|
||||
|
||||
void UAdvancedIdentityLibrary::GetUserAccountDisplayName(const FBPUserOnlineAccount & AccountInfo, FString & DisplayName)
|
||||
{
|
||||
if (!AccountInfo.UserAccountInfo.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountDisplayName was passed an invalid account!"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
DisplayName = AccountInfo.UserAccountInfo->GetDisplayName();
|
||||
}
|
||||
|
||||
void UAdvancedIdentityLibrary::GetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AttributeValue, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
if (!AccountInfo.UserAccountInfo.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute was passed an invalid account!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AccountInfo.UserAccountInfo->GetUserAttribute(AttributeName, AttributeValue))
|
||||
{
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute failed to get user attribute!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
//#include "StandAlonePrivatePCH.h"
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "AdvancedSessions.h"
|
||||
|
||||
void AdvancedSessions::StartupModule()
|
||||
{
|
||||
}
|
||||
|
||||
void AdvancedSessions::ShutdownModule()
|
||||
{
|
||||
}
|
||||
|
||||
IMPLEMENT_MODULE(AdvancedSessions, AdvancedSessions)
|
@@ -0,0 +1,433 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "AdvancedSessionsLibrary.h"
|
||||
|
||||
//General Log
|
||||
DEFINE_LOG_CATEGORY(AdvancedSessionsLog);
|
||||
|
||||
bool UAdvancedSessionsLibrary::IsValidSession(const FBlueprintSessionResult & SessionResult)
|
||||
{
|
||||
return SessionResult.OnlineResult.IsValid();
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetCurrentUniqueBuildID(int32 &UniqueBuildId)
|
||||
{
|
||||
UniqueBuildId = GetBuildUniqueId();
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetUniqueBuildID(FBlueprintSessionResult SessionResult, int32 &UniqueBuildId)
|
||||
{
|
||||
UniqueBuildId = SessionResult.OnlineResult.Session.SessionSettings.BuildUniqueId;
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::AddOrModifyExtraSettings(UPARAM(ref) TArray<FSessionPropertyKeyPair> & SettingsArray, UPARAM(ref) TArray<FSessionPropertyKeyPair> & NewOrChangedSettings, TArray<FSessionPropertyKeyPair> & ModifiedSettingsArray)
|
||||
{
|
||||
ModifiedSettingsArray = SettingsArray;
|
||||
|
||||
bool bFoundSetting = false;
|
||||
// For each new setting
|
||||
for (const FSessionPropertyKeyPair& Setting : NewOrChangedSettings)
|
||||
{
|
||||
bFoundSetting = false;
|
||||
|
||||
for (FSessionPropertyKeyPair & itr : ModifiedSettingsArray)
|
||||
{
|
||||
// Manually comparing the keys
|
||||
if (itr.Key == Setting.Key)
|
||||
{
|
||||
bFoundSetting = true;
|
||||
itr.Data = Setting.Data;
|
||||
}
|
||||
}
|
||||
|
||||
// If it was not found, add to the array instead
|
||||
if (!bFoundSetting)
|
||||
{
|
||||
ModifiedSettingsArray.Add(Setting);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetExtraSettings(FBlueprintSessionResult SessionResult, TArray<FSessionPropertyKeyPair> & ExtraSettings)
|
||||
{
|
||||
FSessionPropertyKeyPair NewSetting;
|
||||
for (auto& Elem : SessionResult.OnlineResult.Session.SessionSettings.Settings)
|
||||
{
|
||||
NewSetting.Key = Elem.Key;
|
||||
NewSetting.Data = Elem.Value.Data;
|
||||
ExtraSettings.Add(NewSetting);
|
||||
}
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetSessionState(EBPOnlineSessionState &SessionState)
|
||||
{
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetSessionState couldn't get the session interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
SessionState = ((EBPOnlineSessionState)SessionInterface->GetSessionState(GameSessionName));
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetSessionSettings(int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetSessionSettings couldn't get the session interface!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
FOnlineSessionSettings* settings = SessionInterface->GetSessionSettings(GameSessionName);
|
||||
if (!settings)
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetSessionSettings couldn't get the session settings!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
return;
|
||||
}
|
||||
|
||||
BuildUniqueID = settings->BuildUniqueId;
|
||||
NumConnections = settings->NumPublicConnections;
|
||||
NumPrivateConnections = settings->NumPrivateConnections;
|
||||
bIsLAN = settings->bIsLANMatch;
|
||||
bIsDedicated = settings->bIsDedicated;
|
||||
bIsAnticheatEnabled = settings->bAntiCheatProtected;
|
||||
bAllowInvites = settings->bAllowInvites;
|
||||
bAllowJoinInProgress = settings->bAllowJoinInProgress;
|
||||
|
||||
FSessionPropertyKeyPair NewSetting;
|
||||
|
||||
for (auto& Elem : settings->Settings)
|
||||
{
|
||||
NewSetting.Key = Elem.Key;
|
||||
NewSetting.Data = Elem.Value.Data;
|
||||
ExtraSettings.Add(NewSetting);
|
||||
}
|
||||
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::IsPlayerInSession(const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession)
|
||||
{
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("IsPlayerInSession couldn't get the session interface!"));
|
||||
bIsInSession = false;
|
||||
return;
|
||||
}
|
||||
|
||||
bIsInSession = SessionInterface->IsPlayerInSession(GameSessionName, *PlayerToCheck.GetUniqueNetId());
|
||||
}
|
||||
|
||||
FSessionsSearchSetting UAdvancedSessionsLibrary::MakeLiteralSessionSearchProperty(FSessionPropertyKeyPair SessionSearchProperty, EOnlineComparisonOpRedux ComparisonOp)
|
||||
{
|
||||
FSessionsSearchSetting setting;
|
||||
setting.PropertyKeyPair = SessionSearchProperty;
|
||||
setting.ComparisonOp = ComparisonOp;
|
||||
|
||||
return setting;
|
||||
}
|
||||
|
||||
FSessionPropertyKeyPair UAdvancedSessionsLibrary::MakeLiteralSessionPropertyByte(FName Key, uint8 Value)
|
||||
{
|
||||
FSessionPropertyKeyPair Prop;
|
||||
Prop.Key = Key;
|
||||
Prop.Data.SetValue((int32)Value);
|
||||
return Prop;
|
||||
}
|
||||
|
||||
FSessionPropertyKeyPair UAdvancedSessionsLibrary::MakeLiteralSessionPropertyBool(FName Key, bool Value)
|
||||
{
|
||||
FSessionPropertyKeyPair Prop;
|
||||
Prop.Key = Key;
|
||||
Prop.Data.SetValue(Value);
|
||||
return Prop;
|
||||
}
|
||||
|
||||
FSessionPropertyKeyPair UAdvancedSessionsLibrary::MakeLiteralSessionPropertyString(FName Key, FString Value)
|
||||
{
|
||||
FSessionPropertyKeyPair Prop;
|
||||
Prop.Key = Key;
|
||||
Prop.Data.SetValue(Value);
|
||||
return Prop;
|
||||
}
|
||||
|
||||
FSessionPropertyKeyPair UAdvancedSessionsLibrary::MakeLiteralSessionPropertyInt(FName Key, int32 Value)
|
||||
{
|
||||
FSessionPropertyKeyPair Prop;
|
||||
Prop.Key = Key;
|
||||
Prop.Data.SetValue(Value);
|
||||
return Prop;
|
||||
}
|
||||
|
||||
FSessionPropertyKeyPair UAdvancedSessionsLibrary::MakeLiteralSessionPropertyFloat(FName Key, float Value)
|
||||
{
|
||||
FSessionPropertyKeyPair Prop;
|
||||
Prop.Key = Key;
|
||||
Prop.Data.SetValue(Value);
|
||||
return Prop;
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetSessionPropertyByte(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, uint8 &SettingValue)
|
||||
{
|
||||
for (FSessionPropertyKeyPair itr : ExtraSettings)
|
||||
{
|
||||
if (itr.Key == SettingName)
|
||||
{
|
||||
if (itr.Data.GetType() == EOnlineKeyValuePairDataType::Int32)
|
||||
{
|
||||
int32 Val;
|
||||
itr.Data.GetValue(Val);
|
||||
SettingValue = (uint8)(Val);
|
||||
SearchResult = ESessionSettingSearchResult::Found;
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchResult = ESessionSettingSearchResult::WrongType;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SearchResult = ESessionSettingSearchResult::NotFound;
|
||||
return;
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetSessionPropertyBool(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, bool &SettingValue)
|
||||
{
|
||||
for (FSessionPropertyKeyPair itr : ExtraSettings)
|
||||
{
|
||||
if (itr.Key == SettingName)
|
||||
{
|
||||
if (itr.Data.GetType() == EOnlineKeyValuePairDataType::Bool)
|
||||
{
|
||||
itr.Data.GetValue(SettingValue);
|
||||
SearchResult = ESessionSettingSearchResult::Found;
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchResult = ESessionSettingSearchResult::WrongType;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SearchResult = ESessionSettingSearchResult::NotFound;
|
||||
return;
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetSessionPropertyString(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, FString &SettingValue)
|
||||
{
|
||||
for (FSessionPropertyKeyPair itr : ExtraSettings)
|
||||
{
|
||||
if (itr.Key == SettingName)
|
||||
{
|
||||
if (itr.Data.GetType() == EOnlineKeyValuePairDataType::String)
|
||||
{
|
||||
itr.Data.GetValue(SettingValue);
|
||||
SearchResult = ESessionSettingSearchResult::Found;
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchResult = ESessionSettingSearchResult::WrongType;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SearchResult = ESessionSettingSearchResult::NotFound;
|
||||
return;
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetSessionPropertyInt(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, int32 &SettingValue)
|
||||
{
|
||||
for (FSessionPropertyKeyPair itr : ExtraSettings)
|
||||
{
|
||||
if (itr.Key == SettingName)
|
||||
{
|
||||
if (itr.Data.GetType() == EOnlineKeyValuePairDataType::Int32)
|
||||
{
|
||||
itr.Data.GetValue(SettingValue);
|
||||
SearchResult = ESessionSettingSearchResult::Found;
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchResult = ESessionSettingSearchResult::WrongType;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SearchResult = ESessionSettingSearchResult::NotFound;
|
||||
return;
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetSessionPropertyFloat(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, float &SettingValue)
|
||||
{
|
||||
for (FSessionPropertyKeyPair itr : ExtraSettings)
|
||||
{
|
||||
if (itr.Key == SettingName)
|
||||
{
|
||||
if (itr.Data.GetType() == EOnlineKeyValuePairDataType::Float)
|
||||
{
|
||||
itr.Data.GetValue(SettingValue);
|
||||
SearchResult = ESessionSettingSearchResult::Found;
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchResult = ESessionSettingSearchResult::WrongType;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SearchResult = ESessionSettingSearchResult::NotFound;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool UAdvancedSessionsLibrary::HasOnlineSubsystem(FName SubSystemName)
|
||||
{
|
||||
return IOnlineSubsystem::DoesInstanceExist(SubSystemName);
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetNetPlayerIndex(APlayerController *PlayerController, int32 &NetPlayerIndex)
|
||||
{
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetNetPlayerIndex received a bad PlayerController!"));
|
||||
NetPlayerIndex = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
NetPlayerIndex = PlayerController->NetPlayerIndex;
|
||||
return;
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::UniqueNetIdToString(const FBPUniqueNetId& UniqueNetId, FString &String)
|
||||
{
|
||||
const FUniqueNetId * ID = UniqueNetId.GetUniqueNetId();
|
||||
|
||||
if ( !ID )
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("UniqueNetIdToString received a bad UniqueNetId!"));
|
||||
String = "ERROR, BAD UNIQUE NET ID";
|
||||
}
|
||||
else
|
||||
String = ID->ToString();
|
||||
}
|
||||
|
||||
|
||||
void UAdvancedSessionsLibrary::GetUniqueNetID(APlayerController *PlayerController, FBPUniqueNetId &UniqueNetId)
|
||||
{
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromController received a bad PlayerController!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
|
||||
{
|
||||
UniqueNetId.SetUniqueNetId(PlayerState->UniqueId.GetUniqueNetId());
|
||||
if (!UniqueNetId.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromController couldn't get the player uniquenetid!"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId)
|
||||
{
|
||||
if (!PlayerState)
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromPlayerState received a bad PlayerState!"));
|
||||
return;
|
||||
}
|
||||
|
||||
UniqueNetId.SetUniqueNetId(PlayerState->UniqueId.GetUniqueNetId());
|
||||
if (!UniqueNetId.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromPlayerState couldn't get the player uniquenetid!"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool UAdvancedSessionsLibrary::IsValidUniqueNetID(const FBPUniqueNetId &UniqueNetId)
|
||||
{
|
||||
return UniqueNetId.IsValid();
|
||||
}
|
||||
|
||||
bool UAdvancedSessionsLibrary::EqualEqual_UNetIDUnetID(const FBPUniqueNetId &A, const FBPUniqueNetId &B)
|
||||
{
|
||||
return ((A.IsValid() && B.IsValid()) && (*A.GetUniqueNetId() == *B.GetUniqueNetId()));
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::SetPlayerName(APlayerController *PlayerController, FString PlayerName)
|
||||
{
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("SetLocalPlayerNameFromController Bad Player Controller!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
|
||||
{
|
||||
PlayerState->SetPlayerName(PlayerName);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("SetLocalPlayerNameFromController had a bad player state!"));
|
||||
}
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetPlayerName(APlayerController *PlayerController, FString &PlayerName)
|
||||
{
|
||||
if (!PlayerController)
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetLocalPlayerNameFromController Bad Player Controller!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
|
||||
{
|
||||
PlayerName = PlayerState->PlayerName;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetLocalPlayerNameFromController had a bad player state!"));
|
||||
}
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(UObject* WorldContextObject, int32 &NumNetPlayers)
|
||||
{
|
||||
//Get an actor to GetWorld() from
|
||||
/*TObjectIterator<AActor> Itr;
|
||||
if (!Itr)
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetNumberOfNetworkPlayers Failed to get iterator!"));
|
||||
return;
|
||||
}*/
|
||||
//~~~~~~~~~~~~
|
||||
|
||||
//Get World
|
||||
UWorld* TheWorld = GEngine->GetWorldFromContextObject(WorldContextObject);
|
||||
|
||||
if (!TheWorld)
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetNumberOfNetworkPlayers Failed to get World()!"));
|
||||
return;
|
||||
}
|
||||
TArray<class APlayerState*>& PlayerArray = (TheWorld->GetGameState()->PlayerArray);
|
||||
NumNetPlayers = PlayerArray.Num();
|
||||
}
|
@@ -0,0 +1,218 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "AdvancedVoiceLibrary.h"
|
||||
|
||||
//General Log
|
||||
DEFINE_LOG_CATEGORY(AdvancedVoiceLog);
|
||||
|
||||
void UAdvancedVoiceLibrary::IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlayerNum)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
bHasHeadset = false;
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Check For Headset couldn't get the voice interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
bHasHeadset = VoiceInterface->IsHeadsetPresent(LocalPlayerNum);
|
||||
}
|
||||
|
||||
void UAdvancedVoiceLibrary::StartNetworkedVoice(uint8 LocalPlayerNum)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Start Networked Voice couldn't get the voice interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
VoiceInterface->StartNetworkedVoice(LocalPlayerNum);
|
||||
}
|
||||
|
||||
void UAdvancedVoiceLibrary::StopNetworkedVoice(uint8 LocalPlayerNum)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Start Networked Voice couldn't get the voice interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
VoiceInterface->StopNetworkedVoice(LocalPlayerNum);
|
||||
}
|
||||
|
||||
bool UAdvancedVoiceLibrary::RegisterLocalTalker(uint8 LocalPlayerNum)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Local Talker couldn't get the voice interface!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return VoiceInterface->RegisterLocalTalker(LocalPlayerNum);
|
||||
}
|
||||
|
||||
void UAdvancedVoiceLibrary::RegisterAllLocalTalkers()
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Local Talkers couldn't get the voice interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
VoiceInterface->RegisterLocalTalkers();
|
||||
}
|
||||
|
||||
|
||||
void UAdvancedVoiceLibrary::UnRegisterLocalTalker(uint8 LocalPlayerNum)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unregister Local Talker couldn't get the voice interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
VoiceInterface->UnregisterLocalTalker(LocalPlayerNum);
|
||||
}
|
||||
|
||||
void UAdvancedVoiceLibrary::UnRegisterAllLocalTalkers()
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister All Local Talkers couldn't get the voice interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
VoiceInterface->UnregisterLocalTalkers();
|
||||
}
|
||||
|
||||
bool UAdvancedVoiceLibrary::RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Remote Talker couldn't get the voice interface!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return VoiceInterface->RegisterRemoteTalker(*UniqueNetId.GetUniqueNetId());
|
||||
}
|
||||
|
||||
bool UAdvancedVoiceLibrary::UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister Remote Talker couldn't get the voice interface!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return VoiceInterface->UnregisterRemoteTalker(*UniqueNetId.GetUniqueNetId());
|
||||
}
|
||||
|
||||
void UAdvancedVoiceLibrary::RemoveAllRemoteTalkers()
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Remove All Remote Talkers couldn't get the voice interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
VoiceInterface->RemoveAllRemoteTalkers();
|
||||
}
|
||||
|
||||
bool UAdvancedVoiceLibrary::IsLocalPlayerTalking(uint8 LocalPlayerNum)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Local Player Talking couldn't get the voice interface!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return VoiceInterface->IsLocalPlayerTalking(LocalPlayerNum);
|
||||
}
|
||||
|
||||
bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Remote Player Talking couldn't get the voice interface!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return VoiceInterface->IsRemotePlayerTalking(*UniqueNetId.GetUniqueNetId());
|
||||
}
|
||||
|
||||
bool UAdvancedVoiceLibrary::IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Player Muted couldn't get the voice interface!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return VoiceInterface->IsMuted(LocalUserNumChecking, *UniqueNetId.GetUniqueNetId());
|
||||
}
|
||||
|
||||
bool UAdvancedVoiceLibrary::MuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Mute Remote Talker couldn't get the voice interface!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return VoiceInterface->MuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide);
|
||||
}
|
||||
|
||||
bool UAdvancedVoiceLibrary::UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return VoiceInterface->UnmuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide);
|
||||
}
|
||||
|
||||
|
||||
void UAdvancedVoiceLibrary::GetNumLocalTalkers(int32 & NumLocalTalkers)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
|
||||
if (!VoiceInterface.IsValid())
|
||||
{
|
||||
NumLocalTalkers = 0;
|
||||
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
NumLocalTalkers = VoiceInterface->GetNumLocalTalkers();
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "CancelFindSessionsCallbackProxy.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UCancelFindSessionsCallbackProxy
|
||||
|
||||
UCancelFindSessionsCallbackProxy::UCancelFindSessionsCallbackProxy(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, Delegate(FOnCancelFindSessionsCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted))
|
||||
{
|
||||
}
|
||||
|
||||
UCancelFindSessionsCallbackProxy* UCancelFindSessionsCallbackProxy::CancelFindSessions(UObject* WorldContextObject, class APlayerController* PlayerController)
|
||||
{
|
||||
UCancelFindSessionsCallbackProxy* Proxy = NewObject<UCancelFindSessionsCallbackProxy>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void UCancelFindSessionsCallbackProxy::Activate()
|
||||
{
|
||||
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CancelFindSessions"), GEngine->GetWorldFromContextObject(WorldContextObject));
|
||||
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
|
||||
|
||||
if (Helper.IsValid())
|
||||
{
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
DelegateHandle = Sessions->AddOnCancelFindSessionsCompleteDelegate_Handle(Delegate);
|
||||
Sessions->CancelFindSessions();
|
||||
|
||||
// OnCompleted 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();
|
||||
}
|
||||
|
||||
void UCancelFindSessionsCallbackProxy::OnCompleted(bool bWasSuccessful)
|
||||
{
|
||||
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CancelFindSessionsCallback"), GEngine->GetWorldFromContextObject(WorldContextObject));
|
||||
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
|
||||
|
||||
if (Helper.IsValid())
|
||||
{
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
Sessions->ClearOnCancelFindSessionsCompleteDelegate_Handle(DelegateHandle);
|
||||
}
|
||||
}
|
||||
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
OnSuccess.Broadcast();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
}
|
||||
}
|
@@ -0,0 +1,151 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "CreateSessionCallbackProxyAdvanced.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UCreateSessionCallbackProxyAdvanced
|
||||
|
||||
UCreateSessionCallbackProxyAdvanced::UCreateSessionCallbackProxyAdvanced(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, CreateCompleteDelegate(FOnCreateSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnCreateCompleted))
|
||||
, StartCompleteDelegate(FOnStartSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnStartCompleted))
|
||||
, NumPublicConnections(1)
|
||||
{
|
||||
}
|
||||
|
||||
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* Proxy = NewObject<UCreateSessionCallbackProxyAdvanced>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
Proxy->NumPublicConnections = PublicConnections;
|
||||
Proxy->NumPrivateConnections = PrivateConnections;
|
||||
Proxy->bUseLAN = bUseLAN;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
Proxy->bAllowInvites = bAllowInvites;
|
||||
Proxy->ExtraSettings = ExtraSettings;
|
||||
Proxy->bDedicatedServer = bIsDedicatedServer;
|
||||
Proxy->bUsePresence = bUsePresence;
|
||||
Proxy->bAllowJoinViaPresence = bAllowJoinViaPresence;
|
||||
Proxy->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
|
||||
Proxy->bAntiCheatProtected = bAntiCheatProtected;
|
||||
Proxy->bUsesStats = bUsesStats;
|
||||
Proxy->bShouldAdvertise = bShouldAdvertise;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void UCreateSessionCallbackProxyAdvanced::Activate()
|
||||
{
|
||||
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CreateSession"), GEngine->GetWorldFromContextObject(WorldContextObject));
|
||||
|
||||
if (PlayerControllerWeakPtr.IsValid() )
|
||||
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
|
||||
|
||||
if (Helper.OnlineSub != nullptr)
|
||||
{
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
CreateCompleteDelegateHandle = Sessions->AddOnCreateSessionCompleteDelegate_Handle(CreateCompleteDelegate);
|
||||
|
||||
FOnlineSessionSettings Settings;
|
||||
Settings.NumPublicConnections = NumPublicConnections;
|
||||
Settings.NumPrivateConnections = NumPrivateConnections;
|
||||
Settings.bShouldAdvertise = true;
|
||||
Settings.bAllowJoinInProgress = true;
|
||||
Settings.bIsLANMatch = bUseLAN;
|
||||
Settings.bAllowJoinViaPresence = true;
|
||||
Settings.bIsDedicated = bDedicatedServer;
|
||||
|
||||
if (bDedicatedServer)
|
||||
Settings.bUsesPresence = false;
|
||||
else
|
||||
Settings.bUsesPresence = bUsePresence;
|
||||
|
||||
Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
|
||||
Settings.bAntiCheatProtected = bAntiCheatProtected;
|
||||
Settings.bUsesStats = bUsesStats;
|
||||
Settings.bShouldAdvertise = bShouldAdvertise;
|
||||
|
||||
// These are about the only changes over the standard Create Sessions Node
|
||||
Settings.bAllowInvites = bAllowInvites;
|
||||
|
||||
FOnlineSessionSetting ExtraSetting;
|
||||
for (int i = 0; i < ExtraSettings.Num(); i++)
|
||||
{
|
||||
ExtraSetting.Data = ExtraSettings[i].Data;
|
||||
// ViaOnlineServiceAndPing
|
||||
ExtraSetting.AdvertisementType = EOnlineDataAdvertisementType::ViaOnlineService;
|
||||
Settings.Settings.Add(ExtraSettings[i].Key, ExtraSetting);
|
||||
}
|
||||
|
||||
|
||||
if (!bDedicatedServer && PlayerControllerWeakPtr.IsValid() && Helper.UserID.IsValid())
|
||||
Sessions->CreateSession(*Helper.UserID, GameSessionName, Settings);
|
||||
else
|
||||
Sessions->CreateSession(0, GameSessionName, Settings);
|
||||
|
||||
// OnCreateCompleted 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();
|
||||
}
|
||||
|
||||
void UCreateSessionCallbackProxyAdvanced::OnCreateCompleted(FName SessionName, bool bWasSuccessful)
|
||||
{
|
||||
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CreateSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject));
|
||||
//Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
|
||||
|
||||
if (Helper.OnlineSub != nullptr)
|
||||
{
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
Sessions->ClearOnCreateSessionCompleteDelegate_Handle(CreateCompleteDelegateHandle);
|
||||
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
StartCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(StartCompleteDelegate);
|
||||
Sessions->StartSession(GameSessionName);
|
||||
|
||||
// OnStartCompleted will get called, nothing more to do now
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bWasSuccessful)
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
}
|
||||
}
|
||||
|
||||
void UCreateSessionCallbackProxyAdvanced::OnStartCompleted(FName SessionName, bool bWasSuccessful)
|
||||
{
|
||||
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("StartSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject));
|
||||
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
|
||||
|
||||
if (Helper.OnlineSub != nullptr)
|
||||
{
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
Sessions->ClearOnStartSessionCompleteDelegate_Handle(StartCompleteDelegateHandle);
|
||||
}
|
||||
}
|
||||
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
OnSuccess.Broadcast();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "EndSessionCallbackProxy.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UEndSessionCallbackProxy
|
||||
|
||||
UEndSessionCallbackProxy::UEndSessionCallbackProxy(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, Delegate(FOnEndSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted))
|
||||
{
|
||||
}
|
||||
|
||||
UEndSessionCallbackProxy* UEndSessionCallbackProxy::EndSession(UObject* WorldContextObject, class APlayerController* PlayerController)
|
||||
{
|
||||
UEndSessionCallbackProxy* Proxy = NewObject<UEndSessionCallbackProxy>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void UEndSessionCallbackProxy::Activate()
|
||||
{
|
||||
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("EndSession"), GEngine->GetWorldFromContextObject(WorldContextObject));
|
||||
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
|
||||
|
||||
if (Helper.IsValid())
|
||||
{
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
FNamedOnlineSession* Session = Sessions->GetNamedSession(GameSessionName);
|
||||
if (Session &&
|
||||
Session->SessionState == EOnlineSessionState::InProgress)
|
||||
{
|
||||
DelegateHandle = Sessions->AddOnEndSessionCompleteDelegate_Handle(Delegate);
|
||||
Sessions->EndSession(GameSessionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnSuccess.Broadcast();
|
||||
}
|
||||
// OnCompleted 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();
|
||||
}
|
||||
|
||||
void UEndSessionCallbackProxy::OnCompleted(FName SessionName, bool bWasSuccessful)
|
||||
{
|
||||
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("EndSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject));
|
||||
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
|
||||
|
||||
if (Helper.IsValid())
|
||||
{
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
Sessions->ClearOnEndSessionCompleteDelegate_Handle(DelegateHandle);
|
||||
}
|
||||
}
|
||||
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
OnSuccess.Broadcast();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
}
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "FindFriendSessionCallbackProxy.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UGetRecentPlayersCallbackProxy
|
||||
DEFINE_LOG_CATEGORY(AdvancedFindFriendSessionLog);
|
||||
|
||||
UFindFriendSessionCallbackProxy::UFindFriendSessionCallbackProxy(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, OnFindFriendSessionCompleteDelegate(FOnFindFriendSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnFindFriendSessionCompleted))
|
||||
{
|
||||
}
|
||||
|
||||
UFindFriendSessionCallbackProxy* UFindFriendSessionCallbackProxy::FindFriendSession(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId)
|
||||
{
|
||||
UFindFriendSessionCallbackProxy* Proxy = NewObject<UFindFriendSessionCallbackProxy>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
Proxy->cUniqueNetId = FriendUniqueNetId;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void UFindFriendSessionCallbackProxy::Activate()
|
||||
{
|
||||
if (!cUniqueNetId.IsValid())
|
||||
{
|
||||
// Fail immediately
|
||||
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed received a bad UniqueNetId!"));
|
||||
FBlueprintSessionResult EmptyResult;
|
||||
OnFailure.Broadcast(EmptyResult);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PlayerControllerWeakPtr.IsValid())
|
||||
{
|
||||
// Fail immediately
|
||||
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed received a bad playercontroller!"));
|
||||
FBlueprintSessionResult EmptyResult;
|
||||
OnFailure.Broadcast(EmptyResult);
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface();
|
||||
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
// Fail immediately
|
||||
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed couldn't cast to ULocalPlayer!"));
|
||||
FBlueprintSessionResult EmptyResult;
|
||||
OnFailure.Broadcast(EmptyResult);
|
||||
return;
|
||||
}
|
||||
|
||||
FindFriendSessionCompleteDelegateHandle = Sessions->AddOnFindFriendSessionCompleteDelegate_Handle(Player->GetControllerId(), OnFindFriendSessionCompleteDelegate);
|
||||
|
||||
Sessions->FindFriendSession(Player->GetControllerId(), *cUniqueNetId.GetUniqueNetId());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Fail immediately
|
||||
FBlueprintSessionResult EmptyResult;
|
||||
OnFailure.Broadcast(EmptyResult);
|
||||
}
|
||||
|
||||
void UFindFriendSessionCallbackProxy::OnFindFriendSessionCompleted(int32 LocalPlayer, bool bWasSuccessful, const FOnlineSessionSearchResult& SessionInfo)
|
||||
{
|
||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface();
|
||||
|
||||
if (Sessions.IsValid())
|
||||
Sessions->ClearOnFindFriendSessionCompleteDelegate_Handle(LocalPlayer, FindFriendSessionCompleteDelegateHandle);
|
||||
|
||||
if ( bWasSuccessful )
|
||||
{
|
||||
FBlueprintSessionResult Result;
|
||||
Result.OnlineResult = SessionInfo;
|
||||
if(Result.OnlineResult.IsValid())
|
||||
OnSuccess.Broadcast(Result);
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed, returned an invalid session."));
|
||||
OnFailure.Broadcast(Result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed"));
|
||||
FBlueprintSessionResult EmptyResult;
|
||||
OnFailure.Broadcast(EmptyResult);
|
||||
}
|
||||
}
|
@@ -0,0 +1,414 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "FindSessionsCallbackProxyAdvanced.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UFindSessionsCallbackProxyAdvanced
|
||||
|
||||
|
||||
UFindSessionsCallbackProxyAdvanced::UFindSessionsCallbackProxyAdvanced(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, Delegate(FOnFindSessionsCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted))
|
||||
, bUseLAN(false)
|
||||
{
|
||||
bRunSecondSearch = false;
|
||||
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* Proxy = NewObject<UFindSessionsCallbackProxyAdvanced>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
Proxy->bUseLAN = bUseLAN;
|
||||
Proxy->MaxResults = MaxResults;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
Proxy->SearchSettings = Filters;
|
||||
Proxy->ServerSearchType = ServerTypeToSearch;
|
||||
Proxy->bEmptyServersOnly = bEmptyServersOnly,
|
||||
Proxy->bNonEmptyServersOnly = bNonEmptyServersOnly;
|
||||
Proxy->bSecureServersOnly = bSecureServersOnly;
|
||||
Proxy->MinSlotsAvailable = MinSlotsAvailable;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void UFindSessionsCallbackProxyAdvanced::Activate()
|
||||
{
|
||||
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("FindSessions"), GEngine->GetWorldFromContextObject(WorldContextObject));
|
||||
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
|
||||
|
||||
if (Helper.IsValid())
|
||||
{
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
// Re-initialize here, otherwise I think there might be issues with people re-calling search for some reason before it is destroyed
|
||||
bRunSecondSearch = false;
|
||||
bIsOnSecondSearch = false;
|
||||
|
||||
DelegateHandle = Sessions->AddOnFindSessionsCompleteDelegate_Handle(Delegate);
|
||||
|
||||
SearchObject = MakeShareable(new FOnlineSessionSearch);
|
||||
SearchObject->MaxSearchResults = MaxResults;
|
||||
SearchObject->bIsLanQuery = bUseLAN;
|
||||
//SearchObject->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||
|
||||
// Create temp filter variable, because I had to re-define a blueprint version of this, it is required.
|
||||
FOnlineSearchSettingsEx tem;
|
||||
|
||||
/* // Search only for dedicated servers (value is true/false)
|
||||
#define SEARCH_DEDICATED_ONLY FName(TEXT("DEDICATEDONLY"))
|
||||
// Search for empty servers only (value is true/false)
|
||||
#define SEARCH_EMPTY_SERVERS_ONLY FName(TEXT("EMPTYONLY"))
|
||||
// Search for non empty servers only (value is true/false)
|
||||
#define SEARCH_NONEMPTY_SERVERS_ONLY FName(TEXT("NONEMPTYONLY"))
|
||||
// Search for secure servers only (value is true/false)
|
||||
#define SEARCH_SECURE_SERVERS_ONLY FName(TEXT("SECUREONLY"))
|
||||
// Search for presence sessions only (value is true/false)
|
||||
#define SEARCH_PRESENCE FName(TEXT("PRESENCESEARCH"))
|
||||
// Search for a match with min player availability (value is int)
|
||||
#define SEARCH_MINSLOTSAVAILABLE FName(TEXT("MINSLOTSAVAILABLE"))
|
||||
// Exclude all matches where any unique ids in a given array are present (value is string of the form "uniqueid1;uniqueid2;uniqueid3")
|
||||
#define SEARCH_EXCLUDE_UNIQUEIDS FName(TEXT("EXCLUDEUNIQUEIDS"))
|
||||
// User ID to search for session of
|
||||
#define SEARCH_USER FName(TEXT("SEARCHUSER"))
|
||||
// Keywords to match in session search
|
||||
#define SEARCH_KEYWORDS FName(TEXT("SEARCHKEYWORDS"))*/
|
||||
|
||||
if (bEmptyServersOnly)
|
||||
tem.Set(SEARCH_EMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals);
|
||||
|
||||
if (bNonEmptyServersOnly)
|
||||
tem.Set(SEARCH_NONEMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals);
|
||||
|
||||
if (bSecureServersOnly)
|
||||
tem.Set(SEARCH_SECURE_SERVERS_ONLY, true, EOnlineComparisonOp::Equals);
|
||||
|
||||
if (MinSlotsAvailable != 0)
|
||||
tem.Set(SEARCH_MINSLOTSAVAILABLE, MinSlotsAvailable, EOnlineComparisonOp::GreaterThanEquals);
|
||||
|
||||
|
||||
|
||||
// Filter results
|
||||
if (SearchSettings.Num() > 0)
|
||||
{
|
||||
for (int i = 0; i < SearchSettings.Num(); i++)
|
||||
{
|
||||
// Function that was added to make directly adding a FVariant possible
|
||||
tem.HardSet(SearchSettings[i].PropertyKeyPair.Key, SearchSettings[i].PropertyKeyPair.Data, SearchSettings[i].ComparisonOp);
|
||||
}
|
||||
}
|
||||
|
||||
switch (ServerSearchType)
|
||||
{
|
||||
|
||||
case EBPServerPresenceSearchType::ClientServersOnly:
|
||||
{
|
||||
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||
}
|
||||
break;
|
||||
|
||||
case EBPServerPresenceSearchType::DedicatedServersOnly:
|
||||
{
|
||||
//tem.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
||||
}
|
||||
break;
|
||||
|
||||
case EBPServerPresenceSearchType::AllServers:
|
||||
default:
|
||||
{
|
||||
// Only steam uses the separate searching flags currently
|
||||
if (IOnlineSubsystem::DoesInstanceExist("STEAM"))
|
||||
{
|
||||
bRunSecondSearch = true;
|
||||
|
||||
SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch);
|
||||
SearchObjectDedicated->MaxSearchResults = MaxResults;
|
||||
SearchObjectDedicated->bIsLanQuery = bUseLAN;
|
||||
|
||||
FOnlineSearchSettingsEx DedicatedOnly = tem;
|
||||
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||
|
||||
//DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
||||
SearchObjectDedicated->QuerySettings = DedicatedOnly;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Copy the derived temp variable over to it's base class
|
||||
SearchObject->QuerySettings = tem;
|
||||
|
||||
Sessions->FindSessions(*Helper.UserID, SearchObject.ToSharedRef());
|
||||
|
||||
// OnQueryCompleted 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(SessionSearchResults);
|
||||
}
|
||||
|
||||
void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
||||
{
|
||||
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("FindSessionsCallback"), GEngine->GetWorldFromContextObject(WorldContextObject));
|
||||
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
|
||||
|
||||
if (!bRunSecondSearch && Helper.IsValid())
|
||||
{
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
Sessions->ClearOnFindSessionsCompleteDelegate_Handle(DelegateHandle);
|
||||
}
|
||||
}
|
||||
|
||||
if (bSuccess)
|
||||
{
|
||||
if (bIsOnSecondSearch)
|
||||
{
|
||||
if (SearchObjectDedicated.IsValid())
|
||||
{
|
||||
// Just log the results for now, will need to add a blueprint-compatible search result struct
|
||||
for (auto& Result : SearchObjectDedicated->SearchResults)
|
||||
{
|
||||
FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs);
|
||||
|
||||
FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log);
|
||||
|
||||
FBlueprintSessionResult BPResult;
|
||||
BPResult.OnlineResult = Result;
|
||||
SessionSearchResults.Add(BPResult);
|
||||
}
|
||||
OnSuccess.Broadcast(SessionSearchResults);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SearchObject.IsValid())
|
||||
{
|
||||
// Just log the results for now, will need to add a blueprint-compatible search result struct
|
||||
for (auto& Result : SearchObject->SearchResults)
|
||||
{
|
||||
FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs);
|
||||
|
||||
FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log);
|
||||
|
||||
FBlueprintSessionResult BPResult;
|
||||
BPResult.OnlineResult = Result;
|
||||
SessionSearchResults.Add(BPResult);
|
||||
}
|
||||
if (!bRunSecondSearch)
|
||||
{
|
||||
OnSuccess.Broadcast(SessionSearchResults);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bRunSecondSearch)
|
||||
{
|
||||
// Need to account for only one of the searches failing
|
||||
if (SessionSearchResults.Num() > 0)
|
||||
OnSuccess.Broadcast(SessionSearchResults);
|
||||
else
|
||||
OnFailure.Broadcast(SessionSearchResults);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (bRunSecondSearch && ServerSearchType == EBPServerPresenceSearchType::AllServers)
|
||||
{
|
||||
bRunSecondSearch = false;
|
||||
bIsOnSecondSearch = true;
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
Sessions->FindSessions(*Helper.UserID, SearchObjectDedicated.ToSharedRef());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UFindSessionsCallbackProxyAdvanced::FilterSessionResults(const TArray<FBlueprintSessionResult> &SessionResults, const TArray<FSessionsSearchSetting> &Filters, TArray<FBlueprintSessionResult> &FilteredResults)
|
||||
{
|
||||
for (int j = 0; j < SessionResults.Num(); j++)
|
||||
{
|
||||
bool bAddResult = true;
|
||||
|
||||
// Filter results
|
||||
if (Filters.Num() > 0)
|
||||
{
|
||||
const FOnlineSessionSetting * setting;
|
||||
for (int i = 0; i < Filters.Num(); i++)
|
||||
{
|
||||
setting = SessionResults[j].OnlineResult.Session.SessionSettings.Settings.Find(Filters[i].PropertyKeyPair.Key);
|
||||
|
||||
// Couldn't find this key
|
||||
if (!setting)
|
||||
continue;
|
||||
|
||||
if (!CompareVariants(setting->Data, Filters[i].PropertyKeyPair.Data, Filters[i].ComparisonOp))
|
||||
{
|
||||
bAddResult = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bAddResult)
|
||||
FilteredResults.Add(SessionResults[j]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool UFindSessionsCallbackProxyAdvanced::CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator)
|
||||
{
|
||||
if (A.GetType() != B.GetType())
|
||||
return false;
|
||||
|
||||
switch (A.GetType())
|
||||
{
|
||||
case EOnlineKeyValuePairDataType::Bool:
|
||||
{
|
||||
bool bA, bB;
|
||||
A.GetValue(bA);
|
||||
B.GetValue(bB);
|
||||
switch (Comparator)
|
||||
{
|
||||
case EOnlineComparisonOpRedux::Equals:
|
||||
return bA == bB; break;
|
||||
case EOnlineComparisonOpRedux::NotEquals:
|
||||
return bA != bB; break;
|
||||
default:
|
||||
return false;break;
|
||||
}
|
||||
}
|
||||
case EOnlineKeyValuePairDataType::Double:
|
||||
{
|
||||
double bA, bB;
|
||||
A.GetValue(bA);
|
||||
B.GetValue(bB);
|
||||
switch (Comparator)
|
||||
{
|
||||
case EOnlineComparisonOpRedux::Equals:
|
||||
return bA == bB; break;
|
||||
case EOnlineComparisonOpRedux::NotEquals:
|
||||
return bA != bB; break;
|
||||
case EOnlineComparisonOpRedux::GreaterThanEquals:
|
||||
return (bA == bB || bA > bB); break;
|
||||
case EOnlineComparisonOpRedux::LessThanEquals:
|
||||
return (bA == bB || bA < bB); break;
|
||||
case EOnlineComparisonOpRedux::GreaterThan:
|
||||
return bA > bB; break;
|
||||
case EOnlineComparisonOpRedux::LessThan:
|
||||
return bA < bB; break;
|
||||
default:
|
||||
return false; break;
|
||||
}
|
||||
}
|
||||
case EOnlineKeyValuePairDataType::Float:
|
||||
{
|
||||
float tbA, tbB;
|
||||
double bA, bB;
|
||||
A.GetValue(tbA);
|
||||
B.GetValue(tbB);
|
||||
bA = (double)tbA;
|
||||
bB = (double)tbB;
|
||||
switch (Comparator)
|
||||
{
|
||||
case EOnlineComparisonOpRedux::Equals:
|
||||
return bA == bB; break;
|
||||
case EOnlineComparisonOpRedux::NotEquals:
|
||||
return bA != bB; break;
|
||||
case EOnlineComparisonOpRedux::GreaterThanEquals:
|
||||
return (bA == bB || bA > bB); break;
|
||||
case EOnlineComparisonOpRedux::LessThanEquals:
|
||||
return (bA == bB || bA < bB); break;
|
||||
case EOnlineComparisonOpRedux::GreaterThan:
|
||||
return bA > bB; break;
|
||||
case EOnlineComparisonOpRedux::LessThan:
|
||||
return bA < bB; break;
|
||||
default:
|
||||
return false; break;
|
||||
}
|
||||
}
|
||||
case EOnlineKeyValuePairDataType::Int32:
|
||||
{
|
||||
int32 bA, bB;
|
||||
A.GetValue(bA);
|
||||
B.GetValue(bB);
|
||||
switch (Comparator)
|
||||
{
|
||||
case EOnlineComparisonOpRedux::Equals:
|
||||
return bA == bB; break;
|
||||
case EOnlineComparisonOpRedux::NotEquals:
|
||||
return bA != bB; break;
|
||||
case EOnlineComparisonOpRedux::GreaterThanEquals:
|
||||
return (bA == bB || bA > bB); break;
|
||||
case EOnlineComparisonOpRedux::LessThanEquals:
|
||||
return (bA == bB || bA < bB); break;
|
||||
case EOnlineComparisonOpRedux::GreaterThan:
|
||||
return bA > bB; break;
|
||||
case EOnlineComparisonOpRedux::LessThan:
|
||||
return bA < bB; break;
|
||||
default:
|
||||
return false; break;
|
||||
}
|
||||
}
|
||||
case EOnlineKeyValuePairDataType::Int64:
|
||||
{
|
||||
uint64 bA, bB;
|
||||
A.GetValue(bA);
|
||||
B.GetValue(bB);
|
||||
switch (Comparator)
|
||||
{
|
||||
case EOnlineComparisonOpRedux::Equals:
|
||||
return bA == bB; break;
|
||||
case EOnlineComparisonOpRedux::NotEquals:
|
||||
return bA != bB; break;
|
||||
case EOnlineComparisonOpRedux::GreaterThanEquals:
|
||||
return (bA == bB || bA > bB); break;
|
||||
case EOnlineComparisonOpRedux::LessThanEquals:
|
||||
return (bA == bB || bA < bB); break;
|
||||
case EOnlineComparisonOpRedux::GreaterThan:
|
||||
return bA > bB; break;
|
||||
case EOnlineComparisonOpRedux::LessThan:
|
||||
return bA < bB; break;
|
||||
default:
|
||||
return false; break;
|
||||
}
|
||||
}
|
||||
|
||||
case EOnlineKeyValuePairDataType::String:
|
||||
{
|
||||
FString bA, bB;
|
||||
A.GetValue(bA);
|
||||
B.GetValue(bB);
|
||||
switch (Comparator)
|
||||
{
|
||||
case EOnlineComparisonOpRedux::Equals:
|
||||
return bA == bB; break;
|
||||
case EOnlineComparisonOpRedux::NotEquals:
|
||||
return bA != bB; break;
|
||||
default:
|
||||
return false; break;
|
||||
}
|
||||
}
|
||||
|
||||
case EOnlineKeyValuePairDataType::Empty:
|
||||
case EOnlineKeyValuePairDataType::Blob:
|
||||
default:
|
||||
return false; break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "GetFriendsCallbackProxy.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UGetFriendsCallbackProxy
|
||||
DEFINE_LOG_CATEGORY(AdvancedGetFriendsLog);
|
||||
|
||||
UGetFriendsCallbackProxy::UGetFriendsCallbackProxy(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, FriendListReadCompleteDelegate(FOnReadFriendsListComplete::CreateUObject(this, &ThisClass::OnReadFriendsListCompleted))
|
||||
{
|
||||
}
|
||||
|
||||
UGetFriendsCallbackProxy* UGetFriendsCallbackProxy::GetAndStoreFriendsList(UObject* WorldContextObject, class APlayerController* PlayerController)
|
||||
{
|
||||
UGetFriendsCallbackProxy* Proxy = NewObject<UGetFriendsCallbackProxy>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void UGetFriendsCallbackProxy::Activate()
|
||||
{
|
||||
if (!PlayerControllerWeakPtr.IsValid())
|
||||
{
|
||||
// Fail immediately
|
||||
UE_LOG(AdvancedGetFriendsLog, Warning, TEXT("GetFriends Failed received a bad player controller!"));
|
||||
TArray<FBPFriendInfo> EmptyArray;
|
||||
OnFailure.Broadcast(EmptyArray);
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
|
||||
if (Friends.IsValid())
|
||||
{
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
||||
|
||||
Friends->ReadFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendListReadCompleteDelegate);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fail immediately
|
||||
TArray<FBPFriendInfo> EmptyArray;
|
||||
|
||||
OnFailure.Broadcast(EmptyArray);
|
||||
}
|
||||
|
||||
void UGetFriendsCallbackProxy::OnReadFriendsListCompleted(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorString)
|
||||
{
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
|
||||
if (Friends.IsValid())
|
||||
{
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
||||
|
||||
TArray<FBPFriendInfo> FriendsListOut;
|
||||
TArray< TSharedRef<FOnlineFriend> > FriendList;
|
||||
Friends->GetFriendsList(LocalUserNum, ListName, FriendList);
|
||||
|
||||
for (int32 i = 0; i < FriendList.Num(); i++)
|
||||
{
|
||||
TSharedRef<FOnlineFriend> Friend = FriendList[i];
|
||||
FBPFriendInfo BPF;
|
||||
FOnlineUserPresence pres = Friend->GetPresence();
|
||||
BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
|
||||
BPF.DisplayName = Friend->GetDisplayName();
|
||||
BPF.RealName = Friend->GetRealName();
|
||||
BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId());
|
||||
BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame;
|
||||
|
||||
BPF.PresenceInfo.bIsOnline = pres.bIsOnline;
|
||||
BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport;
|
||||
BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying;
|
||||
BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
|
||||
BPF.PresenceInfo.StatusString = pres.Status.StatusStr;
|
||||
BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable;
|
||||
BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame;
|
||||
|
||||
|
||||
FriendsListOut.Add(BPF);
|
||||
}
|
||||
|
||||
OnSuccess.Broadcast(FriendsListOut);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TArray<FBPFriendInfo> EmptyArray;
|
||||
OnFailure.Broadcast(EmptyArray);
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "GetRecentPlayersCallbackProxy.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UGetRecentPlayersCallbackProxy
|
||||
DEFINE_LOG_CATEGORY(AdvancedGetRecentPlayersLog);
|
||||
|
||||
UGetRecentPlayersCallbackProxy::UGetRecentPlayersCallbackProxy(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, QueryRecentPlayersCompleteDelegate(FOnQueryRecentPlayersCompleteDelegate::CreateUObject(this, &ThisClass::OnQueryRecentPlayersCompleted))
|
||||
{
|
||||
}
|
||||
|
||||
UGetRecentPlayersCallbackProxy* UGetRecentPlayersCallbackProxy::GetAndStoreRecentPlayersList(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId)
|
||||
{
|
||||
UGetRecentPlayersCallbackProxy* Proxy = NewObject<UGetRecentPlayersCallbackProxy>();
|
||||
Proxy->cUniqueNetId = UniqueNetId;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void UGetRecentPlayersCallbackProxy::Activate()
|
||||
{
|
||||
if (!cUniqueNetId.IsValid())
|
||||
{
|
||||
// Fail immediately
|
||||
UE_LOG(AdvancedGetRecentPlayersLog, Warning, TEXT("GetRecentPlayers Failed received a bad UniqueNetId!"));
|
||||
TArray<FBPOnlineRecentPlayer> EmptyArray;
|
||||
OnFailure.Broadcast(EmptyArray);
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
|
||||
if (Friends.IsValid())
|
||||
{
|
||||
DelegateHandle = Friends->AddOnQueryRecentPlayersCompleteDelegate_Handle(QueryRecentPlayersCompleteDelegate);
|
||||
|
||||
// Testing with null namespace
|
||||
Friends->QueryRecentPlayers(*(cUniqueNetId.GetUniqueNetId()), "");
|
||||
return;
|
||||
}
|
||||
// Fail immediately
|
||||
TArray<FBPOnlineRecentPlayer> EmptyArray;
|
||||
OnFailure.Broadcast(EmptyArray);
|
||||
}
|
||||
|
||||
void UGetRecentPlayersCallbackProxy::OnQueryRecentPlayersCompleted(const FUniqueNetId &UserID, const FString &Namespace, bool bWasSuccessful, const FString& ErrorString)
|
||||
{
|
||||
|
||||
IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
|
||||
if (Friends.IsValid())
|
||||
Friends->ClearOnQueryRecentPlayersCompleteDelegate_Handle(DelegateHandle);
|
||||
|
||||
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
// WHOOPS
|
||||
//IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
|
||||
if (Friends.IsValid())
|
||||
{
|
||||
TArray<FBPOnlineRecentPlayer> PlayersListOut;
|
||||
TArray< TSharedRef<FOnlineRecentPlayer> > PlayerList;
|
||||
|
||||
Friends->GetRecentPlayers(*(cUniqueNetId.GetUniqueNetId()), "", PlayerList);
|
||||
|
||||
for (int32 i = 0; i < PlayerList.Num(); i++)
|
||||
{
|
||||
TSharedRef<FOnlineRecentPlayer> Player = PlayerList[i];
|
||||
FBPOnlineRecentPlayer BPF;
|
||||
BPF.DisplayName = Player->GetDisplayName();
|
||||
BPF.RealName = Player->GetRealName();
|
||||
BPF.UniqueNetId.SetUniqueNetId(Player->GetUserId());
|
||||
PlayersListOut.Add(BPF);
|
||||
}
|
||||
|
||||
OnSuccess.Broadcast(PlayersListOut);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TArray<FBPOnlineRecentPlayer> EmptyArray;
|
||||
OnFailure.Broadcast(EmptyArray);
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "GetUserPrivilegeCallbackProxy.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UGetUserPrivilegeCallbackProxy
|
||||
|
||||
UGetUserPrivilegeCallbackProxy::UGetUserPrivilegeCallbackProxy(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
}
|
||||
|
||||
UGetUserPrivilegeCallbackProxy* UGetUserPrivilegeCallbackProxy::GetUserPrivilege(UObject* WorldContextObject, const EBPUserPrivileges & PrivilegeToCheck, const FBPUniqueNetId & PlayerUniqueNetID)
|
||||
{
|
||||
UGetUserPrivilegeCallbackProxy* Proxy = NewObject<UGetUserPrivilegeCallbackProxy>();
|
||||
Proxy->PlayerUniqueNetID.SetUniqueNetId(PlayerUniqueNetID.GetUniqueNetId());
|
||||
Proxy->UserPrivilege = PrivilegeToCheck;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void UGetUserPrivilegeCallbackProxy::Activate()
|
||||
{
|
||||
auto Identity = Online::GetIdentityInterface();
|
||||
|
||||
if (Identity.IsValid())
|
||||
{
|
||||
Identity->GetUserPrivilege(*PlayerUniqueNetID.GetUniqueNetId(), (EUserPrivileges::Type)UserPrivilege, IOnlineIdentity::FOnGetUserPrivilegeCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted));
|
||||
return;
|
||||
}
|
||||
|
||||
// Fail immediately
|
||||
OnFailure.Broadcast();
|
||||
}
|
||||
|
||||
void UGetUserPrivilegeCallbackProxy::OnCompleted(const FUniqueNetId& PlayerID, EUserPrivileges::Type Privilege, uint32 PrivilegeResult)
|
||||
{
|
||||
OnSuccess.Broadcast(/*PlayerID,*/ (EBPUserPrivileges)Privilege, PrivilegeResult == 0);
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "LoginUserCallbackProxy.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ULoginUserCallbackProxy
|
||||
|
||||
ULoginUserCallbackProxy::ULoginUserCallbackProxy(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, Delegate(FOnLoginCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted))
|
||||
{
|
||||
}
|
||||
|
||||
ULoginUserCallbackProxy* ULoginUserCallbackProxy::LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken)
|
||||
{
|
||||
ULoginUserCallbackProxy* Proxy = NewObject<ULoginUserCallbackProxy>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
Proxy->UserID = UserID;
|
||||
Proxy->UserToken = UserToken;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void ULoginUserCallbackProxy::Activate()
|
||||
{
|
||||
|
||||
if (!PlayerControllerWeakPtr.IsValid())
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
return;
|
||||
}
|
||||
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
return;
|
||||
}
|
||||
|
||||
auto Identity = Online::GetIdentityInterface();
|
||||
|
||||
if (Identity.IsValid())
|
||||
{
|
||||
DelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(Player->GetControllerId(), Delegate);
|
||||
FOnlineAccountCredentials AccountCreds(Identity->GetAuthType(), UserID, UserToken);
|
||||
Identity->Login(Player->GetControllerId(), AccountCreds);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fail immediately
|
||||
OnFailure.Broadcast();
|
||||
}
|
||||
|
||||
void ULoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& ErrorVal)
|
||||
{
|
||||
if (PlayerControllerWeakPtr.IsValid())
|
||||
{
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
||||
|
||||
if (Player)
|
||||
{
|
||||
auto Identity = Online::GetIdentityInterface();
|
||||
|
||||
if (Identity.IsValid())
|
||||
{
|
||||
Identity->ClearOnLoginCompleteDelegate_Handle(Player->GetControllerId(), DelegateHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
OnSuccess.Broadcast();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "LogoutUserCallbackProxy.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ULogoutUserCallbackProxy
|
||||
|
||||
ULogoutUserCallbackProxy::ULogoutUserCallbackProxy(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, Delegate(FOnLogoutCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted))
|
||||
{
|
||||
}
|
||||
|
||||
ULogoutUserCallbackProxy* ULogoutUserCallbackProxy::LogoutUser(UObject* WorldContextObject, class APlayerController* PlayerController)
|
||||
{
|
||||
ULogoutUserCallbackProxy* Proxy = NewObject<ULogoutUserCallbackProxy>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void ULogoutUserCallbackProxy::Activate()
|
||||
{
|
||||
|
||||
if (!PlayerControllerWeakPtr.IsValid())
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
return;
|
||||
}
|
||||
|
||||
auto Identity = Online::GetIdentityInterface();
|
||||
|
||||
if (Identity.IsValid())
|
||||
{
|
||||
DelegateHandle = Identity->AddOnLogoutCompleteDelegate_Handle(Player->GetControllerId(), Delegate);
|
||||
Identity->Logout(Player->GetControllerId());
|
||||
return;
|
||||
}
|
||||
|
||||
// Fail immediately
|
||||
OnFailure.Broadcast();
|
||||
}
|
||||
|
||||
void ULogoutUserCallbackProxy::OnCompleted(int LocalUserNum, bool bWasSuccessful)
|
||||
{
|
||||
|
||||
if (PlayerControllerWeakPtr.IsValid())
|
||||
{
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
||||
|
||||
if (Player)
|
||||
{
|
||||
auto Identity = Online::GetIdentityInterface();
|
||||
|
||||
if (Identity.IsValid())
|
||||
{
|
||||
Identity->ClearOnLogoutCompleteDelegate_Handle(Player->GetControllerId(), DelegateHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
OnSuccess.Broadcast();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "SendFriendInviteCallbackProxy.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UGetRecentPlayersCallbackProxy
|
||||
DEFINE_LOG_CATEGORY(AdvancedSendFriendInviteLog);
|
||||
|
||||
USendFriendInviteCallbackProxy::USendFriendInviteCallbackProxy(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, OnSendInviteCompleteDelegate(FOnSendInviteComplete::CreateUObject(this, &ThisClass::OnSendInviteComplete))
|
||||
{
|
||||
}
|
||||
|
||||
USendFriendInviteCallbackProxy* USendFriendInviteCallbackProxy::SendFriendInvite(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &UniqueNetIDInvited)
|
||||
{
|
||||
USendFriendInviteCallbackProxy* Proxy = NewObject<USendFriendInviteCallbackProxy>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
Proxy->cUniqueNetId = UniqueNetIDInvited;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void USendFriendInviteCallbackProxy::Activate()
|
||||
{
|
||||
if (!cUniqueNetId.IsValid())
|
||||
{
|
||||
// Fail immediately
|
||||
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed received a bad UniqueNetId!"));
|
||||
OnFailure.Broadcast();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PlayerControllerWeakPtr.IsValid())
|
||||
{
|
||||
// Fail immediately
|
||||
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed received a bad playercontroller!"));
|
||||
OnFailure.Broadcast();
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
|
||||
if (Friends.IsValid())
|
||||
{
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
// Fail immediately
|
||||
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed couldn't cast to ULocalPlayer!"));
|
||||
OnFailure.Broadcast();
|
||||
return;
|
||||
}
|
||||
|
||||
Friends->SendInvite(Player->GetControllerId(), *cUniqueNetId.GetUniqueNetId(), EFriendsLists::ToString((EFriendsLists::Default)), OnSendInviteCompleteDelegate);
|
||||
return;
|
||||
}
|
||||
// Fail immediately
|
||||
OnFailure.Broadcast();
|
||||
}
|
||||
|
||||
void USendFriendInviteCallbackProxy::OnSendInviteComplete(int32 LocalPlayerNum, bool bWasSuccessful, const FUniqueNetId &InvitedPlayer, const FString &ListName, const FString &ErrorString)
|
||||
{
|
||||
if ( bWasSuccessful )
|
||||
{
|
||||
OnSuccess.Broadcast();
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed with error: %s"), *ErrorString);
|
||||
OnFailure.Broadcast();
|
||||
}
|
||||
}
|
@@ -0,0 +1,121 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "UpdateSessionCallbackProxyAdvanced.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UUpdateSessionCallbackProxyAdvanced
|
||||
|
||||
UUpdateSessionCallbackProxyAdvanced::UUpdateSessionCallbackProxyAdvanced(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
, OnUpdateSessionCompleteDelegate(FOnUpdateSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnUpdateCompleted))
|
||||
, NumPublicConnections(1)
|
||||
{
|
||||
}
|
||||
|
||||
UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer)
|
||||
{
|
||||
UUpdateSessionCallbackProxyAdvanced* Proxy = NewObject<UUpdateSessionCallbackProxyAdvanced>();
|
||||
Proxy->NumPublicConnections = PublicConnections;
|
||||
Proxy->NumPrivateConnections = PrivateConnections;
|
||||
Proxy->bUseLAN = bUseLAN;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
Proxy->bAllowInvites = bAllowInvites;
|
||||
Proxy->ExtraSettings = ExtraSettings;
|
||||
Proxy->bRefreshOnlineData = bRefreshOnlineData;
|
||||
Proxy->bAllowJoinInProgress = bAllowJoinInProgress;
|
||||
Proxy->bDedicatedServer = bIsDedicatedServer;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void UUpdateSessionCallbackProxyAdvanced::Activate()
|
||||
{
|
||||
|
||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface();
|
||||
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
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(GameSessionName);
|
||||
FOnlineSessionSettings* Settings = Sessions->GetSessionSettings(GameSessionName);
|
||||
|
||||
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(GameSessionName, *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();
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Sessions not supported"));
|
||||
}
|
||||
|
||||
void UUpdateSessionCallbackProxyAdvanced::OnUpdateCompleted(FName SessionName, bool bWasSuccessful)
|
||||
{
|
||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle);
|
||||
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
OnSuccess.Broadcast();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bWasSuccessful)
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("WAS NOT SUCCESSFUL"));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user