package com.gxwebsoft.hjm.controller;

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 推送消息的回调类
 */
public class PushCallback implements MqttCallback {
  private static final Logger logger = LoggerFactory.getLogger(PushCallback.class);
  @Override
  public void connectionLost(Throwable throwable) {
    logger.info("连接丢失.............");
  }

  @Override
  public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
    logger.info("接收消息主题 : " + topic);
    logger.info("接收消息Qos : " + mqttMessage.getQos());
    logger.info("接收消息内容 : " + new String(mqttMessage.getPayload()));

  }

  @Override
  public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
    logger.info("deliveryComplete.............");
  }
}
