Added another session id utility function

Former-commit-id: 4e97162f7c10db3bd97b3756fa2de911e360b662
This commit is contained in:
mordentral
2019-04-18 13:35:15 -04:00
parent 0952d9b18a
commit 6007506189
2 changed files with 30 additions and 0 deletions

View File

@@ -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);

View File

@@ -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();