mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-25 09:24:18 +00:00
Compare commits
17 Commits
5.7-Previe
...
4.27-Locke
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d05e0a0d79 | ||
|
|
141b15c4e4 | ||
|
|
d61c55862f | ||
|
|
3d024ae1c7 | ||
|
|
baed5da63a | ||
|
|
13c795a6e5 | ||
|
|
ef928edaef | ||
|
|
6e6b596ec4 | ||
|
|
62c655cfa7 | ||
|
|
6c5f3b8b06 | ||
|
|
1dbd091e01 | ||
|
|
d1a0b48668 | ||
|
|
3b7ec6ba65 | ||
|
|
e60ee9cf40 | ||
|
|
af1eb9342f | ||
|
|
dbc60b5046 | ||
|
|
4ad2cf5139 |
@@ -160,6 +160,10 @@ public:
|
|||||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||||
static void GetUniqueNetID(APlayerController *PlayerController, FBPUniqueNetId &UniqueNetId);
|
static void GetUniqueNetID(APlayerController *PlayerController, FBPUniqueNetId &UniqueNetId);
|
||||||
|
|
||||||
|
// Get the unique net id of a network player attached to the given controller
|
||||||
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||||
|
static void GetUniqueNetIdOfSessionOwner(FBlueprintSessionResult SessionResult, FBPUniqueNetId& UniqueNetId);
|
||||||
|
|
||||||
// Get the unique net id of a network player who is assigned the the given player state
|
// Get the unique net id of a network player who is assigned the the given player state
|
||||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||||
static void GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId);
|
static void GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId);
|
||||||
|
|||||||
@@ -27,9 +27,10 @@ class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
|||||||
* @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 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 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 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.
|
||||||
*/
|
*/
|
||||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
|
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);
|
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
|
// UOnlineBlueprintCallProxyBase interface
|
||||||
virtual void Activate() override;
|
virtual void Activate() override;
|
||||||
@@ -39,7 +40,7 @@ private:
|
|||||||
// Internal callback when session creation completes, calls StartSession
|
// Internal callback when session creation completes, calls StartSession
|
||||||
void OnCreateCompleted(FName SessionName, bool bWasSuccessful);
|
void OnCreateCompleted(FName SessionName, bool bWasSuccessful);
|
||||||
|
|
||||||
// Internal callback when session creation completes, calls StartSession
|
// Internal callback when session start completes
|
||||||
void OnStartCompleted(FName SessionName, bool bWasSuccessful);
|
void OnStartCompleted(FName SessionName, bool bWasSuccessful);
|
||||||
|
|
||||||
// The player controller triggering things
|
// The player controller triggering things
|
||||||
@@ -94,6 +95,9 @@ private:
|
|||||||
// Whether to prefer the use of voice chat lobbies if the api supports them
|
// Whether to prefer the use of voice chat lobbies if the api supports them
|
||||||
bool bUseLobbiesVoiceChatIfAvailable;
|
bool bUseLobbiesVoiceChatIfAvailable;
|
||||||
|
|
||||||
|
// Whether to start the session automatically after it is created
|
||||||
|
bool bStartAfterCreate;
|
||||||
|
|
||||||
// Store extra settings
|
// Store extra settings
|
||||||
TArray<FSessionPropertyKeyPair> ExtraSettings;
|
TArray<FSessionPropertyKeyPair> ExtraSettings;
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,11 @@ class UEndSessionCallbackProxy : public UOnlineBlueprintCallProxyBase
|
|||||||
UPROPERTY(BlueprintAssignable)
|
UPROPERTY(BlueprintAssignable)
|
||||||
FEmptyOnlineDelegate OnFailure;
|
FEmptyOnlineDelegate OnFailure;
|
||||||
|
|
||||||
// Ends the current session
|
/**
|
||||||
UFUNCTION(BlueprintCallable, meta=(DeprecatedFunction,DeprecationMessage = "This function is deprecated, I realized that people have been using it wrong and it doesn't have much use in blueprints. Use Destroy Session only instead.",BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedSessions|Deprecated")
|
* 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);
|
static UEndSessionCallbackProxy* EndSession(UObject* WorldContextObject, class APlayerController* PlayerController);
|
||||||
|
|
||||||
// UOnlineBlueprintCallProxyBase interface
|
// UOnlineBlueprintCallProxyBase interface
|
||||||
|
|||||||
@@ -7,6 +7,11 @@
|
|||||||
#include "BlueprintDataDefinitions.h"
|
#include "BlueprintDataDefinitions.h"
|
||||||
#include "FindSessionsCallbackProxyAdvanced.generated.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)
|
UCLASS(MinimalAPI)
|
||||||
class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ class ULoginUserCallbackProxy : public UOnlineBlueprintCallProxyBase
|
|||||||
FEmptyOnlineDelegate OnFailure;
|
FEmptyOnlineDelegate OnFailure;
|
||||||
|
|
||||||
// Logs into the identity interface
|
// Logs into the identity interface
|
||||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject", AdvancedDisplay = "AuthType"), Category = "Online|AdvancedIdentity")
|
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);
|
static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken, FString AuthType);
|
||||||
|
|
||||||
// UOnlineBlueprintCallProxyBase interface
|
// UOnlineBlueprintCallProxyBase interface
|
||||||
virtual void Activate() override;
|
virtual void Activate() override;
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
#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;
|
||||||
|
};
|
||||||
@@ -21,7 +21,7 @@ class UUpdateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
|||||||
|
|
||||||
// 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
|
// 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")
|
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);
|
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
|
// UOnlineBlueprintCallProxyBase interface
|
||||||
virtual void Activate() override;
|
virtual void Activate() override;
|
||||||
@@ -38,28 +38,30 @@ private:
|
|||||||
FDelegateHandle OnUpdateSessionCompleteDelegateHandle;
|
FDelegateHandle OnUpdateSessionCompleteDelegateHandle;
|
||||||
|
|
||||||
// Number of public connections
|
// Number of public connections
|
||||||
int NumPublicConnections;
|
int NumPublicConnections = 100;
|
||||||
|
|
||||||
// Number of private connections
|
// Number of private connections
|
||||||
int NumPrivateConnections;
|
int NumPrivateConnections = 0;
|
||||||
|
|
||||||
// Whether or not to search LAN
|
// Whether or not to search LAN
|
||||||
bool bUseLAN;
|
bool bUseLAN = false;
|
||||||
|
|
||||||
// Whether or not to allow invites
|
// Whether or not to allow invites
|
||||||
bool bAllowInvites;
|
bool bAllowInvites = true;
|
||||||
|
|
||||||
// Store extra settings
|
// Store extra settings
|
||||||
TArray<FSessionPropertyKeyPair> ExtraSettings;
|
TArray<FSessionPropertyKeyPair> ExtraSettings;
|
||||||
|
|
||||||
// Whether to update the online data
|
// Whether to update the online data
|
||||||
bool bRefreshOnlineData;
|
bool bRefreshOnlineData = true;
|
||||||
|
|
||||||
// Allow joining in progress
|
// Allow joining in progress
|
||||||
bool bAllowJoinInProgress;
|
bool bAllowJoinInProgress = true;
|
||||||
|
|
||||||
// Update whether this is a dedicated server or not
|
// Update whether this is a dedicated server or not
|
||||||
bool bDedicatedServer;
|
bool bDedicatedServer = false;
|
||||||
|
|
||||||
|
bool bShouldAdvertise = true;
|
||||||
|
|
||||||
// The world context object in which this call is taking place
|
// The world context object in which this call is taking place
|
||||||
UObject* WorldContextObject;
|
UObject* WorldContextObject;
|
||||||
|
|||||||
@@ -451,6 +451,17 @@ void UAdvancedSessionsLibrary::GetUniqueNetID(APlayerController *PlayerControlle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UAdvancedSessionsLibrary::GetUniqueNetIdOfSessionOwner(FBlueprintSessionResult SessionResult, FBPUniqueNetId& UniqueNetId)
|
||||||
|
{
|
||||||
|
FBPUniqueNetId ReturnID;
|
||||||
|
if (SessionResult.OnlineResult.IsValid())
|
||||||
|
{
|
||||||
|
ReturnID.SetUniqueNetId(SessionResult.OnlineResult.Session.OwningUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
UniqueNetId = ReturnID;
|
||||||
|
}
|
||||||
|
|
||||||
void UAdvancedSessionsLibrary::GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId)
|
void UAdvancedSessionsLibrary::GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId)
|
||||||
{
|
{
|
||||||
if (!PlayerState)
|
if (!PlayerState)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
#include "AutoLoginUserCallbackProxy.h"
|
#include "AutoLoginUserCallbackProxy.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// ULoginUserCallbackProxy
|
// ULoginUserCallbackProxy
|
||||||
@@ -44,6 +44,26 @@ void UAutoLoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSucce
|
|||||||
Identity->ClearOnLoginCompleteDelegate_Handle(LocalUserNum, DelegateHandle);
|
Identity->ClearOnLoginCompleteDelegate_Handle(LocalUserNum, DelegateHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(APlayerController* PController = UGameplayStatics::GetPlayerController(WorldContextObject->GetWorld(), LocalUserNum))
|
||||||
|
{
|
||||||
|
ULocalPlayer* Player = Cast<ULocalPlayer>(PController->Player);
|
||||||
|
|
||||||
|
auto uniqueId = UserId.AsShared();
|
||||||
|
|
||||||
|
if (Player)
|
||||||
|
{
|
||||||
|
Player->SetCachedUniqueNetId(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (APlayerState* State = PController->PlayerState)
|
||||||
|
{
|
||||||
|
// Update UniqueId. See also ShowLoginUICallbackProxy.cpp
|
||||||
|
State->SetUniqueId((const FUniqueNetIdPtr&)uniqueId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (bWasSuccessful)
|
if (bWasSuccessful)
|
||||||
{
|
{
|
||||||
OnSuccess.Broadcast();
|
OnSuccess.Broadcast();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ UCreateSessionCallbackProxyAdvanced::UCreateSessionCallbackProxyAdvanced(const F
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bUseLobbiesIfAvailable, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise, bool bUseLobbiesVoiceChatIfAvailable)
|
UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bUseLobbiesIfAvailable, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise, bool bUseLobbiesVoiceChatIfAvailable, bool bStartAfterCreate)
|
||||||
{
|
{
|
||||||
UCreateSessionCallbackProxyAdvanced* Proxy = NewObject<UCreateSessionCallbackProxyAdvanced>();
|
UCreateSessionCallbackProxyAdvanced* Proxy = NewObject<UCreateSessionCallbackProxyAdvanced>();
|
||||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||||
@@ -32,6 +32,7 @@ UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::Create
|
|||||||
Proxy->bUsesStats = bUsesStats;
|
Proxy->bUsesStats = bUsesStats;
|
||||||
Proxy->bShouldAdvertise = bShouldAdvertise;
|
Proxy->bShouldAdvertise = bShouldAdvertise;
|
||||||
Proxy->bUseLobbiesVoiceChatIfAvailable = bUseLobbiesVoiceChatIfAvailable;
|
Proxy->bUseLobbiesVoiceChatIfAvailable = bUseLobbiesVoiceChatIfAvailable;
|
||||||
|
Proxy->bStartAfterCreate = bStartAfterCreate;
|
||||||
return Proxy;
|
return Proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,10 +53,10 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
|
|||||||
FOnlineSessionSettings Settings;
|
FOnlineSessionSettings Settings;
|
||||||
Settings.NumPublicConnections = NumPublicConnections;
|
Settings.NumPublicConnections = NumPublicConnections;
|
||||||
Settings.NumPrivateConnections = NumPrivateConnections;
|
Settings.NumPrivateConnections = NumPrivateConnections;
|
||||||
Settings.bShouldAdvertise = true;
|
Settings.bShouldAdvertise = bShouldAdvertise;
|
||||||
Settings.bAllowJoinInProgress = true;
|
Settings.bAllowJoinInProgress = true;
|
||||||
Settings.bIsLANMatch = bUseLAN;
|
Settings.bIsLANMatch = bUseLAN;
|
||||||
Settings.bAllowJoinViaPresence = true;
|
Settings.bAllowJoinViaPresence = bAllowJoinViaPresence;
|
||||||
Settings.bIsDedicated = bDedicatedServer;
|
Settings.bIsDedicated = bDedicatedServer;
|
||||||
|
|
||||||
if (bDedicatedServer)
|
if (bDedicatedServer)
|
||||||
@@ -73,7 +74,6 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
|
|||||||
Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
|
Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
|
||||||
Settings.bAntiCheatProtected = bAntiCheatProtected;
|
Settings.bAntiCheatProtected = bAntiCheatProtected;
|
||||||
Settings.bUsesStats = bUsesStats;
|
Settings.bUsesStats = bUsesStats;
|
||||||
Settings.bShouldAdvertise = bShouldAdvertise;
|
|
||||||
|
|
||||||
// These are about the only changes over the standard Create Sessions Node
|
// These are about the only changes over the standard Create Sessions Node
|
||||||
Settings.bAllowInvites = bAllowInvites;
|
Settings.bAllowInvites = bAllowInvites;
|
||||||
@@ -133,8 +133,17 @@ void UCreateSessionCallbackProxyAdvanced::OnCreateCompleted(FName SessionName, b
|
|||||||
|
|
||||||
if (bWasSuccessful)
|
if (bWasSuccessful)
|
||||||
{
|
{
|
||||||
StartCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(StartCompleteDelegate);
|
if(this->bStartAfterCreate)
|
||||||
Sessions->StartSession(NAME_GameSession);
|
{
|
||||||
|
UE_LOG_ONLINE_SESSION(Display, TEXT("Session creation completed. Automatic start is turned on, starting session now."));
|
||||||
|
StartCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(StartCompleteDelegate);
|
||||||
|
Sessions->StartSession(NAME_GameSession); // We'll call `OnSuccess.Broadcast()` when start succeeds.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UE_LOG_ONLINE_SESSION(Display, TEXT("Session creation completed. Automatic start is turned off, to start the session call 'StartSession'."));
|
||||||
|
OnSuccess.Broadcast();
|
||||||
|
}
|
||||||
|
|
||||||
// OnStartCompleted will get called, nothing more to do now
|
// OnStartCompleted will get called, nothing more to do now
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -130,20 +130,24 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// Only steam uses the separate searching flags currently
|
// Only steam uses the separate searching flags currently
|
||||||
if (IOnlineSubsystem::DoesInstanceExist("STEAM"))
|
//if (IOnlineSubsystem::DoesInstanceExist("STEAM"))
|
||||||
{
|
//{
|
||||||
bRunSecondSearch = true;
|
bRunSecondSearch = true;
|
||||||
|
|
||||||
SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch);
|
SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch);
|
||||||
SearchObjectDedicated->MaxSearchResults = MaxResults;
|
SearchObjectDedicated->MaxSearchResults = MaxResults;
|
||||||
SearchObjectDedicated->bIsLanQuery = bUseLAN;
|
SearchObjectDedicated->bIsLanQuery = bUseLAN;
|
||||||
|
|
||||||
FOnlineSearchSettingsEx DedicatedOnly = tem;
|
FOnlineSearchSettingsEx DedicatedOnly = tem;
|
||||||
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
|
||||||
|
|
||||||
//DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||||
SearchObjectDedicated->QuerySettings = DedicatedOnly;
|
|
||||||
}
|
if (bSearchLobbies)
|
||||||
|
tem.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals);
|
||||||
|
|
||||||
|
//DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
||||||
|
SearchObjectDedicated->QuerySettings = DedicatedOnly;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -195,7 +199,7 @@ void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
|||||||
|
|
||||||
FBlueprintSessionResult BPResult;
|
FBlueprintSessionResult BPResult;
|
||||||
BPResult.OnlineResult = Result;
|
BPResult.OnlineResult = Result;
|
||||||
SessionSearchResults.Add(BPResult);
|
SessionSearchResults.AddUnique(BPResult);
|
||||||
}
|
}
|
||||||
OnSuccess.Broadcast(SessionSearchResults);
|
OnSuccess.Broadcast(SessionSearchResults);
|
||||||
return;
|
return;
|
||||||
@@ -214,7 +218,7 @@ void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
|||||||
|
|
||||||
FBlueprintSessionResult BPResult;
|
FBlueprintSessionResult BPResult;
|
||||||
BPResult.OnlineResult = Result;
|
BPResult.OnlineResult = Result;
|
||||||
SessionSearchResults.Add(BPResult);
|
SessionSearchResults.AddUnique(BPResult);
|
||||||
}
|
}
|
||||||
if (!bRunSecondSearch)
|
if (!bRunSecondSearch)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ void ULoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSuccessfu
|
|||||||
if (PlayerControllerWeakPtr.IsValid())
|
if (PlayerControllerWeakPtr.IsValid())
|
||||||
{
|
{
|
||||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
||||||
|
|
||||||
auto uniqueId = UserId.AsShared();
|
auto uniqueId = UserId.AsShared();
|
||||||
|
|
||||||
if (Player)
|
if (Player)
|
||||||
@@ -77,12 +78,10 @@ void ULoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSuccessfu
|
|||||||
Player->SetCachedUniqueNetId(uniqueId);
|
Player->SetCachedUniqueNetId(uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
APlayerState* State = PlayerControllerWeakPtr->PlayerState;
|
if (APlayerState* State = PlayerControllerWeakPtr->PlayerState)
|
||||||
|
|
||||||
if (State)
|
|
||||||
{
|
{
|
||||||
// Update UniqueId. See also ShowLoginUICallbackProxy.cpp
|
// Update UniqueId. See also ShowLoginUICallbackProxy.cpp
|
||||||
State->SetUniqueId((const FUniqueNetIdPtr&) uniqueId);
|
State->SetUniqueId((const FUniqueNetIdPtr&)uniqueId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
#include "StartSessionCallbackProxyAdvanced.h"
|
||||||
|
|
||||||
|
UStartSessionCallbackProxyAdvanced::UStartSessionCallbackProxyAdvanced(const FObjectInitializer& ObjectInitializer)
|
||||||
|
: Super(ObjectInitializer)
|
||||||
|
, StartCompleteDelegate(FOnStartSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnStartCompleted))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
UStartSessionCallbackProxyAdvanced* UStartSessionCallbackProxyAdvanced::StartAdvancedSession(
|
||||||
|
const UObject* WorldContextObject)
|
||||||
|
{
|
||||||
|
UStartSessionCallbackProxyAdvanced* Proxy = NewObject<UStartSessionCallbackProxyAdvanced>();
|
||||||
|
Proxy->WorldContextObject = WorldContextObject;
|
||||||
|
return Proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UStartSessionCallbackProxyAdvanced::Activate()
|
||||||
|
{
|
||||||
|
const FOnlineSubsystemBPCallHelperAdvanced Helper(
|
||||||
|
TEXT("StartSession"),
|
||||||
|
GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
|
||||||
|
|
||||||
|
if (Helper.OnlineSub != nullptr)
|
||||||
|
{
|
||||||
|
const auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||||
|
if (Sessions.IsValid())
|
||||||
|
{
|
||||||
|
StartCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(StartCompleteDelegate);
|
||||||
|
Sessions->StartSession(NAME_GameSession);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fail immediately
|
||||||
|
OnFailure.Broadcast();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UStartSessionCallbackProxyAdvanced::OnStartCompleted(FName SessionName, bool bWasSuccessful)
|
||||||
|
{
|
||||||
|
const FOnlineSubsystemBPCallHelperAdvanced Helper(
|
||||||
|
TEXT("StartSessionCallback"),
|
||||||
|
GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
|
||||||
|
|
||||||
|
if (Helper.OnlineSub != nullptr)
|
||||||
|
{
|
||||||
|
const auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||||
|
if (Sessions.IsValid())
|
||||||
|
{
|
||||||
|
Sessions->ClearOnStartSessionCompleteDelegate_Handle(StartCompleteDelegateHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bWasSuccessful)
|
||||||
|
{
|
||||||
|
OnSuccess.Broadcast();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnFailure.Broadcast();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ UUpdateSessionCallbackProxyAdvanced::UUpdateSessionCallbackProxyAdvanced(const F
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer)
|
UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer, bool bShouldAdvertise)
|
||||||
{
|
{
|
||||||
UUpdateSessionCallbackProxyAdvanced* Proxy = NewObject<UUpdateSessionCallbackProxyAdvanced>();
|
UUpdateSessionCallbackProxyAdvanced* Proxy = NewObject<UUpdateSessionCallbackProxyAdvanced>();
|
||||||
Proxy->NumPublicConnections = PublicConnections;
|
Proxy->NumPublicConnections = PublicConnections;
|
||||||
@@ -24,6 +24,7 @@ UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::Update
|
|||||||
Proxy->bRefreshOnlineData = bRefreshOnlineData;
|
Proxy->bRefreshOnlineData = bRefreshOnlineData;
|
||||||
Proxy->bAllowJoinInProgress = bAllowJoinInProgress;
|
Proxy->bAllowJoinInProgress = bAllowJoinInProgress;
|
||||||
Proxy->bDedicatedServer = bIsDedicatedServer;
|
Proxy->bDedicatedServer = bIsDedicatedServer;
|
||||||
|
Proxy->bShouldAdvertise = bShouldAdvertise;
|
||||||
return Proxy;
|
return Proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@ void UUpdateSessionCallbackProxyAdvanced::Activate()
|
|||||||
//Settings->BuildUniqueId = GetBuildUniqueId();
|
//Settings->BuildUniqueId = GetBuildUniqueId();
|
||||||
Settings->NumPublicConnections = NumPublicConnections;
|
Settings->NumPublicConnections = NumPublicConnections;
|
||||||
Settings->NumPrivateConnections = NumPrivateConnections;
|
Settings->NumPrivateConnections = NumPrivateConnections;
|
||||||
//Settings->bShouldAdvertise = true;
|
Settings->bShouldAdvertise = bShouldAdvertise;
|
||||||
Settings->bAllowJoinInProgress = bAllowJoinInProgress;
|
Settings->bAllowJoinInProgress = bAllowJoinInProgress;
|
||||||
Settings->bIsLANMatch = bUseLAN;
|
Settings->bIsLANMatch = bUseLAN;
|
||||||
//Settings->bUsesPresence = true;
|
//Settings->bUsesPresence = true;
|
||||||
|
|||||||
@@ -33,6 +33,10 @@
|
|||||||
{
|
{
|
||||||
"Name": "OnlineSubsystemSteam",
|
"Name": "OnlineSubsystemSteam",
|
||||||
"Enabled": true
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "SteamShared",
|
||||||
|
"Enabled": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user