@Test public void testMultiTopic() throws Exception { m_buff = IoBuffer.allocate(4).setAutoExpand(true); String topic1 = "a/b"; String topic2 = "c/d/e"; initMultiTopic(m_buff, 123, topic1, topic2); m_buff.flip(); MessageDecoderResult res = m_msgdec.decode(null, m_buff, m_mockProtoDecoder); assertEquals(MessageDecoderResult.OK, res); assertEquals(2, m_mockProtoDecoder.getMessage().topics().size()); assertEquals(topic1, m_mockProtoDecoder.getMessage().topics().get(0)); assertEquals(topic2, m_mockProtoDecoder.getMessage().topics().get(1)); assertEquals(AbstractMessage.UNSUBSCRIBE, m_mockProtoDecoder.getMessage().getMessageType()); }
public MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { UnsubscribeMessage message = new UnsubscribeMessage(); if (decodeCommonHeader(message, in) == NEED_DATA) { return NEED_DATA; } if (message.getQos() != QOSType.LEAST_ONE) { return NOT_OK; } int start = in.position(); message.setMessageID(Utils.readWord(in)); int readed = in.position() - start; while (readed < message.getRemainingLength()) { message.addTopic(Utils.decodeString(in)); readed = in.position() - start; } out.write(message); return OK; }
UnsubscribeDecoder extends MqttDecoder { public MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { UnsubscribeMessage message = new UnsubscribeMessage(); if (decodeCommonHeader(message, in) == NEED_DATA) { return NEED_DATA; } if (message.getQos() != QOSType.LEAST_ONE) { return NOT_OK; } int start = in.position(); message.setMessageID(Utils.readWord(in)); int readed = in.position() - start; while (readed < message.getRemainingLength()) { message.addTopic(Utils.decodeString(in)); readed = in.position() - start; } out.write(message); return OK; } }
UnsubscribeDecoder extends MqttDecoder { public MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { UnsubscribeMessage message = new UnsubscribeMessage(); if (decodeCommonHeader(message, in) == NEED_DATA) { return NEED_DATA; } if (message.getQos() != QOSType.LEAST_ONE) { return NOT_OK; } int start = in.position(); message.setMessageID(Utils.readWord(in)); int readed = in.position() - start; while (readed < message.getRemainingLength()) { message.addTopic(Utils.decodeString(in)); readed = in.position() - start; } out.write(message); return OK; }  }
UnsubscribeDecoder extends MqttDecoder { public MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { UnsubscribeMessage message = new UnsubscribeMessage(); if (decodeCommonHeader(message, in) == NEED_DATA) { return NEED_DATA; } if (message.getQos() != QOSType.LEAST_ONE) { return NOT_OK; } int start = in.position(); message.setMessageID(Utils.readWord(in)); int readed = in.position() - start; while (readed < message.getRemainingLength()) { message.addTopic(Utils.decodeString(in)); readed = in.position() - start; } out.write(message); return OK; }  MessageDecoderResult decodable(IoSession session, IoBuffer in); MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out); }
UnsubscribeDecoder extends MqttDecoder { public MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { UnsubscribeMessage message = new UnsubscribeMessage(); if (decodeCommonHeader(message, in) == NEED_DATA) { return NEED_DATA; } if (message.getQos() != QOSType.LEAST_ONE) { return NOT_OK; } int start = in.position(); message.setMessageID(Utils.readWord(in)); int readed = in.position() - start; while (readed < message.getRemainingLength()) { message.addTopic(Utils.decodeString(in)); readed = in.position() - start; } out.write(message); return OK; }  MessageDecoderResult decodable(IoSession session, IoBuffer in); MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out);  }