package com.zd.laboratory.mqtt.test;

import com.zd.laboratory.config.HardwareFunctionStatusConfig;
import com.zd.laboratory.mqtt.constants.MqttConstants;
import com.zd.laboratory.mqtt.service.impl.SubMessageSendManager;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Profile;
import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;
import org.springframework.stereotype.Component;

/**
 * @Author: zhoupan
 * @Date: 2021/10/08/13:09
 * @Description:
 */

@Profile("dev")
@Component
public class MqttTest implements ApplicationListener<ApplicationStartedEvent> {



    @Override
    public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {
//        MqttPahoMessageDrivenChannelAdapter messageProducer = (MqttPahoMessageDrivenChannelAdapter)applicationStartedEvent.getApplicationContext().getBeanFactory().getBean("inbound");
//        //添加主题
//        messageProducer.addTopic(MqttConstants.LAB_FUNCTION_DATA+-1L);
//
//        SubMessageSendManager bean = applicationStartedEvent.getApplicationContext().getBeanFactory().getBean(SubMessageSendManager.class);
//        HardwareFunctionStatusConfig function = applicationStartedEvent.getApplicationContext().getBeanFactory().getBean(HardwareFunctionStatusConfig.class);
//        //发送一个测试测点数据
//        bean.sendFunctionUpdate(-1L,function.getSensorFunctionStatuses());


    }
}
