-
-
Save boldt/4080095 to your computer and use it in GitHub Desktop.
WebSocketEnhancmentNettyBoot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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