修改推送数据格式
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
|
||||
// 引入客户端管理模块,用于维护连接的客户端
|
||||
const clients = require('./clients');
|
||||
const timestamp = require('../utils/timeFormatter');
|
||||
|
||||
/**
|
||||
* 设置 SSE(Server-Sent Events)响应头,确保客户端能够正确接收事件流
|
||||
@ -27,7 +28,7 @@ function setupSSEHeaders(res) {
|
||||
function sendHeartbeat() {
|
||||
const data = {
|
||||
event: 'heartbeat', // 事件类型为 heartbeat
|
||||
time: new Date().toISOString() // 当前时间的 ISO 字符串格式
|
||||
time: timestamp.formatTime() // 当前时间的 ISO 字符串格式
|
||||
};
|
||||
return clients.broadcast(data); // 广播给所有连接的客户端
|
||||
}
|
||||
|
Reference in New Issue
Block a user