@Test public void testDecodeSingleTopic_bug() throws Exception { byte[] overallMessage = new byte[] {(byte)0xA2, 0x0A, 0x00, 0x01, 0x00, 0x06, 0x2F, 0x74, 0x6F, 0x70, 0x69, 0x63}; m_buff = Unpooled.buffer(overallMessage.length); m_buff.writeBytes(overallMessage); m_msgdec.decode(null, m_buff, m_results); assertFalse(m_results.isEmpty()); UnsubscribeMessage message = (UnsubscribeMessage)m_results.get(0); assertNotNull(message); assertEquals(0x01, (int)message.getMessageID()); }
@Override void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { in.resetReaderIndex(); UnsubscribeMessage message = new UnsubscribeMessage(); if (!decodeCommonHeader(message, in)) { in.resetReaderIndex(); return; } if (message.getQos() != AbstractMessage.QOSType.LEAST_ONE) { throw new CorruptedFrameException("Found an Usubscribe message with qos other than LEAST_ONE, was: " + message.getQos()); } int start = in.readerIndex(); message.setMessageID(in.readUnsignedShort()); int readed = in.readerIndex()- start; while (readed < message.getRemainingLength()) { message.addTopic(Utils.decodeString(in)); readed = in.readerIndex()- start; } out.add(message); }
UnsubscribeDecoder extends DemuxDecoder { @Override void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { in.resetReaderIndex(); UnsubscribeMessage message = new UnsubscribeMessage(); if (!decodeCommonHeader(message, in)) { in.resetReaderIndex(); return; } if (message.getQos() != AbstractMessage.QOSType.LEAST_ONE) { throw new CorruptedFrameException("Found an Usubscribe message with qos other than LEAST_ONE, was: " + message.getQos()); } int start = in.readerIndex(); message.setMessageID(in.readUnsignedShort()); int readed = in.readerIndex()- start; while (readed < message.getRemainingLength()) { message.addTopic(Utils.decodeString(in)); readed = in.readerIndex()- start; } out.add(message); } }
UnsubscribeDecoder extends DemuxDecoder { @Override void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { in.resetReaderIndex(); UnsubscribeMessage message = new UnsubscribeMessage(); if (!decodeCommonHeader(message, in)) { in.resetReaderIndex(); return; } if (message.getQos() != AbstractMessage.QOSType.LEAST_ONE) { throw new CorruptedFrameException("Found an Usubscribe message with qos other than LEAST_ONE, was: " + message.getQos()); } int start = in.readerIndex(); message.setMessageID(in.readUnsignedShort()); int readed = in.readerIndex()- start; while (readed < message.getRemainingLength()) { message.addTopic(Utils.decodeString(in)); readed = in.readerIndex()- start; } out.add(message); }  }
UnsubscribeDecoder extends DemuxDecoder { @Override void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { in.resetReaderIndex(); UnsubscribeMessage message = new UnsubscribeMessage(); if (!decodeCommonHeader(message, in)) { in.resetReaderIndex(); return; } if (message.getQos() != AbstractMessage.QOSType.LEAST_ONE) { throw new CorruptedFrameException("Found an Usubscribe message with qos other than LEAST_ONE, was: " + message.getQos()); } int start = in.readerIndex(); message.setMessageID(in.readUnsignedShort()); int readed = in.readerIndex()- start; while (readed < message.getRemainingLength()) { message.addTopic(Utils.decodeString(in)); readed = in.readerIndex()- start; } out.add(message); }   }
UnsubscribeDecoder extends DemuxDecoder { @Override void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { in.resetReaderIndex(); UnsubscribeMessage message = new UnsubscribeMessage(); if (!decodeCommonHeader(message, in)) { in.resetReaderIndex(); return; } if (message.getQos() != AbstractMessage.QOSType.LEAST_ONE) { throw new CorruptedFrameException("Found an Usubscribe message with qos other than LEAST_ONE, was: " + message.getQos()); } int start = in.readerIndex(); message.setMessageID(in.readUnsignedShort()); int readed = in.readerIndex()- start; while (readed < message.getRemainingLength()) { message.addTopic(Utils.decodeString(in)); readed = in.readerIndex()- start; } out.add(message); }    }