Merge branch 'master' into docker_package
This commit is contained in:
commit
c2e64e630b
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue