April 2017
Intermediate to advanced
280 pages
6h 18m
English
The following lines continue the declaration of the public static main method. The code file for the sample is included in the mqtt_essentials_gaston_hillar_04 folder, in the Java01/src/Main.java file:
mqttAsyncClient.setCallback(new MqttCallback() { @Override public void connectionLost(Throwable cause) { cause.printStackTrace(); } @Override public void deliveryComplete(IMqttDeliveryToken token) { } @Override public void messageArrived(String topic, MqttMessage message) throws Exception { if (!topic.equals(topic_for_led01)) { return; } String messageText = new String(message.getPayload(), "UTF-8"); System.out.println( String.format("Topic: %s. Payload: %s", topic, messageText)); } }); ...Read now
Unlock full access