From de0b9b5789be85fb2160423dd103901af7bf3246 Mon Sep 17 00:00:00 2001 From: vis2k Date: Fri, 5 Apr 2019 20:11:22 +0200 Subject: [PATCH] NetworkClient.active reads from .connectState so we don't have redundant states. --- Assets/Mirror/Runtime/NetworkClient.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Assets/Mirror/Runtime/NetworkClient.cs b/Assets/Mirror/Runtime/NetworkClient.cs index 4732ea8f6..7fe0c419c 100644 --- a/Assets/Mirror/Runtime/NetworkClient.cs +++ b/Assets/Mirror/Runtime/NetworkClient.cs @@ -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() 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.")]