/**
* 因为每次连接执行都会init都会被remove,所以每次调用booter都会用新的handler来进行连接配置
* @param address
* @param init
* @return
*/
protected ChannelFuture doBooterConnect(InetSocketAddress address,final ChannelHandler init)
{
ChannelFuture cf;
synchronized (booter) {
if(booter.config().group()==null)
{
booterInit();
}
final CountDownLatch latch=new CountDownLatch(1);
ChannelHandler handler=initHandlerAdapter(init);
booter.handler(handler);
cf=booter.connect(address);
cf.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
log.trace("connect operationComplete:isDone="+future.isDone()+",isSuccess="+future.isSuccess());
if(future.isDone() && future.isSuccess())
{
latch.countDown();
}
}
});
try {
latch.await(getConnectTimeOutMills(),TimeUnit.MILLISECONDS);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
}
return cf;
}
NettyClientConfig.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:util4j
作者:
评论列表
文章目录