package com.inspect.mqtt.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@EnableScheduling
@Component("SendHeartTask")
public class SendHeartTask {
    @Resource
    ISendHeartServer sendHeartServer;

    private static SendHeartTask sendHeartTask;

    public void init() {
        sendHeartTask = this;
        sendHeartTask.sendHeartServer = this.sendHeartServer;
    }

    @Scheduled(
            cron = "0/30 * * * * ?"
    )
    public void sendHeart() {
        this.sendHeartServer.sendHeart();
    }
}
