Exemplo n.º 1
0
        /// <summary>
        /// Processes session and link frames.
        /// </summary>
        /// <param name="frame">The received frame.</param>
        public virtual void ProcessFrame(Frame frame)
        {
            Performative command = frame.Command;

            try
            {
                AmqpDebug.Log(this, false, command);

                if (command.DescriptorCode == Begin.Code)
                {
                    this.OnReceiveBegin((Begin)command);
                }
                else if (command.DescriptorCode == End.Code)
                {
                    this.OnReceiveEnd((End)command);
                }
                else if (command.DescriptorCode == Disposition.Code)
                {
                    this.OnReceiveDisposition((Disposition)command);
                }
                else if (command.DescriptorCode == Flow.Code)
                {
                    this.OnReceiveFlow((Flow)command);
                }
                else
                {
                    this.OnReceiveLinkFrame(frame);
                }
            }
            catch (Exception exception) when(!Fx.IsFatal(exception))
            {
                AmqpTrace.Provider.AmqpLogError(this, "ProcessFrame", exception);
                this.SafeClose(exception);
            }
        }
Exemplo n.º 2
0
 void HandleSaslCommand(Performative command)
 {
     if (command.DescriptorCode == SaslMechanisms.Code)
     {
         this.OnSaslServerMechanisms((SaslMechanisms)command);
     }
     else if (command.DescriptorCode == SaslInit.Code)
     {
         this.OnSaslInit((SaslInit)command);
     }
     else if (command.DescriptorCode == SaslChallenge.Code)
     {
         this.saslHandler.OnChallenge((SaslChallenge)command);
     }
     else if (command.DescriptorCode == SaslResponse.Code)
     {
         this.saslHandler.OnResponse((SaslResponse)command);
     }
     else if (command.DescriptorCode == SaslOutcome.Code)
     {
         this.OnSaslOutcome((SaslOutcome)command);
     }
     else
     {
         throw new AmqpException(AmqpErrorCode.NotAllowed, command.ToString());
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// For internal implementation only.
        /// </summary>
        public void SendCommand(Performative command, ushort channel, ByteBuffer payload)
        {
#if DEBUG
            Frame frame = new Frame();
            frame.Channel = channel;
            frame.Command = command;
            frame.Payload = payload.AsSegment();
            frame.Trace(true, this);
            AmqpTrace.Provider.AmqpLogOperationVerbose(this, TraceOperation.Send, frame);
#endif

            int frameSize;
            if (payload == null)
            {
                // The frame buffer is disposed when the write completes
                ByteBuffer buffer = Frame.EncodeCommand(FrameType.Amqp, channel, command, 0);
                frameSize = buffer.Length;
                this.SendBuffer(buffer);
            }
            else
            {
                // The frame buffer is disposed when the write completes
                ByteBuffer cmdBuffer = Frame.EncodeCommand(FrameType.Amqp, channel, command, payload.Length);
                frameSize = cmdBuffer.Length + payload.Length;
                this.SendBuffer(cmdBuffer, payload);
            }

            this.heartBeat.OnSend();
            if (this.UsageMeter != null)
            {
                this.UsageMeter.OnWrite(this, command == null ? 0 : command.DescriptorCode, frameSize);
            }
        }
Exemplo n.º 4
0
 void HandleSaslCommand(Performative command)
 {
     Utils.Trace(TraceLevel.Verbose, "{0}: Handle SASL command {1}", this.transport, command);
     if (command.DescriptorCode == SaslMechanisms.Code)
     {
         this.OnSaslServerMechanisms((SaslMechanisms)command);
     }
     else if (command.DescriptorCode == SaslInit.Code)
     {
         this.OnSaslInit((SaslInit)command);
     }
     else if (command.DescriptorCode == SaslChallenge.Code)
     {
         this.saslHandler.OnChallenge((SaslChallenge)command);
     }
     else if (command.DescriptorCode == SaslResponse.Code)
     {
         this.saslHandler.OnResponse((SaslResponse)command);
     }
     else if (command.DescriptorCode == SaslOutcome.Code)
     {
         this.OnSaslOutcome((SaslOutcome)command);
     }
     else
     {
         throw new AmqpException(AmqpError.NotAllowed, command.ToString());
     }
 }
Exemplo n.º 5
0
            public static void Log(object source, bool send, Performative command)
            {
                AmqpDebugImpl instance = AmqpDebugImpl.GetInstance(source);
                ulong         code     = command.DescriptorCode;
                uint          p1       = 0;
                uint          p2       = 0;

                if (code == Transfer.Code)
                {
                    Transfer transfer = (Transfer)command;
                    p1 = transfer.DeliveryId ?? 0;
                    p2 = transfer.Settled() ? 1u : 0u;
                }
                else if (code == Disposition.Code)
                {
                    Disposition disp = (Disposition)command;
                    p1 = disp.First ?? 0;
                    p2 = disp.Last ?? p1;
                }
                else if (code == Flow.Code)
                {
                    Flow flow = (Flow)command;
                    p1 = flow.IncomingWindow ?? 0;
                    p2 = flow.NextIncomingId ?? 0;
                    if (flow.Handle.HasValue)
                    {
                        instance.LogInternal(send, code, flow.DeliveryCount.Value, flow.LinkCredit.Value);
                    }
                }

                instance.LogInternal(send, code, p1, p2);
            }
Exemplo n.º 6
0
        public void WriteFrame(Performative command, bool needReply)
        {
            try
            {
#if DEBUG
                Frame frame = new Frame(FrameType.Sasl)
                {
                    Command = command
                };
                frame.Trace(true);
                AmqpTrace.Provider.AmqpLogOperationVerbose(this, TraceOperation.Send, frame);
#endif

                ByteBuffer buffer = Frame.EncodeCommand(FrameType.Sasl, 0, command, 0);
                TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();
                args.SetBuffer(buffer);
                args.CompletedCallback = onWriteFrameComplete;
                args.UserToken         = this;
                args.UserToken2        = needReply;
                this.writer.WriteBuffer(args);
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                this.HandleException("WriteFrame", exception);
            }
        }
Exemplo n.º 7
0
        public void ProcessFrame(Frame frame)
        {
            Performative command = frame.Command;

            try
            {
                if (command.DescriptorCode == Attach.Code)
                {
                    this.OnReceiveAttach((Attach)command);
                }
                else if (command.DescriptorCode == Detach.Code)
                {
                    this.OnReceiveDetach((Detach)command);
                }
                else if (command.DescriptorCode == Transfer.Code)
                {
                    // Transfer is called by incoming session directly
                    //this.OnReceiveTransfer((Transfer)command, frame.Payload);
                }
                else if (command.DescriptorCode == Flow.Code)
                {
                    this.OnReceiveFlow((Flow)command);
                }
                else
                {
                    throw new AmqpException(AmqpError.InvalidField, "descriptor-code");
                }
            }
            catch (AmqpException exception)
            {
                this.TryClose(exception);
                Utils.Trace(TraceLevel.Error, "{0}: Fault with exception: {1}", this, exception);
            }
        }
Exemplo n.º 8
0
        public void ProcessFrame(Frame frame)
        {
            Performative command = frame.Command;

            try
            {
                if (command.DescriptorCode == Attach.Code)
                {
                    this.OnReceiveAttach((Attach)command);
                }
                else if (command.DescriptorCode == Detach.Code)
                {
                    this.OnReceiveDetach((Detach)command);
                }
                else if (command.DescriptorCode == Transfer.Code)
                {
                    this.OnReceiveTransfer((Transfer)command, frame);
                }
                else if (command.DescriptorCode == Flow.Code)
                {
                    this.OnReceiveFlow((Flow)command);
                }
                else
                {
                    throw new AmqpException(AmqpErrorCode.InvalidField, AmqpResources.GetString(AmqpResources.AmqpInvalidPerformativeCode, command.DescriptorCode));
                }
            }
            catch (Exception exception) when(!Fx.IsFatal(exception))
            {
                AmqpTrace.Provider.AmqpLogError(this, nameof(ProcessFrame), exception.Message);
                this.SafeClose(exception);
            }
        }
Exemplo n.º 9
0
        public void SendCommand(Performative command, ushort channel, Action <object> callback, object state)
        {
            Frame frame = new Frame(FrameType.Amqp, channel, command);

            Utils.Trace(TraceLevel.Frame, "SEND  {0}", frame);
            this.AsyncIO.Writer.WriteBuffer(frame.Buffer, command.PayloadList, callback, state);
            this.active = true;
        }
Exemplo n.º 10
0
            void WriteCommand(Performative command)
            {
                Frame      frame      = new Frame(FrameType.Amqp, 0, command);
                ByteBuffer byteBuffer = ByteBuffer.Wrap(Frame.HeaderSize + command.EncodeSize);

                frame.Encode(byteBuffer);
                this.AsyncIO.Writer.WriteBuffer(frame.Buffer, command.PayloadList, null, null);
            }
Exemplo n.º 11
0
        protected void NotifyOpening(Performative command)
        {
            EventHandler <OpenEventArgs> eventHandler = this.Opening;

            if (eventHandler != null)
            {
                eventHandler(this, new OpenEventArgs(command));
            }
        }
Exemplo n.º 12
0
        protected void NotifyOpening(Performative command)
        {
            EventHandler <OpenEventArgs> opening = this.Opening;

            if (opening != null)
            {
                opening(this, new OpenEventArgs(command));
            }
        }
Exemplo n.º 13
0
        void OnReceiveSessionFrame(Frame frame)
        {
            AmqpSession  session = null;
            Performative command = frame.Command;
            ushort       channel = frame.Channel;

            if (command.DescriptorCode == Begin.Code)
            {
                Begin begin = (Begin)command;
                if (begin.RemoteChannel.HasValue)
                {
                    // reply to begin
                    lock (this.ThisLock)
                    {
                        if (!this.sessionsByLocalHandle.TryGetObject(begin.RemoteChannel.Value, out session))
                        {
                            throw new AmqpException(AmqpErrorCode.NotFound, AmqpResources.GetString(AmqpResources.AmqpChannelNotFound, begin.RemoteChannel.Value, this));
                        }

                        session.RemoteChannel = channel;
                        this.sessionsByRemoteHandle.Add(channel, session);
                    }
                }
                else
                {
                    // new begin request
                    AmqpSessionSettings settings = AmqpSessionSettings.Create(begin);
                    settings.RemoteChannel = channel;
                    session = this.SessionFactory.CreateSession(this, settings);
                    this.AddSession(session, channel);
                }
            }
            else
            {
                if (!this.sessionsByRemoteHandle.TryGetObject((uint)channel, out session))
                {
                    if (command.DescriptorCode == End.Code ||
                        command.DescriptorCode == Detach.Code ||
                        this.Settings.IgnoreMissingSessions)
                    {
                        // The session close may timed out already
                        AmqpTrace.Provider.AmqpMissingHandle(this, "session", channel);
                        return;
                    }

                    throw new AmqpException(AmqpErrorCode.NotFound, AmqpResources.GetString(AmqpResources.AmqpChannelNotFound, channel, this));
                }
                else if (command.DescriptorCode == End.Code)
                {
                    this.sessionsByRemoteHandle.Remove((uint)channel);
                    session.RemoteChannel = null;
                }
            }

            session.ProcessFrame(frame);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        public virtual void ProcessFrame(Frame frame)
        {
            Performative command = frame.Command;

            try
            {
                if (command.ValueBuffer != null)
                {
                    // Deferred link frames are decoded here
                    command.DecodeValue(command.ValueBuffer);
                    if (command.ValueBuffer.Length > 0)
                    {
                        command.Payload = command.ValueBuffer.Array;
                    }

                    command.ValueBuffer = null;
                    Utils.Trace(TraceLevel.Frame, "RECV  {0}", frame);
                }

                if (command.DescriptorCode == Begin.Code)
                {
                    this.OnReceiveBegin((Begin)command);
                }
                else if (command.DescriptorCode == End.Code)
                {
                    this.OnReceiveEnd((End)command);
                }
                else if (command.DescriptorCode == Disposition.Code)
                {
                    this.OnReceiveDisposition((Disposition)command);
                }
                else if (command.DescriptorCode == Flow.Code)
                {
                    this.OnReceiveFlow((Flow)command);
                }
                else
                {
                    this.OnReceiveLinkFrame(frame);
                }
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                Utils.Trace(TraceLevel.Error, "{0}: Fault with exception: {1}", this, exception);
                this.TryClose(exception);
            }
        }
Exemplo n.º 16
0
        private void OnReceiveSessionFrame(Frame frame)
        {
            AmqpSession  nullable = null;
            Performative command  = frame.Command;
            ushort       channel  = frame.Channel;

            if (command.DescriptorCode != Begin.Code)
            {
                if (!this.sessionsByRemoteHandle.TryGetObject(channel, out nullable))
                {
                    if (command.DescriptorCode != End.Code && command.DescriptorCode != Detach.Code && !base.Settings.IgnoreMissingSessions)
                    {
                        throw new AmqpException(AmqpError.NotFound, SRAmqp.AmqpChannelNotFound(channel, this));
                    }
                    return;
                }
                if (command.DescriptorCode == End.Code)
                {
                    this.sessionsByRemoteHandle.Remove(channel);
                    nullable.RemoteChannel = null;
                }
            }
            else
            {
                Begin begin = (Begin)command;
                if (!begin.RemoteChannel.HasValue)
                {
                    AmqpSessionSettings amqpSessionSetting = AmqpSessionSettings.Create(begin);
                    amqpSessionSetting.RemoteChannel = new ushort?(channel);
                    nullable = this.SessionFactory.CreateSession(this, amqpSessionSetting);
                    this.AddSession(nullable, new ushort?(channel));
                }
                else
                {
                    lock (base.ThisLock)
                    {
                        if (!this.sessionsByLocalHandle.TryGetObject(begin.RemoteChannel.Value, out nullable))
                        {
                            Error  notFound      = AmqpError.NotFound;
                            ushort?remoteChannel = begin.RemoteChannel;
                            throw new AmqpException(notFound, SRAmqp.AmqpChannelNotFound(remoteChannel.Value, this));
                        }
                        nullable.RemoteChannel = new ushort?(channel);
                        this.sessionsByRemoteHandle.Add(channel, nullable);
                    }
                }
            }
            nullable.ProcessFrame(frame);
        }
Exemplo n.º 17
0
        void OnReceiveSessionFrame(Frame frame)
        {
            AmqpSession  session = null;
            Performative command = frame.Command;
            ushort       channel = frame.Channel;

            if (command.DescriptorCode == Begin.Code)
            {
                Begin begin = (Begin)command;
                if (begin.RemoteChannel.HasValue)
                {
                    // reply to begin
                    lock (this.ThisLock)
                    {
                        if (!this.sessionsByLocalHandle.TryGetObject(begin.RemoteChannel.Value, out session))
                        {
                            throw new AmqpException(AmqpError.NotFound, SRClient.AmqpChannelNotFound(begin.RemoteChannel.Value));
                        }

                        session.RemoteChannel = channel;
                        this.sessionsByRemoteHandle.Add(channel, session);
                    }
                }
                else
                {
                    // new begin request
                    AmqpSessionSettings settings = AmqpSessionSettings.Create(begin);
                    settings.RemoteChannel = channel;
                    session = this.SessionFactory.CreateSession(this, settings);
                    this.AddSession(session, channel);
                }
            }
            else
            {
                if (!this.sessionsByRemoteHandle.TryGetObject((uint)channel, out session))
                {
                    if (frame.Command.DescriptorCode == End.Code ||
                        frame.Command.DescriptorCode == Detach.Code)
                    {
                        return;
                    }

                    throw new AmqpException(AmqpError.NotFound, SRClient.AmqpChannelNotFound((uint)channel));
                }
            }

            session.ProcessFrame(frame);
        }
Exemplo n.º 18
0
        private void ProcessFrame(Frame frame)
        {
            Performative command = frame.Command;

            if (command.DescriptorCode == Open.Code)
            {
                this.OnReceiveOpen((Open)frame.Command);
                return;
            }
            if (command.DescriptorCode != Close.Code)
            {
                this.OnReceiveSessionFrame(frame);
                return;
            }
            this.OnReceiveClose((Close)frame.Command);
        }
Exemplo n.º 19
0
        public void WriteFrame(Performative command, bool needReply)
        {
            try
            {
                Frame frame = new Frame(FrameType.Sasl, 0, command);

                TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs();
                args.SetBuffer(frame.Buffer);
                args.CompletedCallback = this.onWriteFrameComplete;
                args.UserToken         = needReply;
                this.writer.WriteBuffer(args);
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
Exemplo n.º 20
0
        public void Message(Performative p, string senderId, string receiverId, string content)
        {
            switch (p)
            {
            case Performative.Inform:
                ThreadPool.QueueUserWorkItem(delegate { Communication.Send(senderId, receiverId, "inform[content:" + content + ";]"); });
                break;

            case Performative.Cfp:
                ThreadPool.QueueUserWorkItem(delegate { Communication.Send(senderId, receiverId, "cfp[content:" + content + ";]"); });
                break;

            case Performative.Proposal:
                ThreadPool.QueueUserWorkItem(delegate { Communication.Send(senderId, receiverId, "proposal[from:" + senderId + ";content:" + content + "]"); });
                break;
            }
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
0
        void ProcessFrame(Frame frame)
        {
            Performative command = frame.Command;

            Fx.Assert(command != null, "Must have a valid command");

            if (command.DescriptorCode == OpenCommand.Code)
            {
                this.OnReceiveOpen((Open)frame.Command);
            }
            else if (command.DescriptorCode == CloseCommand.Code)
            {
                this.OnReceiveClose((Close)frame.Command);
            }
            else
            {
                this.OnReceiveSessionFrame(frame);
            }
        }
Exemplo n.º 23
0
        public void SendCommand(Performative command, ushort channel, ArraySegment <byte>[] payload)
        {
            if (payload == null)
            {
                base.SendBuffer(Frame.EncodeCommand(FrameType.Amqp, channel, command, 0));
                return;
            }
            ByteBuffer[] byteBuffer = new ByteBuffer[1 + (int)payload.Length];
            int          count      = 0;

            for (int i = 0; i < (int)payload.Length; i++)
            {
                ArraySegment <byte> nums = payload[i];
                count             = count + nums.Count;
                byteBuffer[i + 1] = new ByteBuffer(nums);
            }
            byteBuffer[0] = Frame.EncodeCommand(FrameType.Amqp, channel, command, count);
            base.SendBuffers(byteBuffer);
        }
Exemplo n.º 24
0
        public void SendCommand(Performative command, ushort channel, ArraySegment <byte>[] payload)
        {
#if DEBUG
            Frame frame = new Frame();
            frame.Channel = channel;
            frame.Command = command;
            frame.Trace(true, this, channel, command, -1);
            AmqpTrace.Provider.AmqpLogOperationVerbose(this, TraceOperation.Send, frame);
#endif

            int frameSize = 0;
            if (payload == null)
            {
                // The frame buffer is disposed when the write completes
                ByteBuffer buffer = Frame.EncodeCommand(FrameType.Amqp, channel, command, 0);
                frameSize = buffer.Length;
                this.SendBuffer(buffer);
            }
            else
            {
                ByteBuffer[] buffers     = new ByteBuffer[1 + payload.Length];
                int          payloadSize = 0;
                for (int i = 0; i < payload.Length; ++i)
                {
                    ArraySegment <byte> segment = payload[i];
                    payloadSize   += segment.Count;
                    buffers[i + 1] = new ByteBuffer(segment);
                }

                // The frame buffer is disposed when the write completes
                ByteBuffer cmdBuffer = Frame.EncodeCommand(FrameType.Amqp, channel, command, payloadSize);
                frameSize  = cmdBuffer.Length + payloadSize;
                buffers[0] = cmdBuffer;
                this.SendBuffers(buffers);
            }

            this.heartBeat.OnSend();
            if (this.UsageMeter != null)
            {
                this.UsageMeter.OnWrite(this, command == null ? 0 : command.DescriptorCode, frameSize);
            }
        }
Exemplo n.º 25
0
 public void WriteFrame(Performative command, bool needReply)
 {
     try
     {
         ByteBuffer byteBuffer = Frame.EncodeCommand(FrameType.Sasl, 0, command, 0);
         TransportAsyncCallbackArgs transportAsyncCallbackArg = new TransportAsyncCallbackArgs();
         transportAsyncCallbackArg.SetBuffer(byteBuffer);
         transportAsyncCallbackArg.CompletedCallback = SaslNegotiator.onWriteFrameComplete;
         transportAsyncCallbackArg.UserToken         = this;
         transportAsyncCallbackArg.UserToken2        = needReply;
         this.writer.WriteBuffer(transportAsyncCallbackArg);
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         if (Fx.IsFatal(exception))
         {
             throw;
         }
         this.HandleException("WriteFrame", exception);
     }
 }
Exemplo n.º 26
0
        void SendCommand(Performative command, Action <object> callback, object state)
        {
            this.connection.SendCommand(command, this.LocalChannel, callback, state);
            Utils.Trace(TraceLevel.Debug, "{0}: Sent command {1}", this, command);

            if (command.DescriptorCode == Disposition.Code)
            {
                this.diagnostics.SendDisposition();

                Disposition disposition = (Disposition)command;
                this.diagnostics.SetLastDisposition(disposition.Last == null ? disposition.First.Value : disposition.Last.Value);
                Utils.Trace(TraceLevel.Verbose, "{0}: Dispose {1}-{2}, settled:{3}, outcome:{4}.", this, disposition.First.Value, disposition.Last, disposition.Settled, disposition.State.DescriptorName.Value);
            }
            else if (command.DescriptorCode == Flow.Code)
            {
                this.diagnostics.SendFlow();
            }
            else if (command.DescriptorCode == Transfer.Code)
            {
                this.diagnostics.SendTransfer();
            }
        }
Exemplo n.º 27
0
        public virtual void ProcessFrame(Frame frame)
        {
            Performative command = frame.Command;

            try
            {
                if (command.DescriptorCode == Begin.Code)
                {
                    this.OnReceiveBegin((Begin)command);
                }
                else if (command.DescriptorCode == End.Code)
                {
                    this.OnReceiveEnd((End)command);
                }
                else if (command.DescriptorCode == Disposition.Code)
                {
                    this.OnReceiveDisposition((Disposition)command);
                }
                else if (command.DescriptorCode != Flow.Code)
                {
                    this.OnReceiveLinkFrame(frame);
                }
                else
                {
                    this.OnReceiveFlow((Flow)command);
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                MessagingClientEtwProvider.TraceClient <AmqpSession, Exception>((AmqpSession source, Exception ex) => MessagingClientEtwProvider.Provider.EventWriteAmqpLogError(source, "ProcessFrame", ex.Message), this, exception);
                base.SafeClose(exception);
            }
        }
Exemplo n.º 28
0
        public void ProcessFrame(Frame frame)
        {
            Performative command = frame.Command;

            try
            {
                if (command.DescriptorCode == Attach.Code)
                {
                    this.OnReceiveAttach((Attach)command);
                }
                else if (command.DescriptorCode == Detach.Code)
                {
                    this.OnReceiveDetach((Detach)command);
                }
                else if (command.DescriptorCode != Transfer.Code)
                {
                    if (command.DescriptorCode != Flow.Code)
                    {
                        throw new AmqpException(AmqpError.InvalidField, SRAmqp.AmqpInvalidPerformativeCode(command.DescriptorCode));
                    }
                    this.OnReceiveFlow((Flow)command);
                }
                else
                {
                    this.OnReceiveTransfer((Transfer)command, frame);
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                MessagingClientEtwProvider.TraceClient <AmqpLink, Exception>((AmqpLink source, Exception ex) => MessagingClientEtwProvider.Provider.EventWriteAmqpLogError(source, "ProcessFrame", ex.Message), this, exception);
                base.SafeClose(exception);
            }
        }
Exemplo n.º 29
0
 public static void Trace(this object target, bool send, AmqpConnection connection, ushort channel, Performative performative, int payload)
 {
     if (AmqpDebug)
     {
         if (PerformativeTraceCallback != null)
         {
             PerformativeTraceCallback(send, connection, channel, performative, payload);
         }
         else
         {
             Trace(target, send);
         }
     }
 }
Exemplo n.º 30
0
 public OpenEventArgs(Performative command)
 {
     this.command = command;
 }