Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cyberarch/aip-197-sp-23-digital-classroom
  • cyberarch/cyberarchplugins
2 results
Show changes
Showing
with 1822 additions and 0 deletions
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Engine/Engine.h"
#include "Interfaces/OnlineSessionInterface.h"
#include "BlueprintDataDefinitions.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;
};
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Engine/Engine.h"
#include "BlueprintDataDefinitions.h"
#include "CreateSessionCallbackProxyAdvanced.generated.h"
UCLASS(MinimalAPI)
class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
{
GENERATED_UCLASS_BODY()
// Called when the session was created successfully
UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnSuccess;
// Called when there was an error creating the session
UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnFailure;
/**
* Creates a session with the default online subsystem with advanced optional inputs, for dedicated servers leave UsePresence as false and set IsDedicatedServer to true. Dedicated servers don't use presence.
* @param PublicConnections When doing a 'listen' server, this must be >=2 (ListenServer itself counts as a connection)
* @param bUseLAN When you want to play LAN, the level to play on must be loaded with option 'bIsLanMatch'
* @param bUsePresence Must be true for a 'listen' server (Map must be loaded with option 'listen'), false for a 'dedicated' server.
* @param bUseLobbiesIfAvailable Used to flag the subsystem to use a lobby api instead of general hosting if the API supports it, generally true on steam for listen servers and false for dedicated
* @param bShouldAdvertise Set to true when the OnlineSubsystem should list your server when someone is searching for servers. Otherwise the server is hidden and only join via invite is possible.
* @param bUseLobbiesVoiceChatIfAvailable Set to true to setup voice chat lobbies if the API supports it
* @param bStartAfterCreate Set to true to start the session after it's created. If false you need to manually call StartSession when ready.
*/
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair>& ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bUseLobbiesIfAvailable = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true, bool bUseLobbiesVoiceChatIfAvailable = false, bool bStartAfterCreate = true);
// UOnlineBlueprintCallProxyBase interface
virtual void Activate() override;
// End of UOnlineBlueprintCallProxyBase interface
private:
// Internal callback when session creation completes, optionally calls StartSession
void OnCreateCompleted(FName SessionName, bool bWasSuccessful);
// Internal callback when session start completes
void OnStartCompleted(FName SessionName, bool bWasSuccessful);
// The player controller triggering things
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
// The delegate executed by the online subsystem
FOnCreateSessionCompleteDelegate CreateCompleteDelegate;
// The delegate executed by the online subsystem
FOnStartSessionCompleteDelegate StartCompleteDelegate;
// Handles to the registered delegates above
FDelegateHandle CreateCompleteDelegateHandle;
FDelegateHandle StartCompleteDelegateHandle;
// Number of public connections
int NumPublicConnections;
// Number of private connections
int NumPrivateConnections;
// Whether or not to search LAN
bool bUseLAN;
// Whether or not to allow invites
bool bAllowInvites;
// Whether this is a dedicated server or not
bool bDedicatedServer;
// Whether to use the presence option
bool bUsePresence;
// Whether to prefer the use of lobbies for hosting if the api supports them
bool bUseLobbiesIfAvailable;
// Whether to allow joining via presence
bool bAllowJoinViaPresence;
// Allow joining via presence for friends only
bool bAllowJoinViaPresenceFriendsOnly;
// Delcare the server to be anti cheat protected
bool bAntiCheatProtected;
// Record Stats
bool bUsesStats;
// Should advertise server?
bool bShouldAdvertise;
// Whether to prefer the use of voice chat lobbies if the api supports them
bool bUseLobbiesVoiceChatIfAvailable;
// Whether to start the session automatically after it is created
bool bStartAfterCreate;
// Store extra settings
TArray<FSessionPropertyKeyPair> ExtraSettings;
// The world context object in which this call is taking place
UObject* WorldContextObject;
};
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Engine/Engine.h"
#include "Interfaces/OnlineSessionInterface.h"
#include "BlueprintDataDefinitions.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 sessions, Generally for almost all uses you should be using the engines native Destroy Session node instead.
* This exists for people using StartSession and optionally hand managing the session state.
*/
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedSessions")
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;
};
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h"
#include "Engine/LocalPlayer.h"
#include "FindFriendSessionCallbackProxy.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFindFriendSessionLog, Log, All);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintFindFriendSessionDelegate, const TArray<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 TArray<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;
};
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Engine/Engine.h"
#include "Interfaces/OnlineSessionInterface.h"
#include "FindSessionsCallbackProxy.h"
#include "BlueprintDataDefinitions.h"
#include "FindSessionsCallbackProxyAdvanced.generated.h"
FORCEINLINE bool operator==(const FBlueprintSessionResult& A, const FBlueprintSessionResult& B)
{
return (A.OnlineResult.IsValid() == B.OnlineResult.IsValid() && (A.OnlineResult.GetSessionIdStr() == B.OnlineResult.GetSessionIdStr()));
}
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, bool bSearchLobbies = true, 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;
// Search through lobbies
bool bSearchLobbies;
// Min slots requires to search
int MinSlotsAvailable;
// The world context object in which this call is taking place
UObject* WorldContextObject;
};
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h"
#include "Engine/LocalPlayer.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;
};
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "BlueprintDataDefinitions.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;
};
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h"
#include "Interfaces/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;
// Gets the privilage of the user
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;
};
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h"
#include "Interfaces/OnlineIdentityInterface.h"
#include "Engine/LocalPlayer.h"
#include "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 into the identity interface
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject", AdvancedDisplay = "AuthType"), Category = "Online|AdvancedIdentity")
static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken, FString AuthType);
// 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;
FString AuthType;
// 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;
};
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h"
#include "Interfaces/OnlineIdentityInterface.h"
#include "Engine/LocalPlayer.h"
#include "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;
};
#pragma once
//#include "EngineMinimal.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
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h"
#include "Engine/LocalPlayer.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;
};
#pragma once
#include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h"
#include "StartSessionCallbackProxyAdvanced.generated.h"
UCLASS(MinimalAPI)
class UStartSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
{
GENERATED_UCLASS_BODY()
// Called when the session starts successfully
UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnSuccess;
// Called when there is an error starting the session
UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnFailure;
/**
* Starts a session with the default online subsystem. The session needs to be previously created by calling the "CreateAdvancedSession" node.
* @param WorldContextObject
*/
UFUNCTION(
BlueprintCallable
, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject")
, Category = "Online|AdvancedSessions"
)
static UStartSessionCallbackProxyAdvanced* StartAdvancedSession(const UObject* WorldContextObject);
// UOnlineBlueprintCallProxyBase interface
virtual void Activate() override;
// End of UOnlineBlueprintCallProxyBase interface
private:
// Internal callback when session start completes
void OnStartCompleted(FName SessionName, bool bWasSuccessful);
// The delegate executed by the online subsystem
FOnStartSessionCompleteDelegate StartCompleteDelegate;
// Handles to the registered delegates above
FDelegateHandle StartCompleteDelegateHandle;
// The world context object in which this call is taking place
const UObject* WorldContextObject;
};
\ No newline at end of file
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Engine/Engine.h"
#include "BlueprintDataDefinitions.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, bool bShouldAdvertise = true);
// 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 = 100;
// Number of private connections
int NumPrivateConnections = 0;
// Whether or not to search LAN
bool bUseLAN = false;
// Whether or not to allow invites
bool bAllowInvites = true;
// Store extra settings
TArray<FSessionPropertyKeyPair> ExtraSettings;
// Whether to update the online data
bool bRefreshOnlineData = true;
// Allow joining in progress
bool bAllowJoinInProgress = true;
// Update whether this is a dedicated server or not
bool bDedicatedServer = false;
bool bShouldAdvertise = true;
// The world context object in which this call is taking place
UObject* WorldContextObject;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedExternalUILibrary.h"
#include "Engine/LocalPlayer.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(), NAME_GameSession);
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;
}
\ No newline at end of file
// Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedFriendsGameInstance.h"
#include "Kismet/GameplayStatics.h"
#include "GameFramework/PlayerController.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(GetWorld());
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(GetWorld());
if (VoiceInterface.IsValid())
{
VoiceInterface->ClearOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegateHandle);
}
else
{
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!"));
}
}
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(GetWorld());
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(GetWorld());//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(GetWorld());
if (VoiceInterface.IsValid())
{
PlayerTalkingStateChangedDelegateHandle = VoiceInterface->AddOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegate);
}
else
{
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!"));
}
}
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(GetWorld());
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->GetUniqueId().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> PersonInvited, const FOnlineSessionSearchResult& SessionToJoin)
{
if (bWasSuccessful)
{
if (SessionToJoin.IsValid())
{
FBlueprintSessionResult BluePrintResult;
BluePrintResult.OnlineResult = SessionToJoin;
FBPUniqueNetId PInvited;
PInvited.SetUniqueNetId(PersonInvited);
OnSessionInviteAccepted(LocalPlayer,PInvited, 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,PInvited, 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!"));
}
}
}
\ No newline at end of file
// Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedFriendsInterface.h"
UAdvancedFriendsInterface::UAdvancedFriendsInterface(const class FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
// Fill out your copyright notice in the Description page of Project Settings.
#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(), NAME_GameSession, 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(), NAME_GameSession, *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);
}
}
\ No newline at end of file
// Fill out your copyright notice in the Description page of Project Settings.
#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(!UniqueNetId.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount was passed a bad unique net id!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
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;
}
\ No newline at end of file
//#include "StandAlonePrivatePCH.h"
#include "AdvancedSessions.h"
void AdvancedSessions::StartupModule()
{
}
void AdvancedSessions::ShutdownModule()
{
}
IMPLEMENT_MODULE(AdvancedSessions, AdvancedSessions)
\ No newline at end of file