本文整理汇总了C++中IOnlineSessionPtr::GetResolvedConnectString方法的典型用法代码示例。如果您正苦于以下问题:C++ IOnlineSessionPtr::GetResolvedConnectString方法的具体用法?C++ IOnlineSessionPtr::GetResolvedConnectString怎么用?C++ IOnlineSessionPtr::GetResolvedConnectString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOnlineSessionPtr
的用法示例。
在下文中一共展示了IOnlineSessionPtr::GetResolvedConnectString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnJoinSessionComplete
void URadeGameInstance::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type Result)
{
// Get the OnlineSubsystem we want to work with
IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
if (OnlineSub)
{
// Get SessionInterface from the OnlineSubsystem
IOnlineSessionPtr Sessions = OnlineSub->GetSessionInterface();
if (Sessions.IsValid())
{
// Clear the Delegate again
Sessions->ClearOnJoinSessionCompleteDelegate_Handle(OnJoinSessionCompleteDelegateHandle);
// Get the first local PlayerController, so we can call "ClientTravel" to get to the Server Map
// This is something the Blueprint Node "Join Session" does automatically!
APlayerController * const PlayerController = GetFirstLocalPlayerController();
// We need a FString to use ClientTravel and we can let the SessionInterface contruct such a
// String for us by giving him the SessionName and an empty String. We want to do this, because
// Every OnlineSubsystem uses different TravelURLs
FString TravelURL;
if (PlayerController && Sessions->GetResolvedConnectString(SessionName, TravelURL))
{
// Finally call the ClienTravel. If you want, you could print the TravelURL to see
// how it really looks like
PlayerController->ClientTravel(TravelURL, ETravelType::TRAVEL_Absolute);
}
}
}
}
示例2: RequestReservation
bool APartyBeaconClient::RequestReservation(const FOnlineSessionSearchResult& DesiredHost, const FUniqueNetIdRepl& RequestingPartyLeader, const TArray<FPlayerReservation>& PartyMembers)
{
bool bSuccess = false;
if (DesiredHost.IsValid())
{
UWorld* World = GetWorld();
IOnlineSubsystem* OnlineSub = Online::GetSubsystem(World);
if (OnlineSub)
{
IOnlineSessionPtr SessionInt = OnlineSub->GetSessionInterface();
if (SessionInt.IsValid())
{
FString ConnectInfo;
if (SessionInt->GetResolvedConnectString(DesiredHost, BeaconPort, ConnectInfo))
{
FString SessionId = DesiredHost.Session.SessionInfo->GetSessionId().ToString();
return RequestReservation(ConnectInfo, SessionId, RequestingPartyLeader, PartyMembers);
}
}
}
}
if (!bSuccess)
{
OnFailure();
}
return bSuccess;
}
示例3: OnJoinSessionComplete
void UtrnetDemoGameInstance::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type Result)
{
isLoading_ = false;
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, FString::Printf(TEXT("OnJoinSessionComplete %s, %d"), *SessionName.ToString(), static_cast<int32>(Result)));
// Get SessionInterface from the OnlineSubsystem
IOnlineSessionPtr Sessions = GetSession();
if (!Sessions.IsValid())
{
return;
}
// Clear the Delegate again
Sessions->ClearOnJoinSessionCompleteDelegate_Handle(OnJoinSessionCompleteDelegateHandle);
// Get the first local PlayerController, so we can call "ClientTravel" to get to the Server Map
// This is something the Blueprint Node "Join Session" does automatically!
APlayerController * const PlayerController = GetFirstLocalPlayerController();
// We need a FString to use ClientTravel and we can let the SessionInterface contruct such a
// String for us by giving him the SessionName and an empty String. We want to do this, because
// Every OnlineSubsystem uses different TravelURLs
FString TravelURL;
if (PlayerController && Sessions->GetResolvedConnectString(SessionName, TravelURL))
{
// Finally call the ClienTravel. If you want, you could print the TravelURL to see
// how it really looks like
PlayerController->ClientTravel(TravelURL, ETravelType::TRAVEL_Absolute);
}
}
示例4: OnJoinSessionComplete
void UOnlineSessionClient::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type Result)
{
UE_LOG(LogOnline, Verbose, TEXT("OnJoinSessionComplete %s bSuccess: %d"), *SessionName.ToString(), static_cast<int32>(Result));
IOnlineSessionPtr SessionInt = GetSessionInt();
if (SessionInt.IsValid())
{
SessionInt->ClearOnJoinSessionCompleteDelegate_Handle(OnJoinSessionCompleteDelegateHandle);
if (Result == EOnJoinSessionCompleteResult::Success)
{
FString URL;
if (SessionInt->GetResolvedConnectString(SessionName, URL))
{
APlayerController* PC = GetGameInstance()->GetFirstLocalPlayerController(GetWorld());
if (PC)
{
if (bIsFromInvite)
{
URL += TEXT("?bIsFromInvite");
bIsFromInvite = false;
}
PC->ClientTravel(URL, TRAVEL_Absolute);
}
}
else
{
UE_LOG(LogOnline, Warning, TEXT("Failed to join session %s"), *SessionName.ToString());
}
}
}
}