Example #1
0
            public void OnReceiveDisposition(Disposition disposition)
            {
                SequenceNumber first = disposition.First.Value;
                SequenceNumber last  = disposition.Last ?? first;

                this.session.diagnostics.SetLastDisposition(last.Value);
                bool settled = disposition.Settled();

                for (SequenceNumber i = first; ; i.Increment())
                {
                    Delivery delivery = this.GetDelivery(i);
                    if (delivery != null && delivery.Link != null)
                    {
                        delivery.Settled = settled;
                        delivery.State   = disposition.State;
                        delivery.Link.OnDisposeDelivery(delivery);
                    }

                    if (i == last)
                    {
                        break;
                    }
                }

                if (settled)
                {
                    this.Settle();
                }
            }
Example #2
0
            public void OnReceiveDisposition(Disposition disposition)
            {
                SequenceNumber first = disposition.First.Value;
                SequenceNumber last  = disposition.Last ?? first;

                if (last < first)
                {
                    // Should be a protocol error
                    return;
                }

                List <Delivery> disposedDeliveries = new List <Delivery>();
                int             settledCount       = 0;

                lock (this.syncRoot)
                {
                    if (first >= this.nextDeliveryId)
                    {
                        return;
                    }

                    if (last > this.nextDeliveryId)
                    {
                        last = this.nextDeliveryId;
                    }

                    bool     settled = disposition.Settled();
                    Delivery current = this.firstUnsettled;
                    while (current != null)
                    {
                        SequenceNumber sn = current.DeliveryId.Value;
                        if (sn < first)
                        {
                            current = current.Next;
                        }
                        else if (sn > last)
                        {
                            break;
                        }
                        else
                        {
                            Delivery delivery = current;
                            current = current.Next;

                            delivery.Settled = settled;
                            delivery.State   = disposition.State;
                            if (settled)
                            {
                                ++settledCount;
                                Delivery.Remove(ref this.firstUnsettled, ref this.lastUnsettled, delivery);
                            }

                            disposedDeliveries.Add(delivery);
                        }
                    }
                }

                if (disposedDeliveries.Count > 0)
                {
                    foreach (Delivery delivery in disposedDeliveries)
                    {
                        delivery.Link.OnDisposeDelivery(delivery);
                    }

                    if (settledCount > 0)
                    {
                        this.OnWindowMoved(settledCount);
                    }
                }
            }
Example #3
0
            public void OnReceiveDisposition(Disposition disposition)
            {
                SequenceNumber valueOrDefault;
                SequenceNumber value = disposition.First.Value;
                uint?          last  = disposition.Last;

                if (last.HasValue)
                {
                    valueOrDefault = last.GetValueOrDefault();
                }
                else
                {
                    valueOrDefault = value;
                }
                SequenceNumber sequenceNumber = valueOrDefault;

                if (sequenceNumber < value)
                {
                    return;
                }
                LinkedList <Delivery> deliveries = new LinkedList <Delivery>();
                int num = 0;

                lock (this.syncRoot)
                {
                    if (value < this.nextDeliveryId)
                    {
                        if (sequenceNumber > this.nextDeliveryId)
                        {
                            sequenceNumber = this.nextDeliveryId;
                        }
                        bool flag = disposition.Settled();
                        LinkedListNode <Delivery> first = this.deliveries.First;
                        while (first != null)
                        {
                            SequenceNumber value1 = first.Value.DeliveryId.Value;
                            if (value1 >= value)
                            {
                                if (value1 > sequenceNumber)
                                {
                                    break;
                                }
                                LinkedListNode <Delivery> linkedListNode = first;
                                first = first.Next;
                                Delivery state = linkedListNode.Value;
                                state.Settled = flag;
                                state.State   = disposition.State;
                                if (!flag)
                                {
                                    deliveries.AddLast(linkedListNode.Value);
                                }
                                else
                                {
                                    num++;
                                    this.deliveries.Remove(linkedListNode);
                                    deliveries.AddLast(linkedListNode);
                                }
                            }
                            else
                            {
                                first = first.Next;
                            }
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                if (deliveries.Count > 0)
                {
                    foreach (Delivery delivery in deliveries)
                    {
                        delivery.Link.OnDisposeDelivery(delivery);
                    }
                    if (num > 0)
                    {
                        this.OnWindowMoved(num);
                    }
                }
            }