public UNSUBSCRIBE() { qos(QoS.AT_LEAST_ONCE); }
@Override public String toString() { return "UNSUBSCRIBE{" + "dup=" + dup() + ", qos=" + qos() + ", messageId=" + messageId + ", topics=" + (topics == null ? null : Arrays.asList(topics)) + '}'; } }
public MQTTFrame encode() { try { DataByteArrayOutputStream os = new DataByteArrayOutputStream(); QoS qos = qos(); if(qos != QoS.AT_MOST_ONCE) { os.writeShort(messageId); } for(UTF8Buffer topic: topics) { MessageSupport.writeUTF(os, topic); } MQTTFrame frame = new MQTTFrame(); frame.header(header()); frame.commandType(TYPE); return frame.buffer(os.toBuffer()); } catch (IOException e) { throw new RuntimeException("The impossible happened"); } }
public UNSUBSCRIBE() { qos(QoS.AT_LEAST_ONCE); }
@Override public String toString() { return "UNSUBSCRIBE{" + "dup=" + dup() + ", qos=" + qos() + ", messageId=" + messageId + ", topics=" + (topics == null ? null : Arrays.asList(topics)) + '}'; } }
public MQTTFrame encode() { try { DataByteArrayOutputStream os = new DataByteArrayOutputStream(); QoS qos = qos(); if(qos != QoS.AT_MOST_ONCE) { os.writeShort(messageId); } for(UTF8Buffer topic: topics) { MessageSupport.writeUTF(os, topic); } MQTTFrame frame = new MQTTFrame(); frame.header(header()); frame.commandType(TYPE); return frame.buffer(os.toBuffer()); } catch (IOException e) { throw new RuntimeException("The impossible happened"); } }
public void onUnSubscribe(UNSUBSCRIBE command) throws MQTTProtocolException { checkConnected(); if (command.qos() != QoS.AT_LEAST_ONCE && (version != V3_1 || publishDollarTopics != true)) { throw new MQTTProtocolException("Failed to process unsubscribe request", true, new Exception("UNSUBSCRIBE frame not properly formatted, QoS")); } UTF8Buffer[] topics = command.topics(); if (topics != null) { for (UTF8Buffer topic : topics) { MQTTProtocolSupport.validate(topic.toString()); try { findSubscriptionStrategy().onUnSubscribe(topic.toString()); } catch (IOException e) { throw new MQTTProtocolException("Failed to process unsubscribe request", true, e); } } UNSUBACK ack = new UNSUBACK(); ack.messageId(command.messageId()); sendToMQTT(ack.encode()); } else { LOG.warn("No topics defined for Subscription " + command); throw new MQTTProtocolException("UNSUBSCRIBE command received with no topic filter"); } }
public void onUnSubscribe(UNSUBSCRIBE command) throws MQTTProtocolException { checkConnected(); if (command.qos() != QoS.AT_LEAST_ONCE && (version != V3_1 || publishDollarTopics != true)) { throw new MQTTProtocolException("Failed to process unsubscribe request", true, new Exception("UNSUBSCRIBE frame not properly formatted, QoS")); } UTF8Buffer[] topics = command.topics(); if (topics != null) { for (UTF8Buffer topic : topics) { MQTTProtocolSupport.validate(topic.toString()); try { findSubscriptionStrategy().onUnSubscribe(topic.toString()); } catch (IOException e) { throw new MQTTProtocolException("Failed to process unsubscribe request", true, e); } } UNSUBACK ack = new UNSUBACK(); ack.messageId(command.messageId()); sendToMQTT(ack.encode()); } else { LOG.warn("No topics defined for Subscription " + command); throw new MQTTProtocolException("UNSUBSCRIBE command received with no topic filter"); } }
public void onUnSubscribe(UNSUBSCRIBE command) throws MQTTProtocolException { checkConnected(); if (command.qos() != QoS.AT_LEAST_ONCE && (version != V3_1 || publishDollarTopics != true)) { throw new MQTTProtocolException("Failed to process unsubscribe request", true, new Exception("UNSUBSCRIBE frame not properly formatted, QoS")); } UTF8Buffer[] topics = command.topics(); if (topics != null) { for (UTF8Buffer topic : topics) { MQTTProtocolSupport.validate(topic.toString()); try { findSubscriptionStrategy().onUnSubscribe(topic.toString()); } catch (IOException e) { throw new MQTTProtocolException("Failed to process unsubscribe request", true, e); } } UNSUBACK ack = new UNSUBACK(); ack.messageId(command.messageId()); sendToMQTT(ack.encode()); } else { LOG.warn("No topics defined for Subscription " + command); throw new MQTTProtocolException("UNSUBSCRIBE command received with no topic filter"); } }