mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-24 00:44:23 +00:00
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
74 lines
2.5 KiB
C++
74 lines
2.5 KiB
C++
// 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();
|
|
}
|
|
}
|