示例#1
0
        public void TearDown()
        {
            // stop server/client
            NetworkClient.DisconnectLocalServer();

            NetworkClient.Disconnect();
            NetworkClient.Shutdown();

            NetworkServer.Shutdown();

            // destroy left over objects
            foreach (GameObject item in spawned)
            {
                if (item != null)
                {
                    GameObject.DestroyImmediate(item);
                }
            }

            spawned.Clear();

            NetworkIdentity.spawned.Clear();

            GameObject.DestroyImmediate(Transport.activeTransport.gameObject);
        }
示例#2
0
        public void TearDown()
        {
            NetworkClient.DisconnectLocalServer();
            NetworkClient.Disconnect();
            NetworkClient.Shutdown();

            if (NetworkServer.active)
            {
                NetworkServer.Shutdown();
            }

            if (Transport.activeTransport != null)
            {
                GameObject.Destroy(Transport.activeTransport.gameObject);
            }
        }
示例#3
0
        private IEnumerator DisconnectCoroutine(TaskCompletionSource disconnectTask)
        {
            if (MvNetworkManager.I.IsHost)
            {
                NetworkClient.DisconnectLocalServer();
                _networkManager.StopClient();
            }
            else
            {
                _networkManager.client.connection.Disconnect();
                _networkManager.client.connection.InvokeHandler(new DisconnectMessage(), -1);
            }

            yield return(new WaitUntilTimeout(() => !NetworkClient.active && !NetworkClient.isConnected));

            disconnectTask.SetResult();
        }
示例#4
0
 /// <summary>
 /// disconnect host mode. this is needed to call DisconnectMessage for
 /// the host client too.
 /// </summary>
 public void DisconnectLocalServer()
 {
     NetworkClient.DisconnectLocalServer();
 }