Now we can stop even while connecting.

In some transports (Ignorance),  when the player clicks "Connect",   the transport goes in Connecting state. If the player clicks Disconnect
the transport remains in Connecting state.

This gives the transport a chance to cancel the Connecting process.  This fix has been tested for quite some time in 2018 branch
This commit is contained in:
Paul Pacheco 2019-01-29 19:05:38 -06:00
parent 6c163d1a45
commit 1b915fbffb

View File

@ -73,13 +73,12 @@ public void Disconnect()
isReady = false; isReady = false;
ClientScene.HandleClientDisconnect(this); ClientScene.HandleClientDisconnect(this);
// client? then stop transport // paul: we may be connecting or connected, either way, we need to disconnect
if (NetworkManager.singleton.transport.ClientConnected()) // transport should not do anything if it is not connecting/connected
{
NetworkManager.singleton.transport.ClientDisconnect(); NetworkManager.singleton.transport.ClientDisconnect();
}
// server? then disconnect that client // server? then disconnect that client
else if (NetworkManager.singleton.transport.ServerActive()) if (NetworkManager.singleton.transport.ServerActive())
{ {
NetworkManager.singleton.transport.ServerDisconnect(connectionId); NetworkManager.singleton.transport.ServerDisconnect(connectionId);
} }