Esempio n. 1
0
 /// <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);
     }
 }
Esempio n. 2
0
        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);
                }
            }
        }
Esempio n. 3
0
        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;
            }
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
 /// <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);
Esempio n. 6
0
        /// <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;
            }
        }
Esempio n. 7
0
        /// <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);
            }
        }
Esempio n. 8
0
        /// <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);
        }
Esempio n. 9
0
 /// <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 });
 }
Esempio n. 10
0
 /// <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);
 }
Esempio n. 11
0
 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);
 }
Esempio n. 12
0
 /// <summary>
 /// Rejects the message.
 /// </summary>
 /// <param name="error"></param>
 public void Complete(Error error)
 {
     this.Dispose(new Rejected() { Error = error });
 }