@Test public void testMultiTopic() throws Exception { m_buff = IoBuffer.allocate(4).setAutoExpand(true); Couple c1 = new Couple((byte)2, "a/b"); Couple c2 = new Couple((byte)1, "c/d/e"); initMultiTopic(m_buff, 123, c1, c2); m_buff.flip(); MessageDecoderResult res = m_msgdec.decode(null, m_buff, m_mockProtoDecoder); assertEquals(MessageDecoderResult.OK, res); assertEquals(2, m_mockProtoDecoder.getMessage().subscriptions().size()); assertEquals(AbstractMessage.SUBSCRIBE, m_mockProtoDecoder.getMessage().getMessageType()); }
public MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { SubscribeMessage message = new SubscribeMessage(); 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()) { decodeSubscription(in, message); readed = in.position() - start; } out.write(message); return OK; }
SubscribeDecoder extends MqttDecoder { public MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { SubscribeMessage message = new SubscribeMessage(); 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()) { decodeSubscription(in, message); readed = in.position() - start; } out.write(message); return OK; } }
SubscribeDecoder extends MqttDecoder { public MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { SubscribeMessage message = new SubscribeMessage(); 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()) { decodeSubscription(in, message); readed = in.position() - start; } out.write(message); return OK; }  }
SubscribeDecoder extends MqttDecoder { public MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { SubscribeMessage message = new SubscribeMessage(); 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()) { decodeSubscription(in, message); readed = in.position() - start; } out.write(message); return OK; }  MessageDecoderResult decodable(IoSession session, IoBuffer in); MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out); }
SubscribeDecoder extends MqttDecoder { public MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { SubscribeMessage message = new SubscribeMessage(); 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()) { decodeSubscription(in, message); readed = in.position() - start; } out.write(message); return OK; }  MessageDecoderResult decodable(IoSession session, IoBuffer in); MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out);  }