Esempio n. 1
0
            protected override void run(ChannelHandlerContext ctx)
            {
                long nextDelay = idleStateHandler.readerIdleTimeNanos;

                if (!idleStateHandler.reading)
                {
                    nextDelay -= idleStateHandler.ticksInNanos() - idleStateHandler.lastReadTime;
                }

                if (nextDelay <= 0)
                {
                    // Reader is idle - set a new timeout and notify the callback.
                    idleStateHandler.readerTimer.Change(idleStateHandler.getReaderIdleTimeInMillis(), Timeout.Infinite);

                    bool first = idleStateHandler.firstReaderIdleEvent;
                    idleStateHandler.firstReaderIdleEvent = false;

                    try
                    {
                        IdleStateEvent _event = idleStateHandler.newIdleStateEvent(IdleState.READER_IDLE, first);
                        idleStateHandler.channelIdle(ctx, _event);
                    }
                    catch (Exception t)
                    {
                        ctx.fireExceptionCaught(t);
                    }
                }
                else
                {
                    // Read occurred before the timeout - set a new timeout with shorter delay.
                    idleStateHandler.readerTimer.Change(TimeUnit.NANOSECONDS.toMillis(nextDelay), Timeout.Infinite);
                }
            }
Esempio n. 2
0
            protected override void run(ChannelHandlerContext ctx)
            {
                long lastWriteTime = idleStateHandler.lastWriteTime;
                long nextDelay     = idleStateHandler.writerIdleTimeNanos - (idleStateHandler.ticksInNanos() - idleStateHandler.lastWriteTime);

                if (nextDelay <= 0)
                {
                    // Writer is idle - set a new timeout and notify the callback.
                    idleStateHandler.writerTimer.Change(idleStateHandler.getWriterIdleTimeInMillis(), Timeout.Infinite);

                    bool first = idleStateHandler.firstWriterIdleEvent;
                    idleStateHandler.firstWriterIdleEvent = false;

                    try
                    {
//                      if (idleStateHandler.hasOutputChanged(ctx, first))
//                      {
//                          return;
//                      }

                        IdleStateEvent _event = idleStateHandler.newIdleStateEvent(IdleState.WRITER_IDLE, first);
                        idleStateHandler.channelIdle(ctx, _event);
                    }
                    catch (Exception t)
                    {
                        ctx.fireExceptionCaught(t);
                    }
                }
                else
                {
                    // Write occurred before the timeout - set a new timeout with shorter delay.
                    idleStateHandler.writerTimer.Change(TimeUnit.NANOSECONDS.toMillis(nextDelay), Timeout.Infinite);
                }
            }
Esempio n. 3
0
            protected override void run(ChannelHandlerContext ctx)
            {
                long nextDelay = idleStateHandler.allIdleTimeNanos;

                if (!idleStateHandler.reading)
                {
                    nextDelay -= idleStateHandler.ticksInNanos() - Math.Max(idleStateHandler.lastReadTime, idleStateHandler.lastWriteTime);
                }

                if (nextDelay <= 0)
                {
                    // Both reader and writer are idle - set a new timeout and
                    // notify the callback.
                    idleStateHandler.allTimer.Change(idleStateHandler.getAllIdleTimeInMillis(), Timeout.Infinite);

                    bool first = idleStateHandler.firstAllIdleEvent;
                    idleStateHandler.firstAllIdleEvent = false;

                    try
                    {
//                      if (idleStateHandler.hasOutputChanged(ctx, first))
//                      {
//                          return;
//                      }

                        IdleStateEvent _event = idleStateHandler.newIdleStateEvent(IdleState.ALL_IDLE, first);
                        idleStateHandler.channelIdle(ctx, _event);
                    }
                    catch (Exception t)
                    {
                        ctx.fireExceptionCaught(t);
                    }
                }
                else
                {
                    // Either read or write occurred before the timeout - set a new
                    // timeout with shorter delay.
                    idleStateHandler.allTimer.Change(TimeUnit.NANOSECONDS.toMillis(nextDelay), Timeout.Infinite);
                }
            }
Esempio n. 4
0
 protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt)
 {
     ctx.fireUserEventTriggered(evt);
 }