@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 = IoBuffer.allocate(overallMessage.length).setAutoExpand(true); m_buff.put(overallMessage); m_buff.flip(); MessageDecoderResult res = m_msgdec.decode(null, m_buff, m_mockProtoDecoder); assertNotNull(m_mockProtoDecoder.getMessage()); UnsubscribeMessage message = (UnsubscribeMessage) m_mockProtoDecoder.getMessage(); }
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);  }