Skip to content

Instantly share code, notes, and snippets.

@boldt
Forked from danbev/gist:4076911
Created November 15, 2012 17:54
Show Gist options
  • Save boldt/4080095 to your computer and use it in GitHub Desktop.
Save boldt/4080095 to your computer and use it in GitHub Desktop.
WebSocketEnhancmentNettyBoot
public static void main(String[] args) throws Exception {
final ServerBootstrap sb = new ServerBootstrap();
try {
sb.group(new NioEventLoopGroup(), new NioEventLoopGroup())
.channel(NioServerSocketChannel.class)
.localAddress(new InetSocketAddress(6666))
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(final SocketChannel ch) throws Exception {
ch.pipeline().addLast(
new HttpRequestDecoder(),
new HttpChunkAggregator(65536),
new HttpResponseEncoder(),
new WebSocketServerProtocolHandler("/websocket"),
new CustomTextFrameHandler());
}
});
final Channel ch = sb.bind().sync().channel();
ch.closeFuture().sync();
} finally {
sb.shutdown();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment