zhubaomin
2025-04-07 e67870fff62635cd14beb0d5988f08aeef4b22fa
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/largeScreen/WebSocketHeartBeat.java
New file
@@ -0,0 +1,31 @@
package com.dy.pipIrrRemote.largeScreen;
/**
 * @Author: liurunyu
 * @Date: 2025/2/11 8:37
 * @Description
 */
import com.alibaba.fastjson2.JSON;
import com.dy.common.util.DateTime;
import com.dy.common.webUtil.WebSocketMessage;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class WebSocketHeartBeat {
    // 设置定时十秒一次
    @Scheduled(cron = "0/10 * * * * ?")
    public void WsHeartBeat() throws Exception {
        WebSocketServer.sendMessage2AllClient(getHeartBeatMessage());
    }
    public static String getHeartBeatMessage() {
        WebSocketMessage vo = new WebSocketMessage() ;
        vo.type = WebSocketMessage.TYPE_HEARTBEAT ;
        vo.content = DateTime.yyyy_MM_dd_HH_mm_ss() ;
        return JSON.toJSONString(vo) ;
    }
}