观影室新增语音聊天

This commit is contained in:
mtvpls
2025-12-09 00:59:07 +08:00
parent 50ecb4f056
commit 59e1f9f1c6
4 changed files with 613 additions and 22 deletions
+13
View File
@@ -305,6 +305,19 @@ class WatchRoomServer {
});
});
// 语音聊天 - 服务器中转音频数据
socket.on('voice:audio-chunk', (data) => {
const roomInfo = this.socketToRoom.get(socket.id);
if (!roomInfo) return;
// 将音频数据转发给房间内的其他成员
socket.to(roomInfo.roomId).emit('voice:audio-chunk', {
userId: socket.id,
audioData: data.audioData,
sampleRate: data.sampleRate || 16000,
});
});
// 心跳
socket.on('heartbeat', () => {
const roomInfo = this.socketToRoom.get(socket.id);