package com.yeejoin.amos.patrol.mqtt;

import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttPersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper;

@Component
public class WebMqttComponent {
	@Autowired
    private EmqKeeper emqKeeper;

	public void publish(String topic, String jsonStr) {
		try {
			this.emqKeeper.getMqttClient().publish(topic, jsonStr.getBytes(), 1, false);
		} catch (MqttPersistenceException e) {
			e.printStackTrace();
		} catch (MqttException e) {
			e.printStackTrace();
		}
	}
}
