Java 类net.minecraft.util.io.netty.channel.ChannelInitializer 实例源码

项目:SignGUI    文件:TinyProtocol.java   
private void createServerChannelHandler() {
    endInitProtocol = new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(Channel channel) throws Exception {
            try {
                synchronized (networkManagers) {
                    if (!closed) {
                        injectChannelInternal(channel);
                    }
                }
            } catch (Exception e) {
                plugin.getLogger().log(Level.SEVERE, "Cannot inject incomming channel " + channel, e);
            }
        }

    };

    beginInitProtocol = new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(Channel channel) throws Exception {
            channel.pipeline().addLast(endInitProtocol);
        }

    };

    serverChannelHandler = new ChannelInboundHandlerAdapter() {

        @Override
        public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
            Channel channel = (Channel) msg;

            channel.pipeline().addFirst(beginInitProtocol);
            ctx.fireChannelRead(msg);
        }

    };
}
项目:MoreMobs    文件:TinyProtocol.java   
private void createServerChannelHandler() {
    endInitProtocol = new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(Channel channel) throws Exception {
            try {
                synchronized (networkManagers) {
                    if (!closed) {
                        injectChannelInternal(channel);
                    }
                }
            } catch (Exception e) {
                plugin.getLogger().log(Level.SEVERE,
                        "Cannot inject incomming channel " + channel, e);
            }
        }

    };

    beginInitProtocol = new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(Channel channel) throws Exception {
            channel.pipeline().addLast(endInitProtocol);
        }

    };

    serverChannelHandler = new ChannelInboundHandlerAdapter() {

        @Override
        public void channelRead(ChannelHandlerContext ctx, Object msg)
                throws Exception {
            Channel channel = (Channel) msg;

            channel.pipeline().addFirst(beginInitProtocol);
            ctx.fireChannelRead(msg);
        }

    };
}