
redis.server.netty.RedisCommandDecoder Maven / Gradle / Ivy
The newest version!
package redis.server.netty;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufIndexFinder;
import io.netty.buffer.MessageBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;
import redis.netty4.Command;
import java.io.IOException;
import static redis.netty4.RedisReplyDecoder.readLong;
/**
* Decode commands.
*/
public class RedisCommandDecoder extends ReplayingDecoder {
private byte[][] bytes;
private int arguments = 0;
/**
* Create a new unpooled {@link io.netty.buffer.ByteBuf} by default. Sub-classes may override this to offer a more
* optimized implementation.
*/
@Override
public ByteBuf newInboundBuffer(ChannelHandlerContext ctx) throws Exception {
return ctx.alloc().directBuffer();
}
/**
* Decode the from one {@link io.netty.buffer.ByteBuf} to an other. This method will be called till either the input
* {@link io.netty.buffer.ByteBuf} has nothing to read anymore, till nothing was read from the input {@link io.netty.buffer.ByteBuf} or till
* this method returns {@code null}.
*
* @param ctx the {@link io.netty.channel.ChannelHandlerContext} which this {@link io.netty.handler.codec.ByteToByteDecoder} belongs to
* @param in the {@link io.netty.buffer.ByteBuf} from which to read data
* @param out the {@link io.netty.buffer.MessageBuf} to which decoded messages should be added
* @throws Exception is thrown if an error accour
*/
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, MessageBuf
© 2015 - 2025 Weber Informatics LLC | Privacy Policy