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); } } }
void SendDisposition(DispositionInfo info) { Disposition disposition = new Disposition(); disposition.First = info.First.DeliveryId.Value; disposition.Last = info.Last; disposition.Settled = info.First.Settled; disposition.State = info.First.State; disposition.Role = this.IsReceiver; lock (this.session.ThisLock) { if (this.session.State < AmqpObjectState.CloseSent) { this.session.SendCommand(disposition); } } }
void OnReceiveDisposition(Disposition disposition) { if (disposition.Role.Value) { this.outgoingChannel.OnReceiveDisposition(disposition); } else { this.incomingChannel.OnReceiveDisposition(disposition); } }