Transports and Connections

-
Future < Connection > clientConnectionFuture = tcpNioTransport . connect ( "grizzly.java.net" , 80 );
-
Connection clientConnection = clientConnectionFuture . get ();
-
Connection conn ;
-
conn . addCloseListener ( new CloseListener < Closeable , ICloseType >() {
-
-
@Override
-
public void onClosed ( Closeable closeable , ICloseType type )
-
throws IOException {
-
// TODO Auto-generated method stub
-
-
}
-
});
FilterChains and Filters


- /**
- * 读流程,读取网络数据,或上一个Filter read之后的message
- */
-
public NextAction handleRead ( FilterChainContext ctx ) throws IOException ;
-
- /**
- * 写流程,写如网络数据,或者处理上一个Filter write之后的message
- */
-
public NextAction handleWrite ( FilterChainContext ctx ) throws IOException ;
-
- /**
- * 新加入的连接
- */
-
public NextAction handleConnect ( FilterChainContext ctx ) throws IOException ;
-
- /**
- * 同handleConnect
- */
-
public NextAction handleAccept ( FilterChainContext ctx ) throws IOException ;
-
- /**
- * 连接断开之后调用
- */
-
public NextAction handleClose ( FilterChainContext ctx ) throws IOException ;
StopAction
return ctx.getStopAction(incompleteChunk);
InvokeAction
如果是继续下一次Filter流程,就返回InvokeAction
return ctx.getInvokeAction();
如果数据流里面有粘包(两个数据包一起发来,我们需要一个个处理),同样可以添加参数:
return ctx.getInvokeAction(incompleteChunk);
RerunFilterAction
return ctx.getRerunFilterAction()
这个就是当前Filter的action多执行一次。
SuspendAction
return ctx.getSuspendAction();
这个是暂停。。。。中断线程,并且通过另外一个线程调用
ctx.resume()
:
ForkAction (was SuspendStopAction)
return ctx.getForkAction();
和上一个类似。