diff --git a/Assets/Mirror/Core/NetworkManagerHUD.cs b/Assets/Mirror/Core/NetworkManagerHUD.cs index 62a126bc4..f78eedefa 100644 --- a/Assets/Mirror/Core/NetworkManagerHUD.cs +++ b/Assets/Mirror/Core/NetworkManagerHUD.cs @@ -55,7 +55,7 @@ void StartButtons() // cant be a server in webgl build if (GUILayout.Button("Single Player")) { - NetworkServer.dontListen = true; + NetworkServer.listen = false; manager.StartHost(); } #else diff --git a/Assets/Mirror/Core/NetworkServer.cs b/Assets/Mirror/Core/NetworkServer.cs index 64646bd57..4650d278e 100644 --- a/Assets/Mirror/Core/NetworkServer.cs +++ b/Assets/Mirror/Core/NetworkServer.cs @@ -70,9 +70,21 @@ public static partial class NetworkServer public static readonly Dictionary spawned = new Dictionary(); - /// Single player mode can use dontListen to not accept incoming connections - // see also: https://github.com/vis2k/Mirror/pull/2595 - public static bool dontListen; + /// Single player mode can set listen=false to not accept incoming connections. + static bool _listen = true; + public static bool listen + { + get { return _listen; } + set { _listen = value; } + } + + // DEPRECATED 2024-10-14 + [Obsolete("NetworkServer.dontListen was replaced with NetworkServer.listen. The new value is the opposite, and avoids double negatives like 'dontListen=false'")] + public static bool dontListen + { + get => !listen; + set => listen = !value; + } /// active checks if the server has been started either has standalone or as host server. public static bool active { get; internal set; } @@ -137,7 +149,7 @@ public static void Listen(int maxConns) maxConnections = maxConns; // only start server if we want to listen - if (!dontListen) + if (listen) { Transport.active.ServerStart(); @@ -241,7 +253,7 @@ public static void Shutdown() } // Reset all statics here.... - dontListen = false; + listen = true; isLoadingScene = false; lastSendTime = 0; actualTickRate = 0;