public final void channelRead()

in zuul-sample/src/main/java/com/netflix/zuul/sample/push/SampleWebSocketPushClientProtocolHandler.java [39:64]


    public final void channelRead(ChannelHandlerContext ctx, Object msg) {
        try {
            if (!isAuthenticated()) {
                // Do not entertain ANY message from unauthenticated client
                PushProtocol.WEBSOCKET.sendErrorAndClose(ctx, 1007, "Missing authentication");
            } else if (msg instanceof PingWebSocketFrame) {
                logger.debug("received ping frame");
                ctx.writeAndFlush(new PongWebSocketFrame());
            } else if (msg instanceof CloseWebSocketFrame) {
                logger.debug("received close frame");
                ctx.close();
            } else if (msg instanceof TextWebSocketFrame tf) {
                
                String text = tf.text();
                logger.debug("received test frame: {}", text);
                if (text != null && text.startsWith("ECHO ")) { // echo protocol
                    ctx.channel().writeAndFlush(tf.copy());
                }
            } else if (msg instanceof BinaryWebSocketFrame) {
                logger.debug("received binary frame");
                PushProtocol.WEBSOCKET.sendErrorAndClose(ctx, 1003, "Binary WebSocket frames not supported");
            }
        } finally {
            ReferenceCountUtil.release(msg);
        }
    }