Example #1
0
        void OnReceiveLinkFrame(Frame frame)
        {
            AmqpLink     link    = null;
            Performative command = frame.Command;

            if (command.DescriptorCode == Attach.Code)
            {
                Attach attach = (Attach)command;
                lock (this.ThisLock)
                {
                    this.links.TryGetValue(attach.LinkName, out link);
                }

                if (link == null)
                {
                    if (!this.TryCreateRemoteLink(attach, out link))
                    {
                        return;
                    }
                }
                else
                {
                    lock (this.ThisLock)
                    {
                        link.RemoteHandle = attach.Handle;
                        this.linksByRemoteHandle.Add(attach.Handle.Value, link);
                    }
                }
            }
            else
            {
                LinkPerformative linkBody = (LinkPerformative)command;
                if (!this.linksByRemoteHandle.TryGetObject(linkBody.Handle.Value, out link))
                {
                    if (this.Settings.IgnoreMissingLinks)
                    {
                        AmqpTrace.Provider.AmqpMissingHandle(this.connection, this, "link", linkBody.Handle.Value);
                        return;
                    }

                    if (linkBody.DescriptorCode != Detach.Code)
                    {
                        this.SafeClose(new AmqpException(AmqpErrorCode.UnattachedHandle, AmqpResources.GetString(AmqpResources.AmqpHandleNotFound, linkBody.Handle.Value, this)));
                    }

                    return;
                }
            }

            link.ProcessFrame(frame);
        }
Example #2
0
        private void OnReceiveLinkFrame(Frame frame)
        {
            AmqpLink     handle  = null;
            Performative command = frame.Command;

            if (command.DescriptorCode != Attach.Code)
            {
                LinkPerformative linkPerformative = (LinkPerformative)command;
                if (!this.linksByRemoteHandle.TryGetObject(linkPerformative.Handle.Value, out handle))
                {
                    if (this.Settings.IgnoreMissingLinks)
                    {
                        return;
                    }
                    if (linkPerformative.DescriptorCode != Detach.Code)
                    {
                        Error unattachedHandle = AmqpError.UnattachedHandle;
                        uint? nullable         = linkPerformative.Handle;
                        base.SafeClose(new AmqpException(unattachedHandle, SRAmqp.AmqpHandleNotFound(nullable.Value, this)));
                    }
                    return;
                }
            }
            else
            {
                Attach attach = (Attach)command;
                lock (base.ThisLock)
                {
                    this.links.TryGetValue(attach.LinkName, out handle);
                }
                if (handle != null)
                {
                    lock (base.ThisLock)
                    {
                        handle.RemoteHandle = attach.Handle;
                        this.linksByRemoteHandle.Add(attach.Handle.Value, handle);
                    }
                }
                else if (!this.TryCreateRemoteLink(attach, out handle))
                {
                    return;
                }
            }
            handle.ProcessFrame(frame);
        }
Example #3
0
        void OnReceiveLinkFrame(Frame frame)
        {
            AmqpLink     link    = null;
            Performative command = frame.Command;

            if (command.DescriptorCode == Attach.Code)
            {
                Attach attach = (Attach)command;
                lock (this.ThisLock)
                {
                    this.links.TryGetValue(attach.LinkName, out link);
                }

                if (link == null)
                {
                    if (!this.TryCreateRemoteLink(attach, out link))
                    {
                        return;
                    }
                }
                else
                {
                    lock (this.ThisLock)
                    {
                        link.RemoteHandle = attach.Handle;
                        this.linksByRemoteHandle.Add(attach.Handle.Value, link);
                    }
                }
            }
            else
            {
                LinkPerformative linkBody = (LinkPerformative)command;
                if (!this.linksByRemoteHandle.TryGetObject(linkBody.Handle.Value, out link))
                {
                    if (linkBody.DescriptorCode != Detach.Code)
                    {
                        this.TryClose(new AmqpException(AmqpError.UnattachedHandle));
                    }

                    return;
                }
            }

            try
            {
                if (command.DescriptorCode == Transfer.Code)
                {
                    // pre-process the transfer on the session
                    this.incomingChannel.OnReceiveTransfer(link, (Transfer)command);
                    this.diagnostics.ReceiveTransfer();
                }
                else
                {
                    link.ProcessFrame(frame);
                }
            }
            catch (AmqpException exception)
            {
                this.TryClose(new AmqpException(AmqpError.ErrantLink, exception));
            }
        }