New file |
| | |
| | | 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) ; |
| | | } |
| | | |
| | | } |