use of com.github.jvm.io.protocol.c2d.heart.PongHandler in project jdepth by Crab2died.
the class C2DServer method bind.
private void bind(String host, int port) throws InterruptedException {
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
try {
ServerBootstrap bootstrap = new ServerBootstrap().group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new C2DHessianMsgDecoder(1024 * 1024, 4, 4, -8, 0)).addLast("MessageEncoder", new C2DHessianMsgEncoder()).addLast("ReadTimeoutHandler", new ReadTimeoutHandler(TIME_OUT)).addLast("LoginAuthResp", new LoginAuthRespHandler()).addLast("Pong", new PongHandler());
}
});
ChannelFuture future = bootstrap.bind(host, port).sync();
future.channel().closeFuture().sync();
logger.info("server is started");
} finally {
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
}
Aggregations