Exemple #1
0
 protected void OnReceiveFirstTransfer(Transfer transfer)
 {
     Fx.Assert(transfer.DeliveryId.HasValue, "The first transfer must have a delivery id.");
     this.nextDeliveryId = transfer.DeliveryId.Value;
 }
Exemple #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);
                    }
                }
            }
Exemple #3
0
 /// <summary>
 /// Initializes the object.
 /// </summary>
 /// <param name="type">Used as a prefix in the name for tracking/debugging purposes.</param>
 protected AmqpObject(string type)
     : this(type, SequenceNumber.Increment(ref AmqpObject.nextId))
 {
 }
Exemple #4
0
 public SessionChannel(AmqpSession session)
 {
     this.session        = session;
     this.nextDeliveryId = session.settings.InitialDeliveryId;
     this.syncRoot       = new object();
 }
Exemple #5
0
 /// <summary>
 /// Initializes the object.
 /// </summary>
 /// <param name="type">Used as a prefix in the name for tracking/debugging purposes.</param>
 /// <param name="identifier">Identifier of the object.</param>
 protected AmqpObject(string type, SequenceNumber identifier)
 {
     this.identifier = identifier;
     this.name       = type + this.identifier;
 }