/**
* 初始化channel
*/
@Override
public void initChannel(SocketChannel ch) {
try {
ByteBuf buf = Unpooled.copiedBuffer(flag.getBytes());
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new IdleStateHandler(600,0,0,TimeUnit.SECONDS));
pipeline.addLast(new StringEncoder(CharsetUtil.UTF_8));
pipeline.addLast(new DelimiterBasedFrameDecoder(Integer.MAX_VALUE, buf));
pipeline.addLast(new StringDecoder(CharsetUtil.UTF_8));
pipeline.addLast(new NettyServerHandler());
// pipeline.addLast(new FileServerHandler());
}catch (Exception e){
e.printStackTrace();
}
}
前三个的参数解释如下:
(1).readerIdleTime:为读超时间(即测试端一定时间内未接收到被测试端消息);
(2).writerIdleTime:为写超时间(即测试端一定时间内向被测试端发送消息);
(3).allIdeTime:所有类型的超时时间