视频会议
This commit is contained in:
@@ -435,11 +435,25 @@ func (s *MeetingService) JoinRoom(ctx context.Context, userID int64, code, passw
|
||||
}
|
||||
|
||||
// Task 8:JoinRoom 不再主动调 CreateRouter(Router 在 CreateRoom 时创建、由 HTTPMediaOrchestrator 本地缓存)
|
||||
// 从缓存读取 routerID;缺失时(极少见:服务重启后未重建缓存)保持为空,不阻塞加入流程
|
||||
// 从缓存读取 routerID;缺失时(go-service / media-server 重启且 Redis 也丢了 / 历史房间无缓存)走兜底重建:
|
||||
// 房间状态仍为 Active,但 mediasoup 侧已无该 Router → 直接 CreateRouter 重新拉起,对 Node 是新房间不会冲突。
|
||||
// 失败则与 CreateRoom 保持一致:返回 ErrMediaServiceUnavailable,前端提示重试。
|
||||
routerID, _ := s.mediaOrchestrator.ResolveRouterID(code)
|
||||
if routerID == "" {
|
||||
logs.Debug(ctx, funcName, "RouterID 缓存缺失(非致命,可能服务重启)",
|
||||
logs.Warn(ctx, funcName, "RouterID 缓存缺失,触发 CreateRouter 兜底重建",
|
||||
zap.String("room_code", code))
|
||||
newID, mediaErr := s.mediaOrchestrator.CreateRouter(ctx, code)
|
||||
if mediaErr != nil {
|
||||
logs.Error(ctx, funcName, "兜底 CreateRouter 失败",
|
||||
zap.String("room_code", code), zap.Int64("user_id", userID), zap.Error(mediaErr))
|
||||
// 已写入 participant 行:补偿离开,避免占用"一人一会议"名额
|
||||
if _, leaveErr := s.participantDAO.LeaveRoom(ctx, room.ID, userID, constants.MeetingLeftReasonSelf); leaveErr != nil {
|
||||
logs.Warn(ctx, funcName, "兜底失败后 LeaveRoom 失败(清理任务会兜底)",
|
||||
zap.Int64("room_id", room.ID), zap.Int64("user_id", userID), zap.Error(leaveErr))
|
||||
}
|
||||
return nil, nil, "", ErrMediaServiceUnavailable
|
||||
}
|
||||
routerID = newID
|
||||
}
|
||||
|
||||
// 广播 payload 附带 user_name / user_avatar,前端 _onMemberJoined 直接落库,无需二次拉取
|
||||
|
||||
Reference in New Issue
Block a user