Added identity interface, recompiled all binaries for 4.13.1

Former-commit-id: 8c89eb776e877ee486ca908db651667c7f87e469
This commit is contained in:
mordentral
2016-10-24 14:35:21 -04:00
parent d234ef1735
commit 942a0bbf90
24 changed files with 781 additions and 11 deletions

View File

@@ -1 +1 @@
a76786bb53d1bc69ee7cdab9e4aa673802d31bf2
74159387ae4c0dfa551782c1a573d879e76e7c94

View File

@@ -1 +1 @@
21bebdf84ebf3baa91d180db157a1f2e0dfbc4c0
e9c0072ee5f48736c5b6cb9d80f1d42378271f15

View File

@@ -1 +1 @@
4ace3e4516cc2a4e8f0b950cd9ceb22f25edfd00
ae6509d9c9a5a5b53e37150891505d9cebbc4071

View File

@@ -1 +1 @@
d2f96ab9defedded126a4780a18c04ff4d92b8bc
23b76fcc5841b5a13d093c31596b816e921eb107

View File

@@ -1 +1 @@
aff3301f274803705d0ef3315be24a6b3be274cf
1f54a896a8f905d9794a64b999ee51afdcf6bdd4

View File

@@ -1 +1 @@
e3d98226a589c3853040dbd109aec7be7dcc3742
23dbc3bb8dea26aeb165cdc493930866032ed598

View File

@@ -1 +1 @@
0f13228cdcdc42445bc1fe94748f423a786a21fe
205342f06ff0dfeee1431d6af7534a2d20c9f38f

View File

@@ -1 +1 @@
a9c3ed5d5005d7bc7bc08b55f03238128b11d6f4
3396b004f2ab8bd88779046049c8cfe099e3a6b9

View File

@@ -1,6 +1,6 @@
{
"Changelist" : 3142249,
"BuildId" : "8ec6c032-25a1-4060-b513-5852f4db170c",
"BuildId" : "4ef07da3-e88a-4906-9396-c2b96c225a4a",
"Modules" :
{
"AdvancedSessions" : "UE4Editor-AdvancedSessions-Win64-DebugGame.dll"

View File

@@ -1,6 +1,6 @@
{
"Changelist" : 3142249,
"BuildId" : "049386af-3641-4a3d-b799-3557f9ac0157",
"BuildId" : "4870daf4-0b02-459b-9258-609d8c5a2c4b",
"Modules" :
{
"AdvancedSessions" : "UE4Editor-AdvancedSessions.dll"

View File

@@ -32,6 +32,9 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallFriendInterfaceEventsOnPlayerControllers;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallIdentityInterfaceEventsOnPlayerControllers;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallVoiceInterfaceEventsOnPlayerControllers;
@@ -73,6 +76,24 @@ public:
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;

View File

@@ -40,6 +40,14 @@ public:
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"))

View File

@@ -0,0 +1,75 @@
// 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 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);
};

View File

@@ -13,6 +13,50 @@
#include "OnlineSubsystemUtilsClasses.h"
#include "BlueprintDataDefinitions.generated.h"
UENUM(BlueprintType)
enum EBPUserPrivileges
{
/** 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
@@ -23,7 +67,7 @@ enum class ESessionSettingSearchResult : uint8
// Did not find the setting
NotFound,
// Was not the correct ype
// Was not the correct type
WrongType
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -8,11 +8,14 @@ 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))
{
}
@@ -48,6 +51,18 @@ void UAdvancedFriendsGameInstance::Shutdown()
}
}
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();
}
@@ -87,6 +102,21 @@ void UAdvancedFriendsGameInstance::Init()
}
}
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();
}
@@ -128,6 +158,58 @@ void UAdvancedFriendsGameInstance::Init()
}
}*/
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;

View File

@@ -0,0 +1,198 @@
// 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::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());
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;
}

View File

@@ -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);
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}