mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-22 16:04:18 +00:00
Added another session id utility function
Former-commit-id: 4e97162f7c10db3bd97b3756fa2de911e360b662
This commit is contained in:
@@ -64,6 +64,10 @@ public:
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void GetSessionID_AsString(const FBlueprintSessionResult & SessionResult, FString& SessionID);
|
||||
|
||||
// Get a string copy of the current session ID
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void GetCurrentSessionID_AsString(FString& SessionID);
|
||||
|
||||
// Get the Unique Current Build ID
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void GetCurrentUniqueBuildID(int32 &UniqueBuildId);
|
||||
|
@@ -25,6 +25,32 @@ void UAdvancedSessionsLibrary::GetSessionID_AsString(const FBlueprintSessionResu
|
||||
SessionID.Empty();
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetCurrentSessionID_AsString(FString& SessionID)
|
||||
{
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetCurrentSessionID_AsString couldn't get the session interface!"));
|
||||
SessionID.Empty();
|
||||
return;
|
||||
}
|
||||
|
||||
const FNamedOnlineSession* Session = SessionInterface->GetNamedSession(NAME_GameSession);
|
||||
if (Session != nullptr)
|
||||
{
|
||||
const TSharedPtr<class FOnlineSessionInfo> SessionInfo = Session->SessionInfo;
|
||||
if (SessionInfo.IsValid() && SessionInfo->IsValid() && SessionInfo->GetSessionId().IsValid())
|
||||
{
|
||||
SessionID = SessionInfo->GetSessionId().ToString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Zero the string out if we didn't have a valid one, in case this is called in c++
|
||||
SessionID.Empty();
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetCurrentUniqueBuildID(int32 &UniqueBuildId)
|
||||
{
|
||||
UniqueBuildId = GetBuildUniqueId();
|
||||
|
Reference in New Issue
Block a user