@Override protected void channelRead0(ChannelHandlerContext context, WebSocketFrame frame) throws Exception { if(frame instanceof CloseWebSocketFrame){ handshaker.close(context.channel(), (CloseWebSocketFrame) frame.retain()); return; } if(frame instanceof PingWebSocketFrame){ context.channel().write(new PongWebSocketFrame(frame.content().retain())); return; } if(frame instanceof TextWebSocketFrame){ handleTextMessage(context, ((TextWebSocketFrame) frame).text()); return; } if(frame instanceof BinaryWebSocketFrame){ handleBinaryMessage(context, frame); return; } throw new UnsupportedMessageTypeException(frame.getClass().getName()); }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof RedisRequest) { writeNormal(ctx, (RedisRequest) msg, promise); } else if (msg instanceof TxnRedisRequest) { writeTxn(ctx, (TxnRedisRequest) msg, promise); } else { throw new UnsupportedMessageTypeException(msg, RedisRequest.class, TxnRedisRequest.class); } scheduleTimeoutTask(ctx); }