GetReader() 공개 메소드

public GetReader ( ) : RabbitMQ.Util.NetworkBinaryReader
리턴 RabbitMQ.Util.NetworkBinaryReader
예제 #1
0
        public Command HandleFrame(Frame f)
        {
            switch (m_state)
            {
            case AssemblyState.ExpectingMethod:
            {
                if (f.Type != Constants.FrameMethod)
                {
                    throw new UnexpectedFrameException(f);
                }
                m_command.Method = m_protocol.DecodeMethodFrom(f.GetReader());
                m_state          = m_command.Method.HasContent
                        ? AssemblyState.ExpectingContentHeader
                        : AssemblyState.Complete;
                return(CompletedCommand());
            }

            case AssemblyState.ExpectingContentHeader:
            {
                if (f.Type != Constants.FrameHeader)
                {
                    throw new UnexpectedFrameException(f);
                }
                NetworkBinaryReader reader = f.GetReader();
                m_command.Header     = m_protocol.DecodeContentHeaderFrom(reader);
                m_remainingBodyBytes = m_command.Header.ReadFrom(reader);
                UpdateContentBodyState();
                return(CompletedCommand());
            }

            case AssemblyState.ExpectingContentBody:
            {
                if (f.Type != Constants.FrameBody)
                {
                    throw new UnexpectedFrameException(f);
                }
                byte[] fragment = f.Payload;
                m_command.AppendBodyFragment(fragment);
                if ((ulong)fragment.Length > m_remainingBodyBytes)
                {
                    throw new MalformedFrameException
                              (string.Format("Overlong content body received - {0} bytes remaining, {1} bytes received",
                                             m_remainingBodyBytes,
                                             fragment.Length));
                }
                m_remainingBodyBytes -= (ulong)fragment.Length;
                UpdateContentBodyState();
                return(CompletedCommand());
            }

            case AssemblyState.Complete:
            default:
#if NETFX_CORE
                Debug.WriteLine("Received frame in invalid state {0}; {1}", m_state, f);
#else
                Trace.Fail(string.Format("Received frame in invalid state {0}; {1}", m_state, f));
#endif
                return(null);
            }
        }
        public override void HandleFrame(Frame frame)
        {
            if (frame.Type == Constants.FrameMethod)
            {
                MethodBase method = Connection.Protocol.DecodeMethodFrom(frame.GetReader());
                if ((method.ProtocolClassId == ChannelCloseOk.ClassId)
                    && (method.ProtocolMethodId == ChannelCloseOk.MethodId))
                {
                    // This is the reply we were looking for. Release
                    // the channel with the reason we were passed in
                    // our constructor.
                    Close(m_reason);
                }
                else if ((method.ProtocolClassId == ChannelClose.ClassId)
                         && (method.ProtocolMethodId == ChannelClose.MethodId))
                {
                    // We're already shutting down the channel, so
                    // just send back an ok.
                    Transmit(CreateChannelCloseOk());
                }
            }

            // Either a non-method frame, or not what we were looking
            // for. Ignore it - we're quiescing.
        }
예제 #3
0
        public override void HandleFrame(Frame frame)
        {
            lock (_closingLock)
            {
                if (!m_closing)
                {
                    base.HandleFrame(frame);
                    return;
                }
            }

            if (!m_closeServerInitiated && (frame.Type == Constants.FrameMethod))
            {
                MethodBase method = Connection.Protocol.DecodeMethodFrom(frame.GetReader());
                if ((method.ProtocolClassId == m_closeClassId) &&
                    (method.ProtocolMethodId == m_closeMethodId))
                {
                    base.HandleFrame(frame);
                    return;
                }

                if ((method.ProtocolClassId == m_closeOkClassId) &&
                    (method.ProtocolMethodId == m_closeOkMethodId))
                {
                    // This is the reply (CloseOk) we were looking for
                    // Call any listener attached to this session
                    Handler();
                }
            }

            // Either a non-method frame, or not what we were looking
            // for. Ignore it - we're quiescing.
        }
