紧急修复麦位

This commit is contained in:
hy001 2026-04-29 09:58:59 +08:00
parent 5339742f69
commit 096e37612e
2 changed files with 26 additions and 17 deletions

View File

@ -307,21 +307,24 @@ public class UserHeartbeatListener implements MessageListener {
? checkedChannelState ? checkedChannelState
: agoraRoomStateService.getChannelState(roomProfile.getId()); : agoraRoomStateService.getChannelState(roomProfile.getId());
if (!channelState.querySuccess()) { if (!channelState.querySuccess()) {
log.warn("心跳刷新麦位跳过,声网查询失败 roomId={}, userId={}, response={}", log.warn("心跳刷新麦位声网查询失败,降级刷新业务麦位 roomId={}, userId={}, response={}",
roomProfile.getId(), userProfile.getId(), channelState.getRawResponse()); roomProfile.getId(), userProfile.getId(), channelState.getRawResponse());
liveMicrophoneGateway.refreshNotActiveUser(roomProfile); refreshMicActiveTimeWithoutAgoraCheck(event, roomProfile, liveMicrophone);
return; return;
} }
Long agoraUid = DataTypeUtils.toLong(userProfile.getAccount()); if (!isUserInAgoraChannel(channelState, userProfile)) {
if (!channelState.channelExist() || Objects.isNull(agoraUid)
|| CollectionUtils.isEmpty(channelState.getBroadcasters())
|| !channelState.getBroadcasters().contains(agoraUid)) {
agoraMicStateCleanupService.cleanupUser(roomProfile.getId(), userProfile.getId(), agoraMicStateCleanupService.cleanupUser(roomProfile.getId(), userProfile.getId(),
"heartbeat agora broadcaster missing"); "heartbeat agora user missing");
return; return;
} }
refreshMicActiveTimeWithoutAgoraCheck(event, roomProfile, liveMicrophone);
}
private void refreshMicActiveTimeWithoutAgoraCheck(UserHeartbeatEvent event,
RoomProfileDTO roomProfile,
LiveMicrophone liveMicrophone) {
// 刷新活跃时间 // 刷新活跃时间
if (liveMicCacheService.checkLockMic(roomProfile.getId(), liveMicrophone.getMicIndex())) { if (liveMicCacheService.checkLockMic(roomProfile.getId(), liveMicrophone.getMicIndex())) {
event.setRetryRefreshMick(true); event.setRetryRefreshMick(true);

View File

@ -72,15 +72,21 @@ public class AgoraMicStateReconcileTask {
return; return;
} }
Set<Long> broadcasterUids = new HashSet<>(state.getBroadcasters()); Set<Long> channelUids = new HashSet<>();
if (CollectionUtils.isNotEmpty(state.getBroadcasters())) {
channelUids.addAll(state.getBroadcasters());
}
if (CollectionUtils.isNotEmpty(state.getAudience())) {
channelUids.addAll(state.getAudience());
}
for (LiveMicrophone microphone : microphones) { for (LiveMicrophone microphone : microphones) {
if (Objects.isNull(microphone) || Objects.isNull(microphone.getUser())) { if (Objects.isNull(microphone) || Objects.isNull(microphone.getUser())) {
continue; continue;
} }
Long agoraUid = DataTypeUtils.toLong(microphone.getUser().getAccount()); Long agoraUid = DataTypeUtils.toLong(microphone.getUser().getAccount());
if (Objects.isNull(agoraUid) || !broadcasterUids.contains(agoraUid)) { if (Objects.isNull(agoraUid) || !channelUids.contains(agoraUid)) {
agoraMicStateCleanupService.cleanupUser(roomId, microphone.getUser().getId(), agoraMicStateCleanupService.cleanupUser(roomId, microphone.getUser().getId(),
"reconcile agora broadcaster missing"); "reconcile agora user missing");
} }
} }
} }