@Override public void onSuccess(byte[] value) { for (Topic topic : topics) { activeSubs.put(topic.name(), topic.qos()); } if(next!=null) { next.onSuccess(value); } } });
public MQTTFrame encode() { try { DataByteArrayOutputStream os = new DataByteArrayOutputStream(); QoS qos = qos(); if(qos != QoS.AT_MOST_ONCE) { os.writeShort(messageId); } for(Topic topic: topics) { MessageSupport.writeUTF(os, topic.name()); os.writeByte(topic.qos().ordinal()); } MQTTFrame frame = new MQTTFrame(); frame.header(header()); frame.commandType(TYPE); return frame.buffer(os.toBuffer()); } catch (IOException e) { throw new RuntimeException("The impossible happened"); } }
@Override public void onSuccess(byte[] value) { for (Topic topic : topics) { activeSubs.put(topic.name(), topic.qos()); } if(next!=null) { next.onSuccess(value); } } });
@Override public BindAddress apply(Topic topic) { BindAddress address = decode_destination(topic.name()); session_state.subscriptions.put(topic.name(), new Tuple2<Topic, BindAddress>(topic, address)); mqtt_consumer().addresses.put(address, topic.qos()); if (PathParser.containsWildCards(address.path())) { mqtt_consumer().wildcards.put(address.path(), topic.qos()); } return address; } });
private byte onSubscribe(final Topic topic) throws MQTTProtocolException { final String destinationName = topic.name().toString(); final QoS requestedQoS = topic.qos(); final MQTTSubscription mqttSubscription = mqttSubscriptionByTopic.get(destinationName); if (mqttSubscription != null) { if (requestedQoS != mqttSubscription.getQoS()) { // remove old subscription as the QoS has changed onUnSubscribe(destinationName); } else { return (byte) requestedQoS.ordinal(); } } try { return onSubscribe(destinationName, requestedQoS); } catch (IOException e) { throw new MQTTProtocolException("Failed while intercepting subscribe", true, e); } } }
@Override public Option<BindAddress> apply(UTF8Buffer topicName) { Tuple2<Topic, BindAddress> removed = session_state.subscriptions.remove(topicName); if (removed != null) { Topic topic = removed._1(); BindAddress address = removed._2(); mqtt_consumer().addresses.remove(address); if (PathParser.containsWildCards(address.path())) { mqtt_consumer().wildcards.remove(address.path(), topic.qos()); } return Scala2Java.some(address); } else { return Scala2Java.none(); } } });
private byte onSubscribe(final Topic topic) throws MQTTProtocolException { final String destinationName = topic.name().toString(); final QoS requestedQoS = topic.qos(); final MQTTSubscription mqttSubscription = mqttSubscriptionByTopic.get(destinationName); if (mqttSubscription != null) { if (requestedQoS != mqttSubscription.getQoS()) { // remove old subscription as the QoS has changed onUnSubscribe(destinationName); } else { return (byte) requestedQoS.ordinal(); } } try { return onSubscribe(destinationName, requestedQoS); } catch (IOException e) { throw new MQTTProtocolException("Failed while intercepting subscribe", true, e); } } }
@Override public byte onSubscribe(final Topic topic) throws MQTTProtocolException { final String destinationName = topic.name().toString(); final QoS requestedQoS = topic.qos(); final MQTTSubscription mqttSubscription = mqttSubscriptionByTopic.get(destinationName); if (mqttSubscription != null) { if (requestedQoS != mqttSubscription.getQoS()) { // remove old subscription as the QoS has changed onUnSubscribe(destinationName); } else { try { onReSubscribe(mqttSubscription); } catch (IOException e) { throw new MQTTProtocolException("Failed to find subscription strategy", true, e); } return (byte) requestedQoS.ordinal(); } } try { return onSubscribe(destinationName, requestedQoS); } catch (IOException e) { throw new MQTTProtocolException("Failed while intercepting subscribe", true, e); } }
@Override public byte onSubscribe(final Topic topic) throws MQTTProtocolException { final String destinationName = topic.name().toString(); final QoS requestedQoS = topic.qos(); final MQTTSubscription mqttSubscription = mqttSubscriptionByTopic.get(destinationName); if (mqttSubscription != null) { if (requestedQoS != mqttSubscription.getQoS()) { // remove old subscription as the QoS has changed onUnSubscribe(destinationName); } else { try { onReSubscribe(mqttSubscription); } catch (IOException e) { throw new MQTTProtocolException("Failed to find subscription strategy", true, e); } return (byte) requestedQoS.ordinal(); } } try { return onSubscribe(destinationName, requestedQoS); } catch (IOException e) { throw new MQTTProtocolException("Failed while intercepting subscribe", true, e); } }
@Override public byte onSubscribe(final Topic topic) throws MQTTProtocolException { final String destinationName = topic.name().toString(); final QoS requestedQoS = topic.qos(); final MQTTSubscription mqttSubscription = mqttSubscriptionByTopic.get(destinationName); if (mqttSubscription != null) { if (requestedQoS != mqttSubscription.getQoS()) { // remove old subscription as the QoS has changed onUnSubscribe(destinationName); } else { try { onReSubscribe(mqttSubscription); } catch (IOException e) { throw new MQTTProtocolException("Failed to find subscription strategy", true, e); } return (byte) requestedQoS.ordinal(); } } try { return onSubscribe(destinationName, requestedQoS); } catch (IOException e) { throw new MQTTProtocolException("Failed while intercepting subscribe", true, e); } }
public MQTTFrame encode() { try { DataByteArrayOutputStream os = new DataByteArrayOutputStream(); QoS qos = qos(); if(qos != QoS.AT_MOST_ONCE) { os.writeShort(messageId); } for(Topic topic: topics) { MessageSupport.writeUTF(os, topic.name()); os.writeByte(topic.qos().ordinal()); } MQTTFrame frame = new MQTTFrame(); frame.header(header()); frame.commandType(TYPE); return frame.buffer(os.toBuffer()); } catch (IOException e) { throw new RuntimeException("The impossible happened"); } }
TopicPB.Bean topic_pb = new TopicPB.Bean(); topic_pb.setName(topic.name()); topic_pb.setQos(topic.qos().ordinal()); topic_pb.setAddress(new UTF8Buffer(address.toString())); session_pb.addSubscriptions(topic_pb);