mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-23 08:24:18 +00:00
Added GetPlayerAuthToken function to advanced identity
Now forcing not passing in a player controller if hosting dedicated. Former-commit-id: 7a6578b7ce8d98c87e33ef4623fddc2e39be31ce
This commit is contained in:
@@ -29,6 +29,10 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void GetLoginStatus(const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Get the auth token for a local player
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void GetPlayerAuthToken(APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Get a players nickname
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity")
|
||||
static void GetPlayerNickname(const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname);
|
||||
|
@@ -5,6 +5,38 @@
|
||||
//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())
|
||||
@@ -20,7 +52,6 @@ void UAdvancedIdentityLibrary::GetPlayerNickname(const FBPUniqueNetId & UniqueNe
|
||||
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname Failed to get identity interface!"));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerNickname = IdentityInterface->GetPlayerNickname(*UniqueNetID.GetUniqueNetId());
|
||||
}
|
||||
|
||||
|
@@ -79,7 +79,7 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
|
||||
}
|
||||
|
||||
|
||||
if (PlayerControllerWeakPtr.IsValid() && Helper.UserID.IsValid())
|
||||
if (!bDedicatedServer && PlayerControllerWeakPtr.IsValid() && Helper.UserID.IsValid())
|
||||
Sessions->CreateSession(*Helper.UserID, GameSessionName, Settings);
|
||||
else
|
||||
Sessions->CreateSession(0, GameSessionName, Settings);
|
||||
|
Reference in New Issue
Block a user