package org.springblade;

import org.springblade.mqtt.MqttRecieveCallback;
import org.springblade.mqtt.MyMqttClient;
import org.springblade.mqtt.TendaConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(value = 1)
public class MyApplicationRunner implements ApplicationRunner {

	@Autowired
	private MyMqttClient myMqttClient;
	@Autowired
	private MqttRecieveCallback mqttReceriveCallback;
	@Autowired
	private TendaConfig tendaConfig;

	@Override
	public void run(ApplicationArguments args) throws Exception {
		myMqttClient.init(tendaConfig, mqttReceriveCallback);
		myMqttClient.subTopic(tendaConfig.getTopic());
	}
}
