package com.inspect.mqtt;

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;

public class OnMessageCallback implements MqttCallback {
    public void connectionLost(Throwable cause) {
        System.out.println("MQTT DISCONNECT, PLEASE RECONNECT!");
    }

    public void messageArrived(String topic, MqttMessage message) throws Exception {
        System.out.println("MQTT topic: " + topic);
        System.out.println("MQTT Qos: " + message.getQos());
        System.out.println("MQTT Payload: " + new String(message.getPayload()));
    }

    public void deliveryComplete(IMqttDeliveryToken token) {
        System.out.println("MQTT deliveryComplete: " + token.isComplete());
    }
}
