Does ClientTravel() have a failed callback function?

I just started to learn to use network programming in a third person template game. One executes the following code after pressing a keyboard key:

void UMyGameInstance::OpenLobby()
{
	UWorld* world = GetWorld();
	if (world)
	{
		if (world->ServerTravel(FString("/Game/Maps/Lobby?listen")))
		{
			Log("OpenLobby sucess");
		}
		else
		{
			Log("OpenLobby failed");
		}		
	}
	else
	{
		Log("GetWorld failed");
	}
}

This will create a “Lobby” level and listen.
The other executes the following code after pressing a keyboard key:

void UMyGameInstance::CallClientTravel(const FString& address)
{
	APlayerController* playerController = GetFirstLocalPlayerController();
	if (playerController)
	{
		playerController->ClientTravel(address, ETravelType::TRAVEL_Absolute);
	}
	else
	{
		Log("CallClientTravel failed");
	}
}

So it should be able to jump to that “Lobby” level.
Use the independent process game to execute successively. However, sometimes you can jump to the “Lobby” level, but more often you just reload the current level. I am puzzled why it is not always successful or failed.

In addition, does ClientTravel() have an error callback function? I found that even if I intentionally input the first parameter to an IP address that does not exist, it will only reload the current level without returning any error.

1 Like

I was wondering the same thing. After digging in the engine, I found these callback that work:

GetEngine()->OnTravelFailure().AddUObject(this, &UMyGameInstance::OnTravelFailure);
GetEngine()->OnNetworkFailure().AddUObject(this, &UMyGameInstance::OnNetworkFailure);

They are more generic, but it’s the only way I found to get error feedbacks from it. Also, it loads the default map after. I have yet to find a way to override that behavior and not load default map on Fail. I just want to stay in the Menu I am currently on and show my own error dialog.

Thank you, I hope there will be more intuitive APIs in the future.