Пример #1
0
        /// <summary>
        /// Event that fires every second to check if there is a connection available
        /// If there is no connection the interval will rise with 0.5s until 8s
        /// </summary>
        private void Reconnect(object sender, ElapsedEventArgs e)
        {
            Retry_Connection_Timer.Interval = Retry_Connection_Timer.Interval < 8000 ? Retry_Connection_Timer.Interval + 500 : 8000;
            //Try again when disconnected
            if (Connected != ChatListener.ConnectionState.Connecting)
            {
                if (QueryDispatcher != null)
                {
                    QueryDispatcher.Disconnect();
                    QueryDispatcher.DetachAllEventListeners();
                }

                QueryDispatcher = null;
                QueryRunner     = null;
                Connect();
            }
        }
Пример #2
0
        public void Disconnect()
        {
            lock (ThreadLocker)
            {
                if (QueryDispatcher != null)
                {
                    QueryDispatcher.Disconnect();
                    QueryDispatcher.DetachAllEventListeners();
                }

                //clear values
                QueryDispatcher = null;
                QueryRunner     = null;
                Connected       = ConnectionState.Disconnected;
                Retry_Connection_Timer.Start();
                //Thread.CurrentThread.Abort();
            }
        }
        /// <summary>
        /// Event that fires every second to check if there is a connection available
        /// If there is no connection the interval will rise with 0.5s until 8s
        /// </summary>
        private void Reconnect(object sender, ElapsedEventArgs e)
        {
            Retry_Connection_Timer.Interval = Retry_Connection_Timer.Interval < 8000 ? Retry_Connection_Timer.Interval + 500 : 8000;
            API.Log(API.LogType.Debug, "Try Reconnect");
            //Try again when disconnected
            if (Connected != TeamspeakConnectionThread.ConnectionState.Connecting)
            {
                ClearValues();
                if (QueryDispatcher != null)
                {
                    QueryDispatcher.Disconnect();
                    QueryDispatcher.DetachAllEventListeners();
                }

                QueryDispatcher = null;
                QueryRunner     = null;
                Connect();
                API.Log(API.LogType.Debug, "Teamspeak.ddl: Reconnect");
            }
        }