예제 #1
0
        /// <inheritdoc/>
        public override void Fire()
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Firing a {0} event for session {1}", EventType, Session.Id);
            }

            switch (EventType)
            {
            case IoEventType.MessageReceived:
                _nextFilter.MessageReceived(Session, Parameter);
                break;

            case IoEventType.MessageSent:
                _nextFilter.MessageSent(Session, (IWriteRequest)Parameter);
                break;

            case IoEventType.Write:
                _nextFilter.FilterWrite(Session, (IWriteRequest)Parameter);
                break;

            case IoEventType.Close:
                _nextFilter.FilterClose(Session);
                break;

            case IoEventType.ExceptionCaught:
                _nextFilter.ExceptionCaught(Session, (Exception)Parameter);
                break;

            case IoEventType.SessionIdle:
                _nextFilter.SessionIdle(Session, (IdleStatus)Parameter);
                break;

            case IoEventType.SessionCreated:
                _nextFilter.SessionCreated(Session);
                break;

            case IoEventType.SessionOpened:
                _nextFilter.SessionOpened(Session);
                break;

            case IoEventType.SessionClosed:
                _nextFilter.SessionClosed(Session);
                break;

            default:
                throw new InvalidOperationException("Unknown event type: " + EventType);
            }

            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Event {0} has been fired for session {1}", EventType, Session.Id);
            }
        }
예제 #2
0
 /// <inheritdoc/>
 public virtual void ExceptionCaught(INextFilter nextFilter, IoSession session, Exception cause)
 {
     nextFilter.ExceptionCaught(session, cause);
 }
예제 #3
0
 public override void ExceptionCaught(INextFilter nextFilter, IoSession session, Exception cause)
 {
     test.testResult += id + "EC";
     nextFilter.ExceptionCaught(session, cause);
 }
예제 #4
0
 public override void ExceptionCaught(INextFilter nextFilter, IoSession session, Exception cause)
 {
     test.testResult += id + "EC";
     nextFilter.ExceptionCaught(session, cause);
 }
예제 #5
0
 /// <inheritdoc/>
 public virtual void ExceptionCaught(INextFilter nextFilter, IoSession session, Exception cause)
 {
     nextFilter.ExceptionCaught(session, cause);
 }
예제 #6
0
        /// <inheritdoc/>
        public override void MessageReceived(INextFilter nextFilter, IoSession session, Object message)
        {
            //if (log.IsDebugEnabled)
            //    log.DebugFormat("Processing a MESSAGE_RECEIVED for session {0}", session.Id);

            IoBuffer input = message as IoBuffer;

            if (input == null)
            {
                nextFilter.MessageReceived(session, message);
                return;
            }

            IProtocolDecoder       decoder       = _factory.GetDecoder(session);
            IProtocolDecoderOutput decoderOutput = GetDecoderOut(session, nextFilter);

            // Loop until we don't have anymore byte in the buffer,
            // or until the decoder throws an unrecoverable exception or
            // can't decoder a message, because there are not enough
            // data in the buffer
            while (input.HasRemaining)
            {
                Int32 oldPos = input.Position;
                try
                {
                    // TODO may not need lock on UDP
                    lock (session)
                    {
                        // Call the decoder with the read bytes
                        decoder.Decode(session, input, decoderOutput);
                    }

                    // Finish decoding if no exception was thrown.
                    decoderOutput.Flush(nextFilter, session);
                }
                catch (Exception ex)
                {
                    ProtocolDecoderException pde = ex as ProtocolDecoderException;
                    if (pde == null)
                    {
                        pde = new ProtocolDecoderException(null, ex);
                    }
                    if (pde.Hexdump == null)
                    {
                        // Generate a message hex dump
                        Int32 curPos = input.Position;
                        input.Position = oldPos;
                        pde.Hexdump    = input.GetHexDump();
                        input.Position = curPos;
                    }

                    decoderOutput.Flush(nextFilter, session);
                    nextFilter.ExceptionCaught(session, pde);

                    // Retry only if the type of the caught exception is
                    // recoverable and the buffer position has changed.
                    // We check buffer position additionally to prevent an
                    // infinite loop.
                    if (!(ex is RecoverableProtocolDecoderException) || input.Position == oldPos)
                    {
                        break;
                    }
                }
            }
        }
예제 #7
0
        /// <inheritdoc/>
        public override void MessageReceived(INextFilter nextFilter, IoSession session, Object message)
        {
            //if (log.IsDebugEnabled)
            //    log.DebugFormat("Processing a MESSAGE_RECEIVED for session {0}", session.Id);

            IoBuffer input = message as IoBuffer;
            if (input == null)
            {
                nextFilter.MessageReceived(session, message);
                return;
            }

            IProtocolDecoder decoder = _factory.GetDecoder(session);
            IProtocolDecoderOutput decoderOutput = GetDecoderOut(session, nextFilter);

            // Loop until we don't have anymore byte in the buffer,
            // or until the decoder throws an unrecoverable exception or
            // can't decoder a message, because there are not enough
            // data in the buffer
            while (input.HasRemaining)
            {
                Int32 oldPos = input.Position;
                try
                {
                    // TODO may not need lock on UDP
                    lock (session)
                    {
                        // Call the decoder with the read bytes
                        decoder.Decode(session, input, decoderOutput);
                    }

                    // Finish decoding if no exception was thrown.
                    decoderOutput.Flush(nextFilter, session);
                }
                catch (Exception ex)
                {
                    ProtocolDecoderException pde = ex as ProtocolDecoderException;
                    if (pde == null)
                        pde = new ProtocolDecoderException(null, ex);
                    if (pde.Hexdump == null)
                    {
                        // Generate a message hex dump
                        Int32 curPos = input.Position;
                        input.Position = oldPos;
                        pde.Hexdump = input.GetHexDump();
                        input.Position = curPos;
                    }

                    decoderOutput.Flush(nextFilter, session);
                    nextFilter.ExceptionCaught(session, pde);

                    // Retry only if the type of the caught exception is
                    // recoverable and the buffer position has changed.
                    // We check buffer position additionally to prevent an
                    // infinite loop.
                    if (!(ex is RecoverableProtocolDecoderException) || input.Position == oldPos)
                        break;
                }
            }
        }