package cn.iocoder.yudao.module.pms.abc.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

@Slf4j
@Service
public class DeviceMqttService {
    @Autowired
    private MqttClientManager mqttClientManager;

    @PostConstruct
    public void initDeviceSubscription() {
        // 批量订阅多个设备 Topic（即使启动时设备未在线，后续上线也能接收消息）
        String[] deviceTopics = {
                "/649/YF6660355/property/post"
        };
        mqttClientManager.batchSubscribe(deviceTopics);

        // 动态新增单个设备订阅
//        mqttClientManager.subscribe("/636/YF652/property/post");
    }
}