Пример #1
0
        private void AddAckDict(int channelID, long seqNoRecved, long sentSvrTime)
        {
            Dictionary <long, AckInfo> dictionary = null;

            if (!this.ackDict[this.curAckDictArrIdx].TryGetValue(channelID, out dictionary))
            {
                dictionary = new Dictionary <long, AckInfo>();
                this.ackDict[this.curAckDictArrIdx].Add(channelID, dictionary);
            }
            AckInfo ackInfo = null;

            if (!dictionary.TryGetValue(seqNoRecved, out ackInfo))
            {
                ackInfo = UdpPoolBase <AckInfo> .Alloc();

                dictionary.Add(seqNoRecved, ackInfo);
            }
            ackInfo.channelID   = channelID;
            ackInfo.seqNoRecved = seqNoRecved;
            ackInfo.sentTime    = sentSvrTime;
        }
Пример #2
0
        public void SendAllAck()
        {
            Dictionary <byte, object> dictionary = null;
            byte b    = 0;
            int  num  = 1;
            int  num2 = 3;

            for (int i = 0; i < this.maxAckDictArrLen; i++)
            {
                Dictionary <int, Dictionary <long, AckInfo> > .Enumerator enumerator = this.ackDict[i].GetEnumerator();
                while (enumerator.MoveNext())
                {
                    KeyValuePair <int, Dictionary <long, AckInfo> > current = enumerator.Current;
                    Dictionary <long, AckInfo> value = current.Value;
                    current = enumerator.Current;
                    int key = current.Key;
                    Dictionary <long, AckInfo> .Enumerator enumerator2 = value.GetEnumerator();
                    int num3 = 0;
                    while (enumerator2.MoveNext())
                    {
                        if (b >= 70)
                        {
                            dictionary[0] = b;
                            this.pvpPeer.OpCustom(UdpDriverBase.OperationCode_Ack, dictionary, false, 0);
                            b          = 0;
                            dictionary = null;
                        }
                        if (dictionary == null)
                        {
                            dictionary = new Dictionary <byte, object>();
                        }
                        if (num3 == 0)
                        {
                            dictionary[(byte)(num2 * (int)b + num)]     = key;
                            dictionary[(byte)(num2 * (int)b + 1 + num)] = base.GetNewestFirstSeqno(key);
                            dictionary[(byte)(num2 * (int)b + 2 + num)] = 0L;
                            b += 1;
                        }
                        KeyValuePair <long, AckInfo> current2 = enumerator2.Current;
                        AckInfo value2 = current2.Value;
                        dictionary[(byte)(num2 * (int)b + num)]     = value2.channelID;
                        dictionary[(byte)(num2 * (int)b + 1 + num)] = value2.seqNoRecved;
                        dictionary[(byte)(num2 * (int)b + 2 + num)] = value2.sentTime;
                        UdpPoolBase <AckInfo> .Free(value2);

                        b += 1;
                        num3++;
                    }
                    value.Clear();
                }
            }
            if (b > 0)
            {
                dictionary[0] = b;
                if (!this.pvpPeer.OpCustom(UdpDriverBase.OperationCode_Ack, dictionary, false, 0))
                {
                }
            }
            this.curAckDictArrIdx++;
            this.curAckDictArrIdx %= this.maxAckDictArrLen;
            this.ackDict[this.curAckDictArrIdx].Clear();
        }