Esempio n. 1
0
 protected override byte[] processMessage(UnPacker unPacker)
 {
     unPacker.UnpackByte(); //Remove id byte from message.
     return unPacker.UnpackByteArray(unPacker.remaining());
 }
Esempio n. 2
0
            private byte[] processRecivedMessage(UnPacker unPacker, int accnum)
            {
                if (accnum > this.lastRecivedMessageAckNum)
                {
                    addMissingMessages(accnum);
                    this.lastRecivedMessageAckNum = accnum;

                    return unPacker.UnpackByteArray(unPacker.remaining());
                }
                else
                {
                    if (this.missingMessages.Contains(accnum))
                    {
                        this.missingMessages.Remove(accnum);
                        return unPacker.UnpackByteArray(unPacker.remaining());
                    }

                    return null;
                }
            }
Esempio n. 3
0
            private byte[] buildOrderedMessages(UnPacker unPacker)
            {
                List<int> keysToRemove = new List<int>();
                Packer packer = new Packer(unPacker.remaining());
                packer.Pack(unPacker.UnpackByteArray(unPacker.remaining()));

                foreach (var item in this.outOfOrderMessages.Keys)
                {
                    if (this.lastOrderedMessage + 1 == item)
                    {
                        keysToRemove.Add(item);
                        this.lastOrderedMessage++;
                        packer.Pack(this.outOfOrderMessages[item]);
                    }
                    else
                    {
                        break;
                    }
                }

                keysToRemove.ForEach((x) => this.outOfOrderMessages.Remove(x));

                return packer.GetPackedData();
            }
Esempio n. 4
0
            private byte[] processRecivedMessage(UnPacker unPacker, int accnum)
            {
                if (this.lastOrderedMessage + 1 == accnum)
                {
                    this.lastOrderedMessage++;
                    if (this.outOfOrderMessages.Count == 0)
                        return unPacker.UnpackByteArray(unPacker.remaining());

                    return this.buildOrderedMessages(unPacker);
                }
                else if (this.lastOrderedMessage >= accnum)
                {
                    return null;
                }
                else
                {
                    if (!this.outOfOrderMessages.ContainsKey(accnum))
                    {
                        Console.WriteLine("Message out of order! {0}", accnum);
                        this.outOfOrderMessages.Add(accnum, unPacker.UnpackByteArray(unPacker.remaining()));
                    }
                    return null;
                }
            }
Esempio n. 5
0
 protected override byte[] processMessage(UnPacker unPacker)
 {
     unPacker.UnpackByte();
     int seqNum = unPacker.UnpackInteger();
     if (seqNum < lastRecivedSequenceNumber)
     {
         return null; //Discard the message if it is old.
     }
     else
     {
         lastRecivedSequenceNumber = seqNum;
         return unPacker.UnpackByteArray(unPacker.remaining());
     }
 }