|
|||||||||
| 上一个类 下一个类 | 框架 无框架 | ||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | ||||||||
java.lang.Objectorg.jboss.netty.channel.SimpleChannelUpstreamHandler
org.jboss.netty.handler.timeout.ReadTimeoutHandler
public class ReadTimeoutHandler

当在一定的时间周期内没有数据被读取则抛出ReadTimeoutException.
public class MyPipelineFactory implements当ChannelPipelineFactory{ private finalTimertimer; public MyPipelineFactory(Timertimer) { this.timer = timer; } publicChannelPipelinegetPipeline() { // 该例子配置30秒读取超时: returnChannels.pipeline( newReadTimeoutHandler(timer, 30), // timer必须是共享的. new MyHandler()); } }ServerBootstrapbootstrap = ...;Timertimer = newHashedWheelTimer(); ... bootstrap.setPipelineFactory(new MyPipelineFactory(timer)); ...
ReadTimeoutHandler被创建时Timer会被指定.当你的应用程序关闭,需要手工调用
releaseExternalResources()或Timer.stop()关闭.
WriteTimeoutHandler,
IdleStateHandler| 嵌套类摘要 |
|---|
| 从接口 org.jboss.netty.channel.ChannelHandler 继承的嵌套类/接口 |
|---|
ChannelHandler.Sharable |
| 构造方法摘要 | |
|---|---|
ReadTimeoutHandler(Timer timer,
int timeoutSeconds)
创建一个实例. |
|
ReadTimeoutHandler(Timer timer,
long timeout,
java.util.concurrent.TimeUnit unit)
创建一个实例. |
|
| 方法摘要 | |
|---|---|
void |
afterAdd(ChannelHandlerContext ctx)
|
void |
afterRemove(ChannelHandlerContext ctx)
|
void |
beforeAdd(ChannelHandlerContext ctx)
|
void |
beforeRemove(ChannelHandlerContext ctx)
|
void |
channelClosed(ChannelHandlerContext ctx,
ChannelStateEvent e)
当一个 Channel被关闭且它所有关联的资源被释放时调用. |
void |
channelOpen(ChannelHandlerContext ctx,
ChannelStateEvent e)
当一个 Channel打开,但还没有绑定和连接时被调用. |
void |
messageReceived(ChannelHandlerContext ctx,
MessageEvent e)
当一个从远端发来的消息对象(如: ChannelBuffer)被接收时调用. |
void |
releaseExternalResources()
停止该处理器在构造时指定的 Timer.当该Timer被其他对象使用 ,你不能调用该方法. |
| 从类 org.jboss.netty.channel.SimpleChannelUpstreamHandler 继承的方法 |
|---|
channelBound, channelConnected, channelDisconnected, channelInterestChanged, channelUnbound, childChannelClosed, childChannelOpen, exceptionCaught, handleUpstream, writeComplete |
| 从类 java.lang.Object 继承的方法 |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public ReadTimeoutHandler(Timer timer,
int timeoutSeconds)
timer - Timer 常常被用于触发计时事件.推荐的Timer实现是
HashedWheelTimer.timeoutSeconds - 读超时秒数
public ReadTimeoutHandler(Timer timer,
long timeout,
java.util.concurrent.TimeUnit unit)
timer - Timer 常常被用于触发计时事件.推荐的Timer实现是
HashedWheelTimer.timeout - 读取超时数unit - 读取超时数的TimeUnit| 方法详细信息 |
|---|
public void releaseExternalResources()
Timer.当该Timer被其他对象使用 ,你不能调用该方法.
ExternalResourceReleasable 中的 releaseExternalResources
public void beforeAdd(ChannelHandlerContext ctx)
throws java.lang.Exception
LifeCycleAwareChannelHandler 中的 beforeAddjava.lang.Exception
public void afterAdd(ChannelHandlerContext ctx)
throws java.lang.Exception
LifeCycleAwareChannelHandler 中的 afterAddjava.lang.Exception
public void beforeRemove(ChannelHandlerContext ctx)
throws java.lang.Exception
LifeCycleAwareChannelHandler 中的 beforeRemovejava.lang.Exception
public void afterRemove(ChannelHandlerContext ctx)
throws java.lang.Exception
LifeCycleAwareChannelHandler 中的 afterRemovejava.lang.Exception
public void channelOpen(ChannelHandlerContext ctx,
ChannelStateEvent e)
throws java.lang.Exception
SimpleChannelUpstreamHandler 复制的描述Channel打开,但还没有绑定和连接时被调用.
SimpleChannelUpstreamHandler 中的 channelOpenjava.lang.Exception
public void channelClosed(ChannelHandlerContext ctx,
ChannelStateEvent e)
throws java.lang.Exception
SimpleChannelUpstreamHandler 复制的描述Channel被关闭且它所有关联的资源被释放时调用.
SimpleChannelUpstreamHandler 中的 channelClosedjava.lang.Exception
public void messageReceived(ChannelHandlerContext ctx,
MessageEvent e)
throws java.lang.Exception
SimpleChannelUpstreamHandler 复制的描述ChannelBuffer)被接收时调用.
SimpleChannelUpstreamHandler 中的 messageReceivedjava.lang.Exception
|
|||||||||
| 上一个类 下一个类 | 框架 无框架 | ||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | ||||||||