52 lines
1.4 KiB
Java
52 lines
1.4 KiB
Java
package com.template.util;
|
||
import com.muyu.common.core.domain.Result;
|
||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||
import com.template.domain.MessageTemplateType;
|
||
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 org.springframework.web.bind.annotation.GetMapping;
|
||
|
||
import javax.annotation.Resource;
|
||
import java.util.ArrayList;
|
||
import java.util.List;
|
||
import java.util.concurrent.CompletableFuture;
|
||
import java.util.concurrent.ExecutionException;
|
||
|
||
/**
|
||
* @Author:liuxinyue
|
||
* @Package:com.template.util
|
||
* @Project:cloud-server
|
||
* @name:Callback
|
||
* @Date:2024/9/26 15:23
|
||
*/
|
||
@Log4j2
|
||
public class Callback 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("收到了来自:"+s+"的消息:{}",new String(mqttMessage.getPayload()));
|
||
}
|
||
|
||
@Override
|
||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||
log.info("发布消息成功");
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|