@Test public void testMultiTopic() throws Exception { m_buff = Unpooled.buffer(4); String topic1 = "a/b"; String topic2 = "c/d/e"; initMultiTopic(m_buff, 123, topic1, topic2); m_msgdec.decode(null, m_buff, m_results); assertFalse(m_results.isEmpty()); UnsubscribeMessage message = (UnsubscribeMessage)m_results.get(0); assertNotNull(message); assertEquals(2, message.topics().size()); assertEquals(topic1, message.topics().get(0)); assertEquals(topic2, message.topics().get(1)); assertEquals(AbstractMessage.UNSUBSCRIBE, message.getMessageType()); }
@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); }    }