コード例 #1
0
        /// <summary>
        /// Initializes the link object.
        /// </summary>
        /// <param name="type">A prefix to the link name for debugging purposes.</param>
        /// <param name="session">The session in which the link is created.</param>
        /// <param name="linkSettings">The link settings.</param>
        protected AmqpLink(string type, AmqpSession session, AmqpLinkSettings linkSettings)
            : base(type)
        {
            this.references = 1;
            this.syncRoot   = new object();
            this.settings   = linkSettings ?? throw new ArgumentNullException(nameof(linkSettings));
            this.linkCredit = this.settings.TotalLinkCredit;

            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);
            if (session != null)
            {
                this.AttachTo(session);
            }

            if (!linkSettings.IsReceiver())
            {
                this.inflightDeliveries = new SerializedWorker <Delivery>(this);
            }
        }
コード例 #2
0
 /// <summary>
 /// Initializes the object.
 /// </summary>
 /// <param name="session">The session where the link is created.</param>
 /// <param name="settings">The link settings.</param>
 public SendingAmqpLink(AmqpSession session, AmqpLinkSettings settings)
     : base("sender", session, settings)
 {
     // TODO: Add capability negotiation logic for BatchedMessageFormat to this.Settings
     this.pendingDeliveries   = new SerializedWorker <AmqpMessage>(this);
     this.inflightSends       = new WorkCollection <ArraySegment <byte>, SendAsyncResult, Outcome>(ByteArrayComparer.Instance);
     this.lastFlowRequestTime = DateTime.UtcNow;
 }
コード例 #3
0
ファイル: FrameDecoder.cs プロジェクト: yvgopal/azure-amqp
        public void ExtractFrameBuffers(ByteBuffer buffer, SerializedWorker <ByteBuffer> bufferHandler)
        {
            if (this.currentFrameBuffer != null)
            {
                int sizeToWrite = Math.Min(this.currentFrameBuffer.Size, buffer.Length);

                AmqpBitConverter.WriteBytes(this.currentFrameBuffer, buffer.Buffer, buffer.Offset, sizeToWrite);
                buffer.Complete(sizeToWrite);

                if (this.currentFrameBuffer.Size == 0)
                {
                    ByteBuffer frameBuffer = this.currentFrameBuffer;
                    this.currentFrameBuffer = null;
                    bufferHandler.DoWork(frameBuffer);
                }
            }

            while (buffer.Length >= AmqpCodec.MinimumFrameDecodeSize)
            {
                int frameSize = AmqpCodec.GetFrameSize(buffer);
                if (frameSize < AmqpCodec.MinimumFrameDecodeSize || frameSize > this.maxFrameSize)
                {
                    throw new AmqpException(AmqpErrorCode.FramingError, CommonResources.GetString(CommonResources.InvalidFrameSize, frameSize, this.maxFrameSize));
                }

                int sizeToWrite = Math.Min(frameSize, buffer.Length);
                this.currentFrameBuffer = new ByteBuffer(frameSize, false);
                AmqpBitConverter.WriteBytes(this.currentFrameBuffer, buffer.Buffer, buffer.Offset, sizeToWrite);
                buffer.Complete(sizeToWrite);

                if (frameSize == sizeToWrite)
                {
                    ByteBuffer frameBuffer = this.currentFrameBuffer;
                    this.currentFrameBuffer = null;
                    bufferHandler.DoWork(frameBuffer);
                }
                else
                {
                    break;
                }
            }
        }
コード例 #4
0
ファイル: AmqpLink.cs プロジェクト: iwate/azure-amqp
        int references; // make sure no frames are sent after close

        protected AmqpLink(AmqpSession session, AmqpLinkSettings linkSettings)
            : this("link", session, linkSettings)
        {
            this.inflightDeliveries = new SerializedWorker <Delivery>(this);
        }