mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-24 17:04:18 +00:00
Added identity interface, recompiled all binaries for 4.13.1
Former-commit-id: 8c89eb776e877ee486ca908db651667c7f87e469
This commit is contained in:
80
Source/AdvancedSessions/Private/LogoutUserCallbackProxy.cpp
Normal file
80
Source/AdvancedSessions/Private/LogoutUserCallbackProxy.cpp
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user