package com.template.util;

import com.template.service.TemplateService;
import lombok.extern.log4j.Log4j2;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;

/**
 * @Author：liuxinyue
 * @Package：com.template.util
 * @Project：cloud-server
 * @name：Test1
 * @Date：2024/9/27 22:39
 */
@Log4j2
public class Test1 implements MqttCallback{

    @Resource
    private static TemplateService templateService;


    @Override
    public void connectionLost(Throwable throwable) {
     log.error(throwable.getMessage(), throwable);
    }

    @Override
    public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
      log.info("收到了来自:"+mqttMessage.toString()+"的消息:{}",new String(mqttMessage.getPayload()));
    }

    @Override
    public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
      log.info("发布消息成功");
    }
}
