NetworkClient.active reads from .connectState so we don't have redundant states.

This commit is contained in:
vis2k 2019-04-05 20:11:22 +02:00
parent 04370e56c0
commit de0b9b5789

View File

@ -31,7 +31,7 @@ public class NetworkClient
// active is true while a client is connecting/connected
// (= while the network is active)
public static bool active { get; internal set; }
public static bool active => connectState == ConnectState.Connecting || connectState == ConnectState.Connected;
public static bool isConnected => connectState == ConnectState.Connected;
@ -48,7 +48,6 @@ public static void Connect(string address)
{
if (LogFilter.Debug) Debug.Log("Client Connect: " + address);
active = true;
RegisterSystemHandlers(false);
Transport.activeTransport.enabled = true;
InitializeTransportHandlers();
@ -65,7 +64,7 @@ public static void Connect(string address)
internal static void ConnectLocalServer()
{
if (LogFilter.Debug) Debug.Log("Client Connect Local Server");
active = true;
RegisterSystemHandlers(true);
connectState = ConnectState.Connected;
@ -167,9 +166,6 @@ public static void Disconnect()
connection = null;
RemoveTransportHandlers();
}
// the client's network is not active anymore.
active = false;
}
}
@ -372,7 +368,7 @@ public static void UnregisterHandler<T>() where T : IMessageBase
public static void Shutdown()
{
if (LogFilter.Debug) Debug.Log("Shutting down client.");
active = false;
connectState = ConnectState.None;
}
[Obsolete("Call NetworkClient.Shutdown() instead. There is only one client.")]