UnityEngine.Networking.ClientScene.HandleClientDisconnect C# (CSharp) Method

HandleClientDisconnect() static private method

static private HandleClientDisconnect ( NetworkConnection conn ) : void
conn NetworkConnection
return void
        internal static void HandleClientDisconnect(NetworkConnection conn)
        {
            if ((s_ReadyConnection == conn) && s_IsReady)
            {
                s_IsReady = false;
                s_ReadyConnection = null;
            }
        }

Usage Example

コード例 #1
0
        public bool ReconnectToNewHost(string serverIp, int serverPort)
        {
            if (!NetworkClient.active)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Reconnect - NetworkClient must be active");
                }
                return(false);
            }

            if (m_Connection == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Reconnect - no old connection exists");
                }
                return(false);
            }

            if (LogFilter.logInfo)
            {
                Debug.Log("NetworkClient Reconnect " + serverIp + ":" + serverPort);
            }

            ClientScene.HandleClientDisconnect(m_Connection);
            ClientScene.ClearLocalPlayers();

            m_Connection.Disconnect();
            m_Connection = null;
            m_ClientId   = m_UseRelay ? RelayTransport.AddHost(m_HostTopology, m_HostPort, false, RelayTransport.RelayAddress, RelayTransport.RelayPort) : NetworkTransport.AddHost(m_HostTopology, m_HostPort);

            string hostnameOrIp = serverIp;

            m_ServerPort = serverPort;

            //TODO: relay reconnect

            /*
             * if (Match.NetworkMatch.matchSingleton != null)
             * {
             *  hostnameOrIp = Match.NetworkMatch.matchSingleton.address;
             *  m_ServerPort = Match.NetworkMatch.matchSingleton.port;
             * }*/

            if (UnityEngine.Application.platform == RuntimePlatform.WebGLPlayer)
            {
                m_ServerIp     = hostnameOrIp;
                m_AsyncConnect = ConnectState.Resolved;
            }
            else if (serverIp.Equals("127.0.0.1") || serverIp.Equals("localhost"))
            {
                m_ServerIp     = "127.0.0.1";
                m_AsyncConnect = ConnectState.Resolved;
            }
            else
            {
                if (LogFilter.logDebug)
                {
                    Debug.Log("Async DNS START:" + hostnameOrIp);
                }
                m_AsyncConnect = ConnectState.Resolving;
                Dns.BeginGetHostAddresses(hostnameOrIp, new AsyncCallback(GetHostAddressesCallback), this);
            }
            return(true);
        }
All Usage Examples Of UnityEngine.Networking.ClientScene::HandleClientDisconnect