package com.ffii.towngas.config;

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

public class MqttConsumerCallBack implements MqttCallback {
  @Override
  public void connectionLost(Throwable throwable) {
    System.out.println("Disconnected with server");
  }

  @Override
  public void messageArrived(String topic, MqttMessage message) throws Exception {
    System.out.println(String.format("Topic: %s", topic));
    System.out.println(String.format("Qos : %d", message.getQos()));
    System.out.println(String.format("Content: %s", new String(message.getPayload())));
    System.out.println(String.format("Retained : %b", message.isRetained()));
  }

  @Override
  public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {

  }
}