/// <summary> /// Closes the AMQP object, optionally with an error. /// </summary> /// <param name="waitUntilEnded">The number of seconds to block until a closing frame is received from the peer. If it is 0, the call is non-blocking.</param> /// <param name="error">The AMQP error to send to the peer, indicating why the object is being closed.</param> public void Close(int waitUntilEnded = DefaultCloseTimeout, Error error = null) { // initialize event first to avoid the race with NotifyClosed this.endEvent = new ManualResetEvent(false); if (!this.OnClose(error)) { if (waitUntilEnded > 0) { this.endEvent.WaitOne(waitUntilEnded, false); } } else { this.endEvent.Set(); this.NotifyClosed(null); } }
internal void NotifyClosed(Error error) { ManualResetEvent temp = this.endEvent; if (temp != null) { temp.Set(); } if (!this.closedNotified) { this.closedNotified = true; ClosedCallback closed = this.Closed; if (closed != null) { closed(this, error); } } }
public static void ReleaseAll(Delivery delivery, Error error) { Outcome outcome; if (error == null) { outcome = new Released(); } else { outcome = new Rejected() { Error = error }; } while (delivery != null) { if (delivery.OnOutcome != null) { delivery.OnOutcome(delivery.Message, outcome, delivery.UserToken); } delivery.Buffer.ReleaseReference(); delivery = (Delivery)delivery.Next; } }
internal void NotifyClosed(Error error) { this.Error = error; ManualResetEvent temp = this.endEvent; if (temp != null) { temp.Set(); } ClosedCallback closed = this.Closed; if (closed != null) { closed(this, error); } }
/// <summary> /// When overridden in a derived class, performs the actual close operation required by the object. /// </summary> /// <param name="error"></param> /// <returns></returns> protected abstract bool OnClose(Error error);
/// <summary> /// Aborts the receiver link. /// </summary> /// <param name="error">The error for the abort.</param> protected override void OnAbort(Error error) { Waiter waiter; lock (this.ThisLock) { waiter = (Waiter)this.waiterList.Clear(); } while (waiter != null) { waiter.Signal(null); waiter = (Waiter)waiter.Next; } }
/// <summary> /// Closes the AMQP object, optionally with an error. /// </summary> /// <param name="waitUntilEnded">The number of milliseconds to block until a closing frame is /// received from the peer. If it is 0, the call is non-blocking.</param> /// <param name="error">The AMQP <see cref="Error"/> to send to the peer, indicating why the object is being closed.</param> public void Close(int waitUntilEnded = DefaultCloseTimeout, Error error = null) { if (this.closedCalled) { return; } this.closedCalled = true; // initialize event first to avoid the race with NotifyClosed if (waitUntilEnded > 0) { this.endEvent = new ManualResetEvent(false); } this.Error = error; if (!this.OnClose(error)) { if (waitUntilEnded > 0) { this.endEvent.WaitOne(waitUntilEnded); } } else { if (waitUntilEnded > 0) { this.endEvent.Set(); } this.NotifyClosed(this.Error); } }
/// <summary> /// Closes the receiver link. /// </summary> /// <param name="error">The error for the closure.</param> /// <returns></returns> protected override bool OnClose(Error error) { this.OnAbort(error); return base.OnClose(error); }
/// <summary> /// Rejects a message. It sends a rejected outcome to the peer. /// </summary> /// <param name="message">The message to reject.</param> /// <param name="error">The error, if any, for the rejection.</param> public void Reject(Message message, Error error = null) { this.ThrowIfDetaching("Reject"); this.DisposeMessage(message, new Rejected() { Error = error }); }
/// <summary> /// Completes the processing of the attach performative with an error. /// </summary> /// <param name="error">The error to be sent to the remote peer.</param> public void Complete(Error error) { this.Link.CompleteAttach(this.Attach, error); }
private void ClientConnection_Closed(IAmqpObject sender, Amqp.Framing.Error error) { System.Console.WriteLine($"Client connection closed.\r\n Client Tracking Id: {this.TrackingId}\r\n Details: {error?.Description}"); AttachedClients.DetachClient(this, error?.Description); }
/// <summary> /// Rejects the message. /// </summary> /// <param name="error"></param> public void Complete(Error error) { this.Dispose(new Rejected() { Error = error }); }