|
|
@@ -309,7 +309,7 @@ export function setupExamEvents({ socket, apiClient }: Variables) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- socket.emit('exam:cleaned', {
|
|
|
+ socket.to(roomId).emit('exam:cleaned', {
|
|
|
roomId,
|
|
|
message: questionId
|
|
|
? `已清理房间 ${roomId} 的问题 ${questionId} 数据`
|
|
|
@@ -476,4 +476,24 @@ export function setupExamEvents({ socket, apiClient }: Variables) {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ // 结算消息广播
|
|
|
+ socket.on('exam:settle', async (data: ExamRoomData) => {
|
|
|
+ try {
|
|
|
+ const { roomId } = data;
|
|
|
+ const user = socket.user;
|
|
|
+
|
|
|
+ if (!user) {
|
|
|
+ socket.emit('error', '未授权访问');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 广播结算消息到房间
|
|
|
+ socket.to(roomId).emit('exam:settle');
|
|
|
+
|
|
|
+ console.log(`用户 ${user.username} 在房间 ${roomId} 广播结算消息`);
|
|
|
+ } catch (error) {
|
|
|
+ console.error('广播结算消息失败:', error);
|
|
|
+ socket.emit('error', '广播结算消息失败');
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|