Example usage for io.netty.handler.codec.mqtt MqttQoS FAILURE

List of usage examples for io.netty.handler.codec.mqtt MqttQoS FAILURE

Introduction

In this page you can find the example usage for io.netty.handler.codec.mqtt MqttQoS FAILURE.

Prototype

MqttQoS FAILURE

To view the source code for io.netty.handler.codec.mqtt MqttQoS FAILURE.

Click Source Link

Usage

From source file:io.vertx.mqtt.test.MqttSubscribeTest.java

License:Apache License

protected void endpointHandler(MqttEndpoint endpoint) {

    endpoint.subscribeHandler(subscribe -> {

        List<MqttQoS> qos = new ArrayList<>();

        MqttQoS grantedQos = subscribe.topicSubscriptions().get(0).topicName().equals(MQTT_TOPIC_FAILURE)
                ? MqttQoS.FAILURE
                : subscribe.topicSubscriptions().get(0).qualityOfService();

        qos.add(grantedQos);/*from  w  w w. j av  a  2 s .c  o  m*/
        endpoint.subscribeAcknowledge(subscribe.messageId(), qos);

        this.async.complete();
    });

    endpoint.accept(false);
}

From source file:io.vertx.mqtt.test.server.MqttServerSubscribeTest.java

License:Apache License

@Override
protected void endpointHandler(MqttEndpoint endpoint) {

    endpoint.subscribeHandler(subscribe -> {

        List<MqttQoS> qos = new ArrayList<>();

        MqttQoS grantedQos = subscribe.topicSubscriptions().get(0).topicName().equals(MQTT_TOPIC_FAILURE)
                ? MqttQoS.FAILURE
                : subscribe.topicSubscriptions().get(0).qualityOfService();

        qos.add(grantedQos);/* w ww .jav  a  2s.  co m*/
        endpoint.subscribeAcknowledge(subscribe.messageId(), qos);

        this.async.complete();
    });

    endpoint.accept(false);
}

From source file:net.anyflow.lannister.packetreceiver.SubscribeReceiver.java

License:Apache License

private Map.Entry<List<Integer>, Map<String, TopicSubscription>> generateReturns(
        List<MqttTopicSubscription> topicSubs) {
    List<Integer> grantedQoss = Lists.newArrayList();
    Map<String, TopicSubscription> topicSubscriptions = Maps.newHashMap();

    topicSubs.stream().forEach(topicSub -> {
        if (TopicMatcher.isValid(topicSub.topicName(), true)) {
            TopicSubscription topicSubscription = new TopicSubscription(topicSub.topicName(),
                    topicSub.qualityOfService());

            grantedQoss.add(topicSubscription.qos().value());
            topicSubscriptions.put(topicSubscription.topicFilter(), topicSubscription);
        } else {//from ww w .ja v  a  2 s.  co m
            grantedQoss.add(MqttQoS.FAILURE.value());
        }
    });

    return new Map.Entry<List<Integer>, Map<String, TopicSubscription>>() {
        @Override
        public List<Integer> getKey() {
            return grantedQoss;
        }

        @Override
        public Map<String, TopicSubscription> getValue() {
            return topicSubscriptions;
        }

        @Override
        public Map<String, TopicSubscription> setValue(Map<String, TopicSubscription> value) {
            return null; // Should not be called
        }
    };
}