Пример #1
0
        private void Disconnect()
        {
            lock (this)
            {
                if (Connected)
                {
                    _pluginManager.Dispose();
                    QueryDispatcher.Disconnect();
                    QueryDispatcher?.Dispose();
                    QueryRunner?.Dispose();

                    _stopwatch.Stop();
                    Console.WriteLine("Disconnected! Been connected for {0}:{1}:{2}.{3}", _stopwatch.Elapsed.Hours, _stopwatch.Elapsed.Minutes, _stopwatch.Elapsed.Seconds, _stopwatch.Elapsed.Milliseconds);
                }
                Connected = false;
            }
        }
Пример #2
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();
            }
        }
Пример #3
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");
            }
        }