private static ByteBuf encodeSubAckMessage( ByteBufAllocator byteBufAllocator, MqttSubAckMessage message) { int variableHeaderBufferSize = 2; int payloadBufferSize = message.payload().grantedQoSLevels().size(); int variablePartSize = variableHeaderBufferSize + payloadBufferSize; int fixedHeaderBufferSize = 1 + getVariableLengthInt(variablePartSize); ByteBuf buf = byteBufAllocator.buffer(fixedHeaderBufferSize + variablePartSize); buf.writeByte(getFixedHeaderByte1(message.fixedHeader())); writeVariableLengthInt(buf, variablePartSize); buf.writeShort(message.variableHeader().messageId()); for (int qos : message.payload().grantedQoSLevels()) { buf.writeByte(qos); } return buf; }
private void verifyFailureQos(MqttSubAckMessage subAckMsg) { List<Integer> grantedQoSes = subAckMsg.payload().grantedQoSLevels(); assertEquals(1, grantedQoSes.size()); assertTrue(grantedQoSes.contains(MqttQoS.FAILURE.value())); }
case SUBACK: MqttSubAckMessage suback = (MqttSubAckMessage) msg; final List<Integer> grantedQoSLevels = suback.payload().grantedQoSLevels(); LOG.info("{} SUBACK <{}> packetID <{}>, grantedQoses {}", direction, clientID, messageId(msg), grantedQoSLevels);
private void subscribe(MqttQoS topic, String newsTopic, MQTTConnection connection) { MqttSubscribeMessage subscribe = MqttMessageBuilders.subscribe() .addSubscription(topic, newsTopic) .messageId(1) .build(); sut.subscribeClientToTopics(subscribe, connection.getClientId(), null, this.connection); MqttSubAckMessage subAck = ((EmbeddedChannel) this.connection.channel).readOutbound(); assertEquals(topic.value(), (int) subAck.payload().grantedQoSLevels().get(0)); }
private void subscribe(MqttQoS topic, String newsTopic, MQTTConnection connection) { MqttSubscribeMessage subscribe = MqttMessageBuilders.subscribe() .addSubscription(topic, newsTopic) .messageId(1) .build(); sut.subscribeClientToTopics(subscribe, connection.getClientId(), null, this.connection); MqttSubAckMessage subAck = ((EmbeddedChannel) this.connection.channel).readOutbound(); assertEquals(topic.value(), (int) subAck.payload().grantedQoSLevels().get(0)); }
protected void subscribe(EmbeddedChannel channel, String topic, MqttQoS desiredQos) { MqttSubscribeMessage subscribe = MqttMessageBuilders.subscribe() .addSubscription(desiredQos, topic) .messageId(1) .build(); sut.subscribeClientToTopics(subscribe, FAKE_CLIENT_ID, null, connection); MqttSubAckMessage subAck = channel.readOutbound(); assertEquals(desiredQos.value(), (int) subAck.payload().grantedQoSLevels().get(0)); final String clientId = NettyUtils.clientID(channel); Subscription expectedSubscription = new Subscription(clientId, new Topic(topic), desiredQos); final Set<Subscription> matchedSubscriptions = subscriptions.matchWithoutQosSharpening(new Topic(topic)); assertEquals(1, matchedSubscriptions.size()); final Subscription onlyMatchedSubscription = matchedSubscriptions.iterator().next(); assertEquals(expectedSubscription, onlyMatchedSubscription); }
protected void subscribe(MQTTConnection connection, String topic, MqttQoS desiredQos) { EmbeddedChannel channel = (EmbeddedChannel) connection.channel; MqttSubscribeMessage subscribe = MqttMessageBuilders.subscribe() .addSubscription(desiredQos, topic) .messageId(1) .build(); sut.subscribeClientToTopics(subscribe, connection.getClientId(), null, connection); MqttSubAckMessage subAck = channel.readOutbound(); assertEquals(desiredQos.value(), (int) subAck.payload().grantedQoSLevels().get(0)); final String clientId = connection.getClientId(); Subscription expectedSubscription = new Subscription(clientId, new Topic(topic), desiredQos); final Set<Subscription> matchedSubscriptions = subscriptions.matchWithoutQosSharpening(new Topic(topic)); assertEquals(1, matchedSubscriptions.size()); final Subscription onlyMatchedSubscription = matchedSubscriptions.iterator().next(); assertEquals(expectedSubscription, onlyMatchedSubscription); }
protected void subscribe(MQTTConnection connection, String topic, MqttQoS desiredQos) { EmbeddedChannel channel = (EmbeddedChannel) connection.channel; MqttSubscribeMessage subscribe = MqttMessageBuilders.subscribe() .addSubscription(desiredQos, topic) .messageId(1) .build(); sut.subscribeClientToTopics(subscribe, connection.getClientId(), null, connection); MqttSubAckMessage subAck = channel.readOutbound(); assertEquals(desiredQos.value(), (int) subAck.payload().grantedQoSLevels().get(0)); final String clientId = connection.getClientId(); Subscription expectedSubscription = new Subscription(clientId, new Topic(topic), desiredQos); final Set<Subscription> matchedSubscriptions = subscriptions.matchWithoutQosSharpening(new Topic(topic)); assertEquals(1, matchedSubscriptions.size()); final Subscription onlyMatchedSubscription = matchedSubscriptions.iterator().next(); assertEquals(expectedSubscription, onlyMatchedSubscription); }
protected void subscribe(MQTTConnection connection, String topic, MqttQoS desiredQos) { EmbeddedChannel channel = (EmbeddedChannel) connection.channel; MqttSubscribeMessage subscribe = MqttMessageBuilders.subscribe() .addSubscription(desiredQos, topic) .messageId(1) .build(); sut.subscribeClientToTopics(subscribe, connection.getClientId(), null, connection); MqttSubAckMessage subAck = channel.readOutbound(); assertEquals(desiredQos.value(), (int) subAck.payload().grantedQoSLevels().get(0)); final String clientId = connection.getClientId(); Subscription expectedSubscription = new Subscription(clientId, new Topic(topic), desiredQos); final Set<Subscription> matchedSubscriptions = subscriptions.matchWithoutQosSharpening(new Topic(topic)); assertEquals(1, matchedSubscriptions.size()); final Subscription onlyMatchedSubscription = matchedSubscriptions.iterator().next(); assertEquals(expectedSubscription, onlyMatchedSubscription); }
protected void subscribe(MQTTConnection connection, String topic, MqttQoS desiredQos) { EmbeddedChannel channel = (EmbeddedChannel) connection.channel; MqttSubscribeMessage subscribe = MqttMessageBuilders.subscribe() .addSubscription(desiredQos, topic) .messageId(1) .build(); sut.subscribeClientToTopics(subscribe, connection.getClientId(), null, connection); MqttSubAckMessage subAck = channel.readOutbound(); assertEquals(desiredQos.value(), (int) subAck.payload().grantedQoSLevels().get(0)); final String clientId = connection.getClientId(); Subscription expectedSubscription = new Subscription(clientId, new Topic(topic), desiredQos); final Set<Subscription> matchedSubscriptions = subscriptions.matchQosSharpening(new Topic(topic)); assertEquals(1, matchedSubscriptions.size()); //assertTrue(matchedSubscriptions.size() >=1); final Subscription onlyMatchedSubscription = matchedSubscriptions.iterator().next(); assertEquals(expectedSubscription, onlyMatchedSubscription); // assertTrue(matchedSubscriptions.contains(expectedSubscription)); }
private static void validateSubAckPayload(MqttSubAckPayload expected, MqttSubAckPayload actual) { assertArrayEquals( "MqttSubAckPayload GrantedQosLevels mismatch ", expected.grantedQoSLevels().toArray(), actual.grantedQoSLevels().toArray()); }
private static ByteBuf encodeSubAckMessage( ByteBufAllocator byteBufAllocator, MqttSubAckMessage message) { int variableHeaderBufferSize = 2; int payloadBufferSize = message.payload().grantedQoSLevels().size(); int variablePartSize = variableHeaderBufferSize + payloadBufferSize; int fixedHeaderBufferSize = 1 + getVariableLengthInt(variablePartSize); ByteBuf buf = byteBufAllocator.buffer(fixedHeaderBufferSize + variablePartSize); buf.writeByte(getFixedHeaderByte1(message.fixedHeader())); writeVariableLengthInt(buf, variablePartSize); buf.writeShort(message.variableHeader().packetId()); message.payload().grantedQoSLevels().forEach(qos -> buf.writeByte(qos.value())); return buf; }
private static ByteBuf encodeSubAckMessage( ByteBufAllocator byteBufAllocator, MqttSubAckMessage message) { int variableHeaderBufferSize = 2; int payloadBufferSize = message.payload().grantedQoSLevels().size(); int variablePartSize = variableHeaderBufferSize + payloadBufferSize; int fixedHeaderBufferSize = 1 + getVariableLengthInt(variablePartSize); ByteBuf buf = byteBufAllocator.buffer(fixedHeaderBufferSize + variablePartSize); buf.writeByte(getFixedHeaderByte1(message.fixedHeader())); writeVariableLengthInt(buf, variablePartSize); buf.writeShort(message.variableHeader().messageId()); for (int qos : message.payload().grantedQoSLevels()) { buf.writeByte(qos); } return buf; }
for (Integer qos : ((MqttSubAckMessage) message).payload().grantedQoSLevels()) { log.append("\n\t" + qos);
for (Integer qos : ((MqttSubAckMessage) message).payload().grantedQoSLevels()) { log.append("\n\t" + qos);
case SUBACK: MqttSubAckMessage suback = (MqttSubAckMessage) msg; final List<Integer> grantedQoSLevels = suback.payload().grantedQoSLevels(); LOG.info("{} SUBACK <{}> packetID <{}>, grantedQoses {}", direction, clientID, messageId(msg), grantedQoSLevels);
unsuback.payload().grantedQoSLevels()); handleSuback(mqttSubAckMessage); break;
unsuback.payload().grantedQoSLevels()); handleSuback(mqttSubAckMessage); break;