mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
fix: NetworkClient.Shutdown now clears OnDis/ConnectedEvents
This commit is contained in:
parent
68a4a06926
commit
e827c6c0f3
@ -1354,6 +1354,11 @@ public static void Shutdown()
|
||||
if (Transport.activeTransport != null)
|
||||
Transport.activeTransport.ClientDisconnect();
|
||||
connection = null;
|
||||
|
||||
// clear events. someone might have hooked into them before, but
|
||||
// we don't want to use those hooks after Shutdown anymore.
|
||||
OnConnectedEvent = null;
|
||||
OnDisconnectedEvent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,5 +96,19 @@ public void Send()
|
||||
// received it on server?
|
||||
Assert.That(called, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShutdownCleanup()
|
||||
{
|
||||
// add some test event hooks to make sure they are cleaned up.
|
||||
// there used to be a bug where they wouldn't be cleaned up.
|
||||
NetworkClient.OnConnectedEvent = () => {};
|
||||
NetworkClient.OnDisconnectedEvent = () => {};
|
||||
|
||||
NetworkClient.Shutdown();
|
||||
|
||||
Assert.That(NetworkClient.OnConnectedEvent, Is.Null);
|
||||
Assert.That(NetworkClient.OnDisconnectedEvent, Is.Null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user