Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-26 17:03:58 +08:00
commit c2e64e630b
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
package io.renren.websocket.task;
import io.renren.modules.job.task.ITask;
import io.renren.websocket.WebSocketServer;
import io.renren.websocket.data.MessageData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* 与websocket客户端定时心跳
*/
@Component("heartRateTask")
public class HeartRateTask implements ITask {
private static final Logger logger = LoggerFactory.getLogger(HeartRateTask.class);
@Autowired
private WebSocketServer webSocketServer;
/**
* 执行定时任务接口
*
* @param params 参数多参数使用JSON数据
*/
@Override
public void run(String params) {
logger.info("websocket心跳");
MessageData<String> message = new MessageData<String>().msg("heartRate:" + LocalDateTime.now());
webSocketServer.sendMessageAll(message);
}
}