Handling Network Error

Hello, I am starting to study c++ multiplayer part and my question is:
How to handle network errors in c++ using the gameinstance?
I know that on blueprints we have the event handleNetworkError.

Thanks.

Something like this worked for me:

Make a function like this in your GameInstance class:

void HandleNetworkFailure(UWorld * World, UNetDriver * NetDriver, ENetworkFailure::Type FailureType, const FString & ErrorString);

Then you need to bind that function to the UEngine’s OnNetworkFailure delegate:

GetEngine()->OnNetworkFailure().AddUObject(this, &UCTBallGameInstance::HandleNetworkFailure);

It gave me errors if i tried to bind it in the constructor so do it somewhere after that.

1 Like