Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-26 19:45:40 +08:00
commit f997270565
2 changed files with 13 additions and 3 deletions

View File

@ -101,4 +101,8 @@ public class WebSocketServer {
log.error("send message error" + e.getMessage(), e);
}
}
public static Map<String, WebSocketData> getServers() {
return servers;
}
}

View File

@ -28,8 +28,14 @@ public class HeartRateTask implements ITask {
*/
@Override
public void run(String params) {
logger.info("websocket心跳");
MessageData<String> message = new MessageData<String>().msg("heartRate:" + LocalDateTime.now());
webSocketServer.sendMessageAll(message);
try {
if (webSocketServer.getServers().isEmpty()) {
return;
}
MessageData<String> message = new MessageData<String>().msg("heartRate:" + LocalDateTime.now());
webSocketServer.sendMessageAll(message);
} catch (Exception exception) {
logger.error("websocket客户端心跳失败", exception);
}
}
}