I actually use Unet for Unity and when a client try to join using a bad IP, I have a timeOut Error.
I would like to avoid this timeOut error. So, I tried to override the "OnDisconnectClient" of NetworkManager.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class CustomNetworkManager : NetworkManager {
public override void OnClientDisconnect(NetworkConnection conn)
{
Debug.Log("TimeOutError");
}
}
It works, but this function is also called when the client quit the server on purpose. So I tried this :
public class CustomNetworkManager : NetworkManager {
public override void OnClientDisconnect(NetworkConnection conn)
{
try
{
base.OnClientDisconnect(conn);
}
catch(Exception e)
{
Debug.Log(e.ToString());
}
}
}
But the error isn't catch and still pop in the console. I also tried catch without the Exception parameter but still the same.
Thanks per advance for the help.
PS: I work on Unity 2018.2.15f1
I would use a try-catch statement, to catch the exception. then in the catch do what ever error handling you want to do.