예제 #4
0
        public override void HandleFrame(Frame frame)
        {
            if (frame.Type == Constants.FrameMethod)
            {
                MethodBase method = Connection.Protocol.DecodeMethodFrom(frame.GetReader());
                if ((method.ProtocolClassId == ChannelCloseOk.ClassId) &&
                    (method.ProtocolMethodId == ChannelCloseOk.MethodId))
                {
                    // This is the reply we were looking for. Release
                    // the channel with the reason we were passed in
                    // our constructor.
                    Close(m_reason);
                }
                else if ((method.ProtocolClassId == ChannelClose.ClassId) &&
                         (method.ProtocolMethodId == ChannelClose.MethodId))
                {
                    // We're already shutting down the channel, so
                    // just send back an ok.
                    Transmit(CreateChannelCloseOk());
                }
            }

            // Either a non-method frame, or not what we were looking
            // for. Ignore it - we're quiescing.
        }
        public Command HandleFrame(Frame f)
        {
            switch (m_state)
            {
                case AssemblyState.ExpectingMethod:
                {
                    if (f.Type != Constants.FrameMethod)
                    {
                        throw new UnexpectedFrameException(f);
                    }
                    m_command.Method = m_protocol.DecodeMethodFrom(f.GetReader());
                    m_state = m_command.Method.HasContent
                        ? AssemblyState.ExpectingContentHeader
                        : AssemblyState.Complete;
                    return CompletedCommand();
                }
                case AssemblyState.ExpectingContentHeader:
                {
                    if (f.Type != Constants.FrameHeader)
                    {
                        throw new UnexpectedFrameException(f);
                    }
                    NetworkBinaryReader reader = f.GetReader();
                    m_command.Header = m_protocol.DecodeContentHeaderFrom(reader);
                    m_remainingBodyBytes = m_command.Header.ReadFrom(reader);
                    UpdateContentBodyState();
                    return CompletedCommand();
                }
                case AssemblyState.ExpectingContentBody:
                {
                    if (f.Type != Constants.FrameBody)
                    {
                        throw new UnexpectedFrameException(f);
                    }
                    byte[] fragment = f.Payload;
                    m_command.AppendBodyFragment(fragment);
                    if ((ulong)fragment.Length > m_remainingBodyBytes)
                    {
                        throw new MalformedFrameException
                            (string.Format("Overlong content body received - {0} bytes remaining, {1} bytes received",
                                m_remainingBodyBytes,
                                fragment.Length));
                    }
                    m_remainingBodyBytes -= (ulong)fragment.Length;
                    UpdateContentBodyState();
                    return CompletedCommand();
                }
                case AssemblyState.Complete:
                default:
#if NETFX_CORE
                    Debug.WriteLine("Received frame in invalid state {0}; {1}", m_state, f);
#else
                    Trace.Fail(string.Format("Received frame in invalid state {0}; {1}", m_state, f));
#endif
                    return null;
            }
        }
예제 #6
0
        public override void HandleFrame(Frame frame)
        {
            if (frame.Type == CommonFraming.Constants.FrameMethod)
            {
                MethodBase method = Connection.Protocol.DecodeMethodFrom(frame.GetReader());
                if ((method.ProtocolClassId == m_replyClassId) &&
                    (method.ProtocolMethodId == m_replyMethodId))
                {
                    // This is the reply we were looking for. Release
                    // the channel with the reason we were passed in
                    // our constructor.
                    Close(m_reason);
                    return;
                }
            }

            // Either a non-method frame, or not what we were looking
            // for. Ignore it - we're quiescing.
        }
예제 #7
0
        public override void HandleFrame(Frame frame)
        {
        
            lock(m_closingLock)
            {
                if (!m_closing)
                {
                    base.HandleFrame(frame);
                    return;
                }
            } 
            
            if (!m_closeServerInitiated
                && (frame.Type == CommonFraming.Constants.FrameMethod))
            {
                MethodBase method = Connection.Protocol.DecodeMethodFrom(frame.GetReader());
                if ((method.ProtocolClassId == m_closeClassId)
                    && (method.ProtocolMethodId == m_closeMethodId))
                {
                    base.HandleFrame(frame);
                    return;
                }
                
                if ((method.ProtocolClassId == m_closeOkClassId)
                    && (method.ProtocolMethodId == m_closeOkMethodId))
                {
                    // This is the reply (CloseOk) we were looking for
                    // Call any listener attached to this session
                    this.Handler();
                    return;
                }
            }

            // Either a non-method frame, or not what we were looking
            // for. Ignore it - we're quiescing.
        }
        public override void HandleFrame(Frame frame)
        {
            if (frame.Type == CommonFraming.Constants.FrameMethod) {
                MethodBase method = Connection.Protocol.DecodeMethodFrom(frame.GetReader());
                if ((method.ProtocolClassId == m_replyClassId)
                    && (method.ProtocolMethodId == m_replyMethodId))
                {
                    // This is the reply we were looking for. Release
                    // the channel with the reason we were passed in
                    // our constructor.
                    Close(m_reason);
                    return;
                }
            }

            // Either a non-method frame, or not what we were looking
            // for. Ignore it - we're quiescing.
        }