Search in sources :

Example 1 with WebSocketHandler

use of com.weicoder.netty.handler.WebSocketHandler in project weicoder by wdcode.

the class WebSocketServer method handler.

@Override
protected ChannelHandler handler() {
    return new ChannelInitializer<SocketChannel>() {

        @Override
        public void initChannel(final SocketChannel ch) throws Exception {
            ch.pipeline().addLast(new HttpServerCodec());
            ch.pipeline().addLast(new HttpObjectAggregator(1024 * 1024));
            ch.pipeline().addLast(new WebSocketHandler("websocket"));
            ch.config().setAllocator(PooledByteBufAllocator.DEFAULT);
        }
    };
}
Also used : SocketChannel(io.netty.channel.socket.SocketChannel) HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) WebSocketHandler(com.weicoder.netty.handler.WebSocketHandler) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) ChannelInitializer(io.netty.channel.ChannelInitializer)

Aggregations

WebSocketHandler (com.weicoder.netty.handler.WebSocketHandler)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1 SocketChannel (io.netty.channel.socket.SocketChannel)1 HttpObjectAggregator (io.netty.handler.codec.http.HttpObjectAggregator)1 HttpServerCodec (io.netty.handler.codec.http.HttpServerCodec)1