package com.hw.mqtt.task;

import net.dreamlu.iot.mqtt.core.server.MqttServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.nio.charset.StandardCharsets;

/**
 * 自定义任务：心跳下发
 * @author WenJY
 * @date 2023-03-14 12:16
 * @param null
 * @return null
 */
@Service
public class PublishAllTask {
	@Autowired
	private MqttServer mqttServer;

	@Scheduled(fixedDelay = 1000)
	public void run() {
		mqttServer.publishAll("/test/heartbeat", "心跳指令无需处理".getBytes(StandardCharsets.UTF_8));
	}

}
