コード例 #1
0
ファイル: AmqpSession.cs プロジェクト: modulexcite/IL2JS
        void OnReceiveFlow(Flow flow)
        {
            this.outgoingChannel.OnFlow(flow);
            this.incomingChannel.OnFlow(flow);

            if (flow.Handle.HasValue)
            {
                AmqpLink link = null;
                if (!this.linksByRemoteHandle.TryGetObject(flow.Handle.Value, out link))
                {
                    this.TryClose(new AmqpException(AmqpError.UnattachedHandle));
                    return;
                }

                link.OnFlow(flow);
            }
            else if (flow.Echo())
            {
                this.SendFlow();
            }

            this.diagnostics.ReceiveFlow(flow.Handle.HasValue);
        }
コード例 #2
0
ファイル: AmqpLink.cs プロジェクト: modulexcite/IL2JS
        void OnReceiveFlow(Flow flow)
        {
            Utils.Trace(TraceLevel.Verbose, "{0}: Receive {1}", this, flow);
            lock (this.syncRoot)
            {
                if (this.IsReceiver)
                {
                    this.available = flow.Available ?? uint.MaxValue;
                    // this.transferCount = flow.TransferCount ?? this.transferCount;
                }
                else
                {
                    this.drain = flow.Drain ?? false;
                    if (flow.LinkCredit() != uint.MaxValue)
                    {
                        if (this.linkCredit == uint.MaxValue)
                        {
                            this.linkCredit = flow.LinkCredit.Value;
                        }
                        else
                        {
                            uint oldCredit = this.linkCredit;
                            uint otherDeliveryCount = flow.DeliveryCount ?? 0;
                            this.linkCredit = unchecked(otherDeliveryCount + flow.LinkCredit.Value - this.deliveryCount.Value);
                        }
                    }
                    else
                    {
                        this.linkCredit = uint.MaxValue;
                    }
                }
            }

            this.pendingDeliveries.ContinueWork();

            if (flow.Echo())
            {
                this.SendFlow(false);
            }

            if (this.linkCredit > 0)
            {
                ArraySegment<byte> txnId = this.GetTxnIdFromFlow(flow);
                this.OnCreditAvailable(this.linkCredit, this.drain, txnId);
            }
        }