mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkClient.OnTransportDisconnected: local connection cleanup code moved into LocalConnection Disconnect
This commit is contained in:
parent
73df46e2b0
commit
3afad21de9
@ -118,6 +118,19 @@ public override void Disconnect()
|
||||
{
|
||||
connectionToClient.DisconnectInternal();
|
||||
DisconnectInternal();
|
||||
|
||||
// THIS WAS PREVIOUSLY IN NETWORKCLIENT.DISCONNECT:
|
||||
|
||||
// call client OnDisconnected with connection to server
|
||||
// => previously we used to send a DisconnectMessage to
|
||||
// NetworkServer.localConnection. this would queue the
|
||||
// message until NetworkClient.Update processes it.
|
||||
// => invoking the client's OnDisconnected event directly
|
||||
// here makes tests fail. so let's do it exactly the same
|
||||
// order as before by queueing the event for next Update!
|
||||
//OnDisconnectedEvent?.Invoke(connection);
|
||||
QueueDisconnectedEvent();
|
||||
NetworkServer.RemoveLocalConnection();
|
||||
}
|
||||
|
||||
// true because local connections never timeout
|
||||
|
@ -266,28 +266,6 @@ static void OnTransportDisconnected()
|
||||
connectState = ConnectState.Disconnected;
|
||||
ready = false;
|
||||
|
||||
// this was in Disconnect() before.
|
||||
// but it should happen after truly disconnecting here.
|
||||
|
||||
// local connection
|
||||
if (isLocalClient)
|
||||
{
|
||||
// TODO move into LocalConnection.Disconnect
|
||||
if (isConnected)
|
||||
{
|
||||
// call client OnDisconnected with connection to server
|
||||
// => previously we used to send a DisconnectMessage to
|
||||
// NetworkServer.localConnection. this would queue the
|
||||
// message until NetworkClient.Update processes it.
|
||||
// => invoking the client's OnDisconnected event directly
|
||||
// here makes tests fail. so let's do it exactly the same
|
||||
// order as before by queueing the event for next Update!
|
||||
//OnDisconnectedEvent?.Invoke(connection);
|
||||
((LocalConnectionToServer)connection).QueueDisconnectedEvent();
|
||||
}
|
||||
NetworkServer.RemoveLocalConnection();
|
||||
}
|
||||
|
||||
// call OnDisconnected event. NetworkManager hooks into it.
|
||||
OnDisconnectedEvent?.Invoke();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user