Search in sources :

Example 1 with LoginAuthRespHandler

use of com.github.jvm.io.protocol.c2d.auth.LoginAuthRespHandler 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();
    }
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) SocketChannel(io.netty.channel.socket.SocketChannel) LoggingHandler(io.netty.handler.logging.LoggingHandler) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) PongHandler(com.github.jvm.io.protocol.c2d.heart.PongHandler) C2DHessianMsgDecoder(com.github.jvm.io.protocol.c2d.codc.hessian.C2DHessianMsgDecoder) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) C2DHessianMsgEncoder(com.github.jvm.io.protocol.c2d.codc.hessian.C2DHessianMsgEncoder) EventLoopGroup(io.netty.channel.EventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) ReadTimeoutHandler(io.netty.handler.timeout.ReadTimeoutHandler) LoginAuthRespHandler(com.github.jvm.io.protocol.c2d.auth.LoginAuthRespHandler) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Aggregations

LoginAuthRespHandler (com.github.jvm.io.protocol.c2d.auth.LoginAuthRespHandler)1 C2DHessianMsgDecoder (com.github.jvm.io.protocol.c2d.codc.hessian.C2DHessianMsgDecoder)1 C2DHessianMsgEncoder (com.github.jvm.io.protocol.c2d.codc.hessian.C2DHessianMsgEncoder)1 PongHandler (com.github.jvm.io.protocol.c2d.heart.PongHandler)1 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 ChannelFuture (io.netty.channel.ChannelFuture)1 EventLoopGroup (io.netty.channel.EventLoopGroup)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 SocketChannel (io.netty.channel.socket.SocketChannel)1 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)1 LoggingHandler (io.netty.handler.logging.LoggingHandler)1 ReadTimeoutHandler (io.netty.handler.timeout.ReadTimeoutHandler)1