SUBACK ack = new SUBACK().decode(frame); completeRequest(ack.messageId(), SUBSCRIBE.TYPE, ack.grantedQos()); break;
void onSubscribe(SUBSCRIBE command) throws MQTTProtocolException { checkConnected(); LOG.trace("MQTT SUBSCRIBE message:{} client:{} connection:{}", command.messageId(), clientId, connectionInfo.getConnectionId()); Topic[] topics = command.topics(); if (topics != null) { byte[] qos = new byte[topics.length]; for (int i = 0; i < topics.length; i++) { try { qos[i] = onSubscribe(topics[i]); } catch (IOException e) { throw new MQTTProtocolException("Failed to process subscription request", true, e); } } SUBACK ack = new SUBACK(); ack.messageId(command.messageId()); ack.grantedQos(qos); try { getMQTTTransport().sendToMQTT(ack.encode()); } catch (IOException e) { LOG.warn("Couldn't send SUBACK for " + command, e); } } else { LOG.warn("No topics defined for Subscription " + command); } }
static private String toString(MQTTFrame frame) { if( frame == null ) return null; try { switch (frame.messageType()) { case PINGREQ.TYPE: return new PINGREQ().decode(frame).toString(); case PINGRESP.TYPE: return new PINGRESP().decode(frame).toString(); case CONNECT.TYPE: return new CONNECT().decode(frame).toString(); case DISCONNECT.TYPE: return new DISCONNECT().decode(frame).toString(); case SUBSCRIBE.TYPE: return new SUBSCRIBE().decode(frame).toString(); case UNSUBSCRIBE.TYPE: return new UNSUBSCRIBE().decode(frame).toString(); case PUBLISH.TYPE: return new PUBLISH().decode(frame).toString(); case PUBACK.TYPE: return new PUBACK().decode(frame).toString(); case PUBREC.TYPE: return new PUBREC().decode(frame).toString(); case PUBREL.TYPE: return new PUBREL().decode(frame).toString(); case PUBCOMP.TYPE: return new PUBCOMP().decode(frame).toString(); case CONNACK.TYPE: return new CONNACK().decode(frame).toString(); case SUBACK.TYPE: return new SUBACK().decode(frame).toString(); default: return frame.toString(); } } catch (Throwable e) { LOG.warn(e.getMessage(), e); return frame.toString(); } }
void onSubscribe(SUBSCRIBE command) throws MQTTProtocolException { checkConnected(); LOG.trace("MQTT SUBSCRIBE message:{} client:{} connection:{}", command.messageId(), clientId, connectionInfo.getConnectionId()); Topic[] topics = command.topics(); if (topics != null) { byte[] qos = new byte[topics.length]; for (int i = 0; i < topics.length; i++) { try { qos[i] = onSubscribe(topics[i]); } catch (IOException e) { throw new MQTTProtocolException("Failed to process subscription request", true, e); } } SUBACK ack = new SUBACK(); ack.messageId(command.messageId()); ack.grantedQos(qos); try { getMQTTTransport().sendToMQTT(ack.encode()); } catch (IOException e) { LOG.warn("Couldn't send SUBACK for " + command, e); } } else { LOG.warn("No topics defined for Subscription " + command); } }
static private String toString(MQTTFrame frame) { if( frame == null ) return null; try { switch (frame.messageType()) { case PINGREQ.TYPE: return new PINGREQ().decode(frame).toString(); case PINGRESP.TYPE: return new PINGRESP().decode(frame).toString(); case CONNECT.TYPE: return new CONNECT().decode(frame).toString(); case DISCONNECT.TYPE: return new DISCONNECT().decode(frame).toString(); case SUBSCRIBE.TYPE: return new SUBSCRIBE().decode(frame).toString(); case UNSUBSCRIBE.TYPE: return new UNSUBSCRIBE().decode(frame).toString(); case PUBLISH.TYPE: return new PUBLISH().decode(frame).toString(); case PUBACK.TYPE: return new PUBACK().decode(frame).toString(); case PUBREC.TYPE: return new PUBREC().decode(frame).toString(); case PUBREL.TYPE: return new PUBREL().decode(frame).toString(); case PUBCOMP.TYPE: return new PUBCOMP().decode(frame).toString(); case CONNACK.TYPE: return new CONNACK().decode(frame).toString(); case SUBACK.TYPE: return new SUBACK().decode(frame).toString(); default: return frame.toString(); } } catch (Throwable e) { LOG.warn(e.getMessage(), e); return frame.toString(); } }
void onSubscribe(SUBSCRIBE command) throws MQTTProtocolException { checkConnected(); LOG.trace("MQTT SUBSCRIBE message:{} client:{} connection:{}", command.messageId(), clientId, connectionInfo.getConnectionId()); Topic[] topics = command.topics(); if (topics != null) { byte[] qos = new byte[topics.length]; for (int i = 0; i < topics.length; i++) { MQTTProtocolSupport.validate(topics[i].name().toString()); try { qos[i] = findSubscriptionStrategy().onSubscribe(topics[i]); } catch (IOException e) { throw new MQTTProtocolException("Failed to process subscription request", true, e); } } SUBACK ack = new SUBACK(); ack.messageId(command.messageId()); ack.grantedQos(qos); try { getMQTTTransport().sendToMQTT(ack.encode()); } catch (IOException e) { LOG.warn("Couldn't send SUBACK for " + command, e); } } else { LOG.warn("No topics defined for Subscription " + command); throw new MQTTProtocolException("SUBSCRIBE command received with no topic filter"); } }
SUBACK ack = new SUBACK().decode(frame); completeRequest(ack.messageId(), SUBSCRIBE.TYPE, ack.grantedQos()); break;
static private String toString(MQTTFrame frame) { if( frame == null ) return null; try { switch (frame.messageType()) { case PINGREQ.TYPE: return new PINGREQ().decode(frame).toString(); case PINGRESP.TYPE: return new PINGRESP().decode(frame).toString(); case CONNECT.TYPE: return new CONNECT().decode(frame).toString(); case DISCONNECT.TYPE: return new DISCONNECT().decode(frame).toString(); case SUBSCRIBE.TYPE: return new SUBSCRIBE().decode(frame).toString(); case UNSUBSCRIBE.TYPE: return new UNSUBSCRIBE().decode(frame).toString(); case PUBLISH.TYPE: return new PUBLISH().decode(frame).toString(); case PUBACK.TYPE: return new PUBACK().decode(frame).toString(); case PUBREC.TYPE: return new PUBREC().decode(frame).toString(); case PUBREL.TYPE: return new PUBREL().decode(frame).toString(); case PUBCOMP.TYPE: return new PUBCOMP().decode(frame).toString(); case CONNACK.TYPE: return new CONNACK().decode(frame).toString(); case SUBACK.TYPE: return new SUBACK().decode(frame).toString(); default: return frame.toString(); } } catch (Throwable e) { LOG.warn(e.getMessage(), e); return frame.toString(); } }
void onSubscribe(SUBSCRIBE command) throws MQTTProtocolException { checkConnected(); LOG.trace("MQTT SUBSCRIBE message:{} client:{} connection:{}", command.messageId(), clientId, connectionInfo.getConnectionId()); Topic[] topics = command.topics(); if (topics != null) { byte[] qos = new byte[topics.length]; for (int i = 0; i < topics.length; i++) { MQTTProtocolSupport.validate(topics[i].name().toString()); try { qos[i] = findSubscriptionStrategy().onSubscribe(topics[i]); } catch (IOException e) { throw new MQTTProtocolException("Failed to process subscription request", true, e); } } SUBACK ack = new SUBACK(); ack.messageId(command.messageId()); ack.grantedQos(qos); try { getMQTTTransport().sendToMQTT(ack.encode()); } catch (IOException e) { LOG.warn("Couldn't send SUBACK for " + command, e); } } else { LOG.warn("No topics defined for Subscription " + command); throw new MQTTProtocolException("SUBSCRIBE command received with no topic filter"); } }
void onSubscribe(SUBSCRIBE command) throws MQTTProtocolException { checkConnected(); LOG.trace("MQTT SUBSCRIBE message:{} client:{} connection:{}", command.messageId(), clientId, connectionInfo.getConnectionId()); Topic[] topics = command.topics(); if (topics != null) { byte[] qos = new byte[topics.length]; for (int i = 0; i < topics.length; i++) { MQTTProtocolSupport.validate(topics[i].name().toString()); try { qos[i] = findSubscriptionStrategy().onSubscribe(topics[i]); } catch (IOException e) { throw new MQTTProtocolException("Failed to process subscription request", true, e); } } SUBACK ack = new SUBACK(); ack.messageId(command.messageId()); ack.grantedQos(qos); try { getMQTTTransport().sendToMQTT(ack.encode()); } catch (IOException e) { LOG.warn("Couldn't send SUBACK for " + command, e); } } else { LOG.warn("No topics defined for Subscription " + command); throw new MQTTProtocolException("SUBSCRIBE command received with no topic filter"); } }