예제 #1
0
        private void InterceptDispositionFrame(Disposition disposition)
        {
            if (!State.CanReceiveFrames())
            {
                throw new AmqpException(ErrorCode.IllegalState, $"Received Disposition frame but session state is {State.ToString()}.");
            }
            if (State == SessionStateEnum.DISCARDING)
            {
                return;
            }

            if (disposition.Role == true)
            {
                // from the RECEIVER
                throw new NotImplementedException();
            }
            else
            {
                // from the SENDER
                // We typically get a Disposition when the Receiver Link (our side)
                // sends back an unsettled Disposition in a terminal state.
                if (!disposition.Last.HasValue)
                {
                    disposition.Last = disposition.First;
                }
                for (uint deliveryHandle = disposition.First; deliveryHandle <= disposition.Last; deliveryHandle++)
                {
                    var delivery = incomingUnsettledMap.Find(d => d.DeliveryId == deliveryHandle);
                    delivery.Settled = disposition.Settled;
                    delivery.State   = disposition.State;

                    var link = delivery.Link;
                    if (link.State == LinkStateEnum.DESTROYED)
                    {
                        throw new AmqpException(ErrorCode.ErrantLink, "If any input (other than a detach) related to the endpoint either via the input handle or delivery-ids be received, the session MUST be terminated with an errant-link session-error.");
                    }
                    link.NotifyOfDisposition(delivery, disposition);

                    if (disposition.Settled)
                    {
                        incomingUnsettledMap.Remove(delivery);
                    }
                }
            }
        }