Ejemplo n.º 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();
                }
            }
Ejemplo n.º 2
0
            void DisposeAndSettle()
            {
                if (this.session.State != AmqpObjectState.Opened)
                {
                    return;
                }

                bool needSettle = false;
                SequenceNumber start;
                SequenceNumber end;
                lock (this.syncRoot)
                {
                    start = this.unsettledLwm;
                    end = this.nextDeliveryId;
                }

                Disposition disposition = null;
                for (; start != end; start.Increment())
                {
                    Delivery firstDelivery = this.GetDelivery(start);
                    if (firstDelivery == null || !firstDelivery.StateChanged)
                    {
                        continue;
                    }

                    firstDelivery.StateChanged = false;
                    if (firstDelivery.Settled)
                    {
                        needSettle = true;
                    }

                    disposition = new Disposition();
                    disposition.First = start.Value;
                    disposition.Settled = firstDelivery.Settled;
                    disposition.State = firstDelivery.State;
                    disposition.Role = this.IsReceiver;

                    SequenceNumber last = start;
                    int count = 0;
                    for (last.Increment(); last != end; last.Increment())
                    {
                        Delivery lastDelivery = this.GetDelivery(last);
                        if (lastDelivery == null)
                        {
                            ++count;
                            continue;
                        }

                        if (!lastDelivery.StateChanged ||
                            lastDelivery.Settled != firstDelivery.Settled ||
                            !IsEqual(lastDelivery.State as Outcome, firstDelivery.State as Outcome))
                        {
                            break;
                        }

                        lastDelivery.StateChanged = false;
                        ++count;
                    }

                    if (count > 0)
                    {
                        disposition.Last = start + count;
                        start = disposition.Last.Value;
                    }

                    this.session.SendCommand(disposition);
                }

                if (needSettle)
                {
                    this.Settle();
                }
            }
Ejemplo n.º 3
0
        void OnReceiveDisposition(Disposition disposition)
        {
            if (disposition.Role.Value)
            {
                this.outgoingChannel.OnReceiveDisposition(disposition);
            }
            else
            {
                this.incomingChannel.OnReceiveDisposition(disposition);
            }

            this.diagnostics.ReceiveDisposition();
        }