2
我是Netty的新手,需要以自定义的方式处理邮件。我有以下接口:Netty的处理信息
public interface Command{ }
public interface CommandFactory{
Command(byte b)
}
public interface CommandProcessor{
void process(Command c, Object arg)
}
现在我从客户端收到一些数据并想要处理它。我为实现ReplayingDecoder<Void>
:
public class CommandDecoder extends ReplayingDecoder<Void>{
private CommandFactory cmf;
private CommandProcessor cmp;
void decode(ChannelHandlerContext ctx, ByteBuf in, List<AnyRef> out){
Command command = cmf.command (
in.readByte()
);
String arg = new String (
in.readBytes (
in.readShort()
).array()
);
cmp.process(command, arg); //<------------ Here
}
}
的事情是我不知道这件事。我在解码器内处理命令。至少可以说很奇怪。也许我应该通过解码commmand
和arg
进一步到channel pipeline
。
但是哪个ChannelInboundHandler
可供选择用于命令处理?