修改 字符串

This commit is contained in:
2026-05-12 22:12:19 +08:00
parent a6cda3e9dd
commit 6f0b573335
2 changed files with 22 additions and 9 deletions

View File

@@ -416,7 +416,7 @@ function AddHeartbeat(ws: WebSocket, connectionId: string) {
onDisconnect(ws, connectionId);
} else {
// 发送ping消息
ws.send(JSON.stringify({ from: connectionId, to: "", type: "on-message", data: { type: "ping"} }));
ws.send(JSON.stringify({ from: connectionId, to: "", type: "on-message", data: { type: "ping" }.toString() }));
log(LogLevel.log, 'WebSocket connection heartbeat, lastActivity: ', (ws as any).lastActivity);
}
}, 3000);
@@ -455,15 +455,15 @@ function onMessage(ws: WebSocket, message: any): void {
if (group.host === ws) {
// host发送消息转发给所有participants
group.participants.forEach(participantWs => {
participantWs.send(JSON.stringify({ from: connectionId, to: "", type: "on-message", data: chatMessage }));
participantWs.send(JSON.stringify({ from: connectionId, to: "", type: "on-message", data: JSON.stringify(chatMessage) }));
});
} else {
// participant发送消息转发给host附带participantId和其他participants
group.host.send(JSON.stringify({ from: connectionId, to: "", type: "on-message", data: chatMessage, participantId: senderParticipantId }));
group.host.send(JSON.stringify({ from: connectionId, to: "", type: "on-message", data: JSON.stringify(chatMessage), participantId: senderParticipantId }));
// 同时转发给其他participants排除发送者自身
group.participants.forEach(participantWs => {
if (participantWs !== ws) {
participantWs.send(JSON.stringify({ from: connectionId, to: "", type: "on-message", data: chatMessage, participantId: senderParticipantId }));
participantWs.send(JSON.stringify({ from: connectionId, to: "", type: "on-message", data: JSON.stringify(chatMessage), participantId: senderParticipantId }));
}
});
}