当前位置: 首页>>代码示例>>C#>>正文


C# INextFilter.FilterWrite方法代码示例

本文整理汇总了C#中INextFilter.FilterWrite方法的典型用法代码示例。如果您正苦于以下问题:C# INextFilter.FilterWrite方法的具体用法?C# INextFilter.FilterWrite怎么用?C# INextFilter.FilterWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在INextFilter的用法示例。


在下文中一共展示了INextFilter.FilterWrite方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FilterWrite

        /// <inheritdoc/>
        public override void FilterWrite(INextFilter nextFilter, IoSession session, IWriteRequest writeRequest)
        {
            IoEvent ioe = new IoEvent(IoEventType.Write, session, writeRequest);
            if (_queueHandler.Accept(this, ioe))
            {
                nextFilter.FilterWrite(session, writeRequest);
                IWriteFuture writeFuture = writeRequest.Future;
                if (writeFuture == null)
                    return;

                // We can track the write request only when it has a future.
                _queueHandler.Offered(this, ioe);
                writeFuture.Complete += (s, e) => _queueHandler.Polled(this, ioe);
            }
        }
开发者ID:ettele,项目名称:Mina.NET,代码行数:16,代码来源:WriteRequestFilter.cs

示例2: FilterWrite

        /// <inheritdoc/>
        public override void FilterWrite(INextFilter nextFilter, IoSession session, IWriteRequest writeRequest)
        {
            if (_manipulateWrites)
            {
                // manipulate bytes
                IoBuffer buf = writeRequest.Message as IoBuffer;
                if (buf != null)
                {
                    ManipulateIoBuffer(session, buf);
                    IoBuffer buffer = InsertBytesToNewIoBuffer(session, buf);
                    if (buffer != null)
                    {
                        writeRequest = new DefaultWriteRequest(buffer, writeRequest.Future);
                    }
                    // manipulate PDU
                }
                else
                {
                    if (_duplicatePduProbability > _rng.Next())
                    {
                        nextFilter.FilterWrite(session, writeRequest);
                    }

                    if (_resendPduLasterProbability > _rng.Next())
                    {
                        // store it somewhere and trigger a write execution for
                        // later
                        // TODO
                    }
                    if (_removePduProbability > _rng.Next())
                    {
                        return;
                    }
                }
            }

            base.FilterWrite(nextFilter, session, writeRequest);
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:39,代码来源:ErrorGeneratingFilter.cs

示例3: FilterWrite

 /// <inheritdoc/>
 public virtual void FilterWrite(INextFilter nextFilter, IoSession session, IWriteRequest writeRequest)
 {
     nextFilter.FilterWrite(session, writeRequest);
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:5,代码来源:IoFilterAdapter.cs

示例4: SessionIdle

        /// <inheritdoc/>
        public override void SessionIdle(INextFilter nextFilter, IoSession session, IdleStatus status)
        {
            if (status == _interestedIdleStatus)
            {
                if (!session.ContainsAttribute(WAITING_FOR_RESPONSE))
                {
                    Object pingMessage = _messageFactory.GetRequest(session);
                    if (pingMessage != null)
                    {
                        nextFilter.FilterWrite(session, new DefaultWriteRequest(pingMessage));
                        //session.Write(pingMessage);

                        // If policy is OFF, there's no need to wait for
                        // the response.
                        if (_requestTimeoutHandler != KeepAliveRequestTimeoutHandler.DeafSpeaker)
                        {
                            MarkStatus(session);
                            if (_interestedIdleStatus == IdleStatus.BothIdle)
                            {
                                session.SetAttribute(IGNORE_READER_IDLE_ONCE);
                            }
                        }
                        else
                        {
                            ResetStatus(session);
                        }
                    }
                }
                else
                {
                    HandlePingTimeout(session);
                }
            }
            else if (status == IdleStatus.ReaderIdle)
            {
                if (session.RemoveAttribute(IGNORE_READER_IDLE_ONCE) == null)
                {
                    if (session.ContainsAttribute(WAITING_FOR_RESPONSE))
                    {
                        HandlePingTimeout(session);
                    }
                }
            }

            if (_forwardEvent)
                nextFilter.SessionIdle(session, status);
        }
开发者ID:zesus19,项目名称:c5.v1,代码行数:48,代码来源:KeepAliveFilter.cs

示例5: MessageReceived

        /// <inheritdoc/>
        public override void MessageReceived(INextFilter nextFilter, IoSession session, Object message)
        {
            try
            {
                if (_messageFactory.IsRequest(session, message))
                {
                    Object pongMessage = _messageFactory.GetResponse(session, message);

                    if (pongMessage != null)
                        nextFilter.FilterWrite(session, new DefaultWriteRequest(pongMessage));
                }

                if (_messageFactory.IsResponse(session, message))
                    ResetStatus(session);
            }
            finally
            {
                if (!IsKeepAliveMessage(session, message))
                    nextFilter.MessageReceived(session, message);
            }
        }
开发者ID:zesus19,项目名称:c5.v1,代码行数:22,代码来源:KeepAliveFilter.cs

示例6: FilterWrite

 public override void FilterWrite(INextFilter nextFilter, IoSession session, IWriteRequest writeRequest)
 {
     test.testResult += id + "FW";
     nextFilter.FilterWrite(session, writeRequest);
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:5,代码来源:IoFilterChainTest.cs

示例7: InternalFlush

 private void InternalFlush(INextFilter nextFilter, IoSession session, IoBuffer buf)
 {
     IoBuffer tmp = null;
     lock (buf)
     {
         buf.Flip();
         tmp = buf.Duplicate();
         buf.Clear();
     }
     if (log.IsDebugEnabled)
         log.Debug("Flushing buffer: " + tmp);
     nextFilter.FilterWrite(session, new DefaultWriteRequest(tmp));
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:13,代码来源:BufferedWriteFilter.cs

示例8: FilterWrite

        /// <inheritdoc/>
        public override void FilterWrite(INextFilter nextFilter, IoSession session, IWriteRequest writeRequest)
        {
            Object message = writeRequest.Message;

            // Bypass the encoding if the message is contained in a IoBuffer,
            // as it has already been encoded before
            if (message is IoBuffer || message is IFileRegion)
            {
                nextFilter.FilterWrite(session, writeRequest);
                return;
            }

            // Get the encoder in the session
            IProtocolEncoder encoder = _factory.GetEncoder(session);
            IProtocolEncoderOutput encoderOut = GetEncoderOut(session, nextFilter, writeRequest);

            if (encoder == null)
                throw new ProtocolEncoderException("The encoder is null for the session " + session);
            if (encoderOut == null)
                throw new ProtocolEncoderException("The encoderOut is null for the session " + session);

            try
            {
                encoder.Encode(session, message, encoderOut);
                AbstractProtocolEncoderOutput ape = encoderOut as AbstractProtocolEncoderOutput;
                if (ape != null)
                {
                    // Send it directly
                    IQueue<Object> bufferQueue = ape.MessageQueue;
                    // Write all the encoded messages now
                    while (!bufferQueue.IsEmpty)
                    {
                        Object encodedMessage = bufferQueue.Dequeue();

                        if (encodedMessage == null)
                            break;

                        // Flush only when the buffer has remaining.
                        IoBuffer buf = encodedMessage as IoBuffer;
                        if (buf == null || buf.HasRemaining)
                        {
                            IWriteRequest encodedWriteRequest = new EncodedWriteRequest(encodedMessage, null, writeRequest.Destination);
                            nextFilter.FilterWrite(session, encodedWriteRequest);
                        }
                    }
                }

                // Call the next filter
                nextFilter.FilterWrite(session, new MessageWriteRequest(writeRequest));
            }
            catch (Exception ex)
            {
                ProtocolEncoderException pee = ex as ProtocolEncoderException;
                if (pee == null)
                    pee = new ProtocolEncoderException(null, ex);
                throw pee;
            }
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:59,代码来源:ProtocolCodecFilter.cs

示例9: MessageReceived

 public override void MessageReceived(INextFilter nextFilter, IoSession session, object message)
 {
     using (var scope = ObjectHost.Host.BeginLifetimeScope())
     {
         var commandMessage = message as DuplexMessage;
         if (commandMessage != null)
         {
             if (commandMessage.Header.CommandCode == CommandCode.Authentication)
             {
                 var school = metaRepository
                     .GetAllSchools()
                     .ByIdentifier(commandMessage.Header.Identifier);
                 if (school != null && school.UniqueToken.Equals(
                     commandMessage.GetContent<AuthInfo>().Mac, StringComparison.OrdinalIgnoreCase))
                 {
                     session.SetAttributeIfAbsent(KeyName.SESSION_IDENTIFIER, commandMessage.Header.Identifier);
                     identifierManager.SetSessonIdentifier(commandMessage.Header.Identifier, session);
                     nextFilter.FilterWrite(session,
                         new DefaultWriteRequest(
                             DuplexMessage.CreateCallbackMessage(commandMessage)));
                 }
                 else
                 {
                     nextFilter.FilterWrite(session, 
                         new DefaultWriteRequest(
                             DuplexMessage.CreateAckMessage(commandMessage, ErrorCode.AuthenticationFailed)));
                 }
             }
             else if (
                 commandMessage.Header.CommandCode == CommandCode.Register ||
                 commandMessage.Header.CommandCode == CommandCode.Heartbeat)
             {
                 nextFilter.MessageReceived(session, message);
             }
             else
             {
                 if (!session.ContainsAttribute(KeyName.SESSION_IDENTIFIER))
                 {
                     nextFilter.FilterWrite(session, new DefaultWriteRequest(
                         DuplexMessage.CreateAckMessage(commandMessage, ErrorCode.UnauthorizedCommand)));
                 }
                 else
                 {
                     var identifier = session.GetAttribute<string>(KeyName.SESSION_IDENTIFIER);
                     if (identifier.Equals(commandMessage.Header.Identifier))
                         nextFilter.MessageReceived(session, message);
                     else
                     {
                         nextFilter.FilterWrite(session, new DefaultWriteRequest(
                             DuplexMessage.CreateAckMessage(commandMessage, ErrorCode.UnauthorizedCommand)));
                     }
                 }
                 
             }
         }
         else
         {
             nextFilter.FilterWrite(session, new DefaultWriteRequest(
                 DuplexMessage.CreateAckMessage(
                     Guid.NewGuid().ToByteArray().ToBase64(), 
                     MessageVersion.V1, 
                     CommandCode.UnAssigned, 
                     ErrorCode.IllegalCommandRequest)));
         }
     }
 }
开发者ID:zesus19,项目名称:c5.v1,代码行数:66,代码来源:AuthenticationValidationFilter.cs


注:本文中的INextFilter.FilterWrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。