NetworkClient.Disconnect: explicitly check against Connecting and Connected.

prepares for Disconnecting state so we don't need to change this here.
This commit is contained in:
vis2k 2021-07-08 16:10:15 +08:00
parent 49eeb58af6
commit 57c0f70df8

View File

@ -217,8 +217,12 @@ public static void ConnectLocalServer()
/// <summary>Disconnect from server.</summary>
public static void Disconnect()
{
// only if connected or connecting
if (connectState == ConnectState.Disconnected) return;
// only if connected or connecting.
// don't disconnect() again if already in the process of
// disconnecting or fully disconnected.
if (connectState != ConnectState.Connecting &&
connectState != ConnectState.Connected)
return;
// TODO move to 'cleanup' code below if safe
connectState = ConnectState.Disconnected;