Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.nettyhttpserver.server; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.socket.SocketChannel; import io.netty.handler.codec.http.HttpServerCodec; import io.netty.handler.traffic.AbstractTrafficShapingHandler; /** * * @author McKey */ class NettyServerInitializer extends ChannelInitializer<SocketChannel> { public NettyServerInitializer() { } @Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); p.addLast("codec", new HttpServerCodec()); p.addLast("traffic", new NettyChannelTrafficShapingHandler(AbstractTrafficShapingHandler.DEFAULT_CHECK_INTERVAL)); p.addLast("handler", new NettyServerHandler()); } }