protected AmqpLink(AmqpSession session, AmqpLinkSettings linkSettings) { if (linkSettings == null) { throw new ArgumentNullException("linkSettings"); } this.Session = session; this.settings = linkSettings; this.linkCredit = this.settings.TransferLimit; this.settings.AutoSendFlow = this.linkCredit > 0; this.syncRoot = new object(); Source source = (Source)this.settings.Source; if (source != null) { this.defaultOutcome = source.DefaultOutcome; } if (this.defaultOutcome == null) { this.defaultOutcome = AmqpConstants.ReleasedOutcome; } this.unsettledMap = new Dictionary<ArraySegment<byte>, Delivery>(ByteArrayComparer.Instance); this.pendingDeliveries = new SerializedWorker<Delivery>(this.TrySendDelivery, this.AbortDelivery, false); session.AttachLink(this); }
public IAsyncResult BeginDisposeMessage(ArraySegment<byte> deliveryTag, Outcome outcome, bool batchable, TimeSpan timeout, AsyncCallback callback, object state) { return new DisposeAsyncResult(this, deliveryTag, outcome, batchable, timeout, callback, state); }
public DisposeAsyncResult( ReceivingAmqpLink link, ArraySegment<byte> deliveryTag, Outcome outcome, bool batchable, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { if (link.TryGetDelivery(deliveryTag, out this.delivery)) { delivery.CompleteCallback = onDisposeComplete; delivery.UserToken = this; link.DisposeDelivery(delivery, false, outcome); } else { // Delivery tag not found this.outcome = new Rejected() { Error = AmqpError.NotFound }; this.Complete(true); } }
static bool IsEqual(Outcome outcome1, Outcome outcome2) { if (outcome1 != null && outcome2 != null) { // TODO: how about the error messages return outcome1.DescriptorCode == outcome2.DescriptorCode; } else { return outcome1 == null && outcome2 == null; } }