Example usage for io.netty.channel.socket SocketChannel read

List of usage examples for io.netty.channel.socket SocketChannel read

Introduction

In this page you can find the example usage for io.netty.channel.socket SocketChannel read.

Prototype

@Override
    Channel read();

Source Link

Usage

From source file:srebrinb.messagebroker.websocket.WebSocketServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    if (sslCtx != null) {
        pipeline.addLast(sslCtx.newHandler(ch.alloc()));
    }/*w w  w.  j  a va  2s  .  c  o  m*/

    pipeline.addLast(new HttpServerCodec());
    pipeline.addLast(new HttpObjectAggregator(65536));
    pipeline.addLast(new WebSocketServerCompressionHandler());
    pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true));
    //     pipeline.addLast(new UtsHeadersChannelHandler());
    pipeline.addLast(new WebSocketIndexPageHandler(WEBSOCKET_PATH));
    pipeline.addLast(new WebSocketFrameHandler());
    allChannels.add(ch.read());
    String shortID = ch.id().asShortText();
    System.out.println(shortID);
    ch.read().writeAndFlush(new TextWebSocketFrame("Hello " + shortID));
}