use of com.firenio.codec.http11.WebSocketCodec in project baseio by generallycloud.
the class TestHttpLoadServer method main.
public static void main(String[] args) throws Exception {
IoEventHandle eventHandle = new IoEventHandle() {
@Override
public void accept(Channel ch, Frame frame) throws Exception {
HttpFrame f = (HttpFrame) frame;
f.setConnection(HttpConnection.KEEP_ALIVE);
f.setContentType(HttpContentType.text_plain);
f.setString("Hello World", ch);
ch.writeAndFlush(f);
ch.release(f);
}
};
NioEventLoopGroup group = new NioEventLoopGroup();
group.setMemoryCapacity(1024 * 1024 * 64);
group.setMemoryUnit(512);
group.setEventLoopSize(2);
ChannelAcceptor context = new ChannelAcceptor(group, 8080);
context.addProtocolCodec(new HttpCodec(8));
context.addProtocolCodec(new WebSocketCodec());
context.setIoEventHandle(eventHandle);
context.addChannelEventListener(new LoggerChannelOpenListener());
context.bind();
}
Aggregations