fix: #3365 NetworkClient.OnTransportDisconnected now always invokes OnDisconnected, even during connecting phase

This commit is contained in:
vis2k 2023-01-28 23:41:14 +09:00
parent e21d42a324
commit 7d2d21ac2c

View File

@ -383,7 +383,13 @@ internal static void OnTransportDisconnected()
// Raise the event before changing ConnectState // Raise the event before changing ConnectState
// because 'active' depends on this during shutdown // because 'active' depends on this during shutdown
if (connection != null) OnDisconnectedEvent?.Invoke(); //
// previously OnDisconnected was only invoked if connection != null.
// however, if DNS resolve fails in Transport.Connect(),
// OnDisconnected would never be called because 'connection' is only
// create after the Transport.Connect() call.
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3365
OnDisconnectedEvent?.Invoke();
connectState = ConnectState.Disconnected; connectState = ConnectState.Disconnected;
ready = false; ready = false;