Current Output : 3 clients (A,B,C) → A hosts a private session → B tries to join → B rejected because wrong password → B goes back to default map (pop up notification does not show up, i suspect its because after showing popup engine calls client travel). → C gets notification popup
Expected Output : 3 clients (A,B,C) → A hosts a private session → B tries to join → B rejected because wrong password → B goes back to default map → popup appear informing the player
I have a function bounded to OnNetworkFailure Event of Gengine class in my playercontroller , Basically what i’m trying to do is validate password server side, so checking password In Gamemode on PreLogin , at this time playercontroller doesnt exist so i assign message to ErrorMessage outparameter.
Here’s the code
GameMode CPP
void ALobbyGameode::PreLogin(const FString &Options, const FString &Address, const FUniqueNetIdRepl &UniqueId, FString &ErrorMessage)
{
Super::PreLogin(Options, Address, UniqueId, ErrorMessage);
FString Password = UGameplayStatics::ParseOption(Options, TEXT("Password"));
if(!SessionPassword.IsEmpty() && SessionPassword != Password)
{
ErrorMessage = "Invalid password";
return;
}
}
PlayerController CPP
void ABasePlayerController::BeginPlay()
{
Super::BeginPlay();
if (!GEngine) return;
GEngine->OnNetworkFailure().AddUObject(this, &ABasePlayerController::OnNetworkConnectionFailed);
}
void ABasePlayerController::OnNetworkConnectionFailed(UWorld *InWorld, UNetDriver *NetDriver, ENetworkFailure::Type FailureType, const FString &ErrorString)
{
UE_LOG(LogTemp, Warning, TEXT("NetWork connection failed called on playercontroller "));
if(!IsLocalPlayerController()) return;
PushNotification(ErrorString);
}
Output:
LogTemp: Warning: NetWork connection failed called on playercontroller
LogTemp: Warning: NetWork connection failed called on playercontroller
LogTemp: Warning: NetWork connection failed called on playercontroller
LogTemp: Warning: NetWork connection failed called on playercontroller
As you can see its called multiple times , i dont know why.
and how do i know which client got Rejected? , because right now all clients are getting notification popup
do suggest if there is any better approach to this