im trying to connect to a listen server as a client like this:
void UFurAndFangGameInstance::JoinServer(int32 ServerNumber)
{
IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
IOnlineIdentityPtr IdentityInterface = OnlineSub->GetIdentityInterface();
TSharedPtr<const FUniqueNetId> UserId;
if (IdentityInterface.IsValid())
{
UserId = IdentityInterface->GetUniquePlayerId(0);
}
SessionInterface->JoinSession(*UserId, SESSION_NAME, SessionSearch->SearchResults[ServerNumber]);
FString Messaage = FString::Printf(TEXT("Joining Session %s"), *SessionSearch->SearchResults[ServerNumber].GetSessionIdStr());
GetEngine()->AddOnScreenDebugMessage(0, 2, FColor::Green, Messaage);
}
delegate:
void UFurAndFangGameInstance::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type Result)
{
if (Result == EOnJoinSessionCompleteResult::Success)
{
GetEngine()->AddOnScreenDebugMessage(6845, 10, FColor::Red, TEXT("Successfuly Joined Session"));
FString Address;
if (!SessionInterface->GetResolvedConnectString(SessionName, Address)) {
GetEngine()->AddOnScreenDebugMessage(63451, 5, FColor::Green, TEXT("Could not get connect string."));
return;
}
APlayerController* PlayerController = GetFirstLocalPlayerController();
//if (!ensure(PlayerController != nullptr)) return;
GetEngine()->AddOnScreenDebugMessage(63451, 5, FColor::Green, FString::Printf(TEXT("Loading Map for %s"), *Address));
PlayerController->ClientTravel(Address, ETravelType::TRAVEL_Absolute);
}
else
{
GetEngine()->AddOnScreenDebugMessage(6845, 10, FColor::Red, TEXT("Failed to Join session "));
}
}
I do get the "Successfuly Joined Session" debug messages etc, But the client wont load into the same map as the server and will stay in the main menu,ive made sure this line:
PlayerController->ClientTravel(Address, ETravelType::TRAVEL_Absolute);
is executed
does anyone know possible reasons as to why this isnt working properly ?