Example #1
0
        protected void _1s_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (this._remain_life_number > 0)
            {
                this._remain_life_number--;
                if (this._remain_life_number <= 0)
                {
                    EzLogger.GlobalLogger.info("tcp client receive timeout, life = " + this._remain_life_number);

                    this.Dispose();

                    OnConnectionDropped();
                }
            }

            if (this.AutoHeartBeat && (_remain_heart_beat_number-- <= 0))
            {
                _remain_heart_beat_number = this.DefaultHeartBeatNumber;

                if (this.Connected)
                {
                    HeartBeatCmd hb = new HeartBeatCmd();
                    hb.sender_name = this.HeartBeatSender;
                    Helper.tcp_client_send(this, hb);
                }
            }
        }
        protected void _1s_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (this._remain_life_number > 0)
            {
                this._remain_life_number--;
                if (this._remain_life_number <= 0)
                {
                    EzLogger.GlobalLogger.info("tcp client receive timeout, life = " + this._remain_life_number);

                    this.Dispose();

                    OnConnectionDropped();
                }
            }

            if (this.AutoHeartBeat && (_remain_heart_beat_number-- <= 0))
            {
                _remain_heart_beat_number = this.DefaultHeartBeatNumber;

                if (this.Connected)
                {
                    HeartBeatCmd hb = new HeartBeatCmd();
                    hb.sender_name = this.HeartBeatSender;
                    Helper.tcp_client_send(this, hb);
                }
            }
        }