UnityEngine.Networking.NetworkMigrationManager.LostHostOnClient C# (CSharp) Method

LostHostOnClient() public method

This should be called on a client when it has lost its connection to the host.

public LostHostOnClient ( NetworkConnection conn ) : bool
conn NetworkConnection The connection of the client that was connected to the host.
return bool
        public bool LostHostOnClient(NetworkConnection conn)
        {
            byte num;
            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkMigrationManager client OnDisconnectedFromHost");
            }
            if (Application.platform == RuntimePlatform.WebGLPlayer)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("LostHostOnClient: Host migration not supported on WebGL");
                }
                return false;
            }
            if (this.m_Client == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("NetworkMigrationManager LostHostOnHost client was never initialized.");
                }
                return false;
            }
            if (!this.m_HostMigration)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("NetworkMigrationManager LostHostOnHost migration not enabled.");
                }
                return false;
            }
            this.m_DisconnectedFromHost = true;
            this.DisablePlayerObjects();
            NetworkTransport.Disconnect(this.m_Client.hostId, this.m_Client.connection.connectionId, out num);
            if (this.m_OldServerConnectionId != -1)
            {
                SceneChangeOption option;
                this.OnClientDisconnectedFromHost(conn, out option);
                return (option == SceneChangeOption.StayInOnlineScene);
            }
            return false;
        }

Usage Example

コード例 #1
0
        internal void OnClientDisconnectInternal(NetworkMessage netMsg)
        {
            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkManager:OnClientDisconnectInternal");
            }

#if ENABLE_UNET_HOST_MIGRATION
            if (m_MigrationManager != null)
            {
                if (m_MigrationManager.LostHostOnClient(netMsg.conn))
                {
                    // should OnClientDisconnect be called?
                    return;
                }
            }
#endif

            if (m_OfflineScene != "")
            {
                //ClientChangeScene(m_OfflineScene, false);
            }

            // If we have a valid connection here drop the client in the matchmaker before shutting down below
            if (matchMaker != null && matchInfo != null && matchInfo.networkId != NetworkID.Invalid && matchInfo.nodeId != NodeID.Invalid)
            {
                matchMaker.DropConnection(matchInfo.networkId, matchInfo.nodeId, matchInfo.domain, OnDropConnection);
            }

            OnClientDisconnect(netMsg.conn);
        }
All Usage Examples Of UnityEngine.Networking.NetworkMigrationManager::LostHostOnClient