Exemple #1
0
 public void Disconnect()
 {
     try
     {
         XSocket.Close();
     }
     catch (Exception)
     {
         Out.WriteLine("Error disconnecting user from Game", "GAME", ConsoleColor.DarkRed);
     }
 }
        private void OnGUI()
        {
            if (!showEntry)
            {
                return;
            }
            var rect = RemoteDebugConfig.clientRect;

            GUI.Label(rect, "本机:" + m_LocalIP);
            rect.y += GUI.skin.font.fontSize + 10;
            switch (m_State)
            {
            case ClientState.Disconnected:
                GUI_ServerList(rect);
                break;

            case ClientState.Connecting:
                GUI.Label(rect, "连接中...");
                break;

            case ClientState.ConnectFailed:
                GUI.Label(rect, "连接失败:" + m_ServerName);
                rect.y += GUI.skin.font.fontSize + 5;
                GUI_ServerList(rect);
                break;

            case ClientState.Connected:
                GUI.Label(rect, "已连接:" + m_ServerName);
                rect.y += GUI.skin.font.fontSize + 5;
                if (GUI.Button(rect, Styles.disconnect))
                {
                    m_State = ClientState.Disconnected;
                    if (m_Client != null)
                    {
                        m_Client.Close();
                    }
                }
                break;
            }
        }