@Override public ChannelBuffer encode(CommandMessage message) { ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); buffer.writeInt(message.getCommand()); ChannelBufferUtils.writeCommandArguments(buffer, message.getArguments()); return buffer; }
@Override public CommandMessage decode(ChannelBuffer buffer) { final int command = buffer.readInt(); final List<Object> arguments = ChannelBufferUtils.readCommandArguments(buffer); return new CommandMessage(command, arguments); }