IEnumerator CleanUpStoppedServer() { // We wait to give the disconnect message time to go out // If we didn't wait here clients wouldn't recognize the server disconnect until after a long timeout yield return(0); NobleServer.Dispose(); }
/// <summary>Clean up the client and server.</summary> /// <remarks> /// If you override this method you must call the base method or resources will not be properly cleaned up. /// </remarks> override public void OnDestroy() { base.OnDestroy(); // Only Dispose static NobleServer is this is "main" network manager // This fixes an issue where having a network manager in every scene // and destroying the unneeded one after a scene transition // would cause a disconnect if (NetworkManager.singleton == (this as NetworkManager)) { NobleServer.Dispose(); if (client != null) { client.Dispose(); } } }