//package com.ho.filecenter.config;
//
//import cn.hutool.core.util.IdUtil;
//import com.ho.filecenter.util.AnotherMqttConfigUtil;
//import lombok.Data;
//import lombok.extern.slf4j.Slf4j;
//import org.eclipse.paho.client.mqttv3.IMqttToken;
//import org.eclipse.paho.client.mqttv3.MqttClient;
//import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
///**
// * @author wp
// * @desc: Mqtt配置类
// * @date 2025/06/11
// */
//@Configuration
//@Data
//@ConfigurationProperties("mqtt1")
//@Slf4j
//public class AnotherMqttConfig {
//
//    //服务器url
//    @Value("${mqtt1.url}")
//    String url;
//    //超时时间
//    @Value("${mqtt1.timeout}")
//    Integer timeout;
//    //会话保持时间
//    @Value("${mqtt1.keepAlive}")
//    Integer keepAlive;
//
//    @Value("${mqtt1.userName}")
//    String userName;
//
//    @Value("${mqtt1.passWord}")
//    String passWord;
//
//    @Autowired
//    AnotherFileEdgeResponseConsumer fileEdgeResponseConsumer;
//
//    //文件响应
//    @Bean(name = "AnotherFileEdgeResponse")
//    public MqttClient initFileResponseClient() {
//        String clientId = IdUtil.simpleUUID();
//        log.info("clientId:" + clientId);
//        MqttClient client =null;
//        try {
//            client = new MqttClient(url, clientId,null);
//            MqttConnectOptions options = new MqttConnectOptions();
//            options.setUserName(userName);
//            options.setPassword(passWord.toCharArray());
//            options.setCleanSession(true);
//            options.setConnectionTimeout(timeout);
//            options.setKeepAliveInterval(keepAlive);
//            client.setCallback(fileEdgeResponseConsumer);
//            IMqttToken iMqttToken = client.connectWithResult(options);
//            boolean complete = iMqttToken.isComplete();
//            log.info("FileResponseClient建立连接：{}", complete);
//
//            //这里监听的是
//            String[] topic = AnotherMqttConfigUtil.getFileResponseTopic();
//            int[] qos = new int[topic.length];
//            client.subscribe(topic,qos);
//            log.info("已订阅topic：{}", topic);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return client;
//    }
//}
