Ejemplo n.º 1
0
 //string portName;
 public ResendTrigger(QQClient client)
 {
     this.client  = client;
     timeOutQueue = new List <OutPacket>();
     //toPort = new Dictionary<OutPacket, string>();
     ThreadExcutor.RegisterIntervalObject(this, this, QQGlobal.QQ_TIMEOUT_SEND, true);
 }
Ejemplo n.º 2
0
        public void Run(object state, bool timedOut)
        {
            if (IsRunning == false)
            {
                lock (this)
                {
                    if (!IsRunning)
                    {
                        IsRunning = true;
                        long t = GetTimeoutLeft();
                        while (t <= 0)
                        {
                            OutPacket   packet = Remove();
                            IConnection conn   = client.ConnectionManager.ConnectionPool.GetConnection(packet.PortName);
                            if (conn != null && packet != null && !conn.Policy.IsReplied(packet, false))
                            {
                                if (packet.NeedResend())
                                {
                                    // 重发次数未到最大,重发
                                    client.PacketManager.SendPacketAnyway(packet, packet.PortName);
                                }
                                else
                                {
                                    // 触发操作超时事件
                                    FireOperationTimeOutEvent(packet, packet.PortName);
                                }
                            }
                            t = GetTimeoutLeft();
                        }
                        IsRunning = false;

                        // 继续等待 t 时间后再执行 // 先反注册原来的线程
                        this.RegisterdHandler.Unregister(this.WaitHandler);
                        ThreadExcutor.RegisterIntervalObject(this, this, t, true);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public KeepAliveTrigger(QQClient client)
 {
     this.client = client;
     ThreadExcutor.RegisterIntervalObject(this, this, QQGlobal.QQ_INTERVAL_KEEP_ALIVE, false);
 }