fix(meeting): Task 16 会议销毁路径资源清理专项
前端修复: - _onRoomEnded 保留结束页数据,新增 exitEndedRoom() 动作 room.vue onUnload 在 ENDED 状态调用,释放 currentRoom / participants / chatMessages 等 pinia state - endMeeting() API 成功后立即触发 _onRoomEnded 本地兜底,不再依赖 room.ended 广播 避免 API 成功但 WS 抖动导致 engine / timer / AudioContext 泄漏 - 新增 _pendingBroadcastTimers 集合收纳 _broadcastSelfState 的 setTimeout 句柄 _cleanupMedia 统一 clearTimeout,避免会议结束后 stale 重试逻辑排队 后端修复: - MeetingLifecycleService.OnRoomEnded 统一生命周期收尾 取消 graceTimers / emptyTTLTimers + Pipeline DEL host_grace / empty_ttl / 两个 handling 锁 key - EndRoom 事务提交后遍历 activesBefore 调 cleanupRoomRedisResidual 批量 DEL 每个前任活跃成员的 resourceTrackKey + memberStateKey 补调 lifecycleSvc.OnRoomEnded 清理自身 timer + keys - HandleEmptyRoomExpired MarkEnded 后补调 cleanupRoomRedisResidual + 清 host_grace 残留 验证:go vet + go build + npm run build:h5 全部通过 Made-with: Cursor
This commit is contained in:
@@ -575,6 +575,18 @@ func (s *MeetingService) EndRoom(ctx context.Context, userID int64, code string)
|
||||
logs.Warn(ctx, funcName, "关闭 mediasoup Router 失败", zap.Error(err))
|
||||
}
|
||||
|
||||
// Task 16 资源清理专项:EndRoom 场景下 WS 断开钩子尚未触发(用户客户端可能仍在会议页),
|
||||
// 需主动清每个活跃成员在 Redis 的资源追踪集合 + 音视频状态 Hash,避免短期反复开会累积垃圾条目
|
||||
userIDs := make([]int64, 0, len(activesBefore))
|
||||
for _, p := range activesBefore {
|
||||
userIDs = append(userIDs, p.UserID)
|
||||
}
|
||||
cleanupRoomRedisResidual(ctx, s.redis, code, userIDs)
|
||||
// 取消生命周期 timer + 清 host_grace / empty_ttl / handling 锁 key(幂等)
|
||||
if s.lifecycleSvc != nil {
|
||||
s.lifecycleSvc.OnRoomEnded(ctx, code)
|
||||
}
|
||||
|
||||
logs.Info(ctx, funcName, "会议已结束", zap.String("room_code", code), zap.Int64("host_id", userID))
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user