紧急修复麦位

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

View File

@ -72,15 +72,21 @@ public class AgoraMicStateReconcileTask {
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) {
if (Objects.isNull(microphone) || Objects.isNull(microphone.getUser())) {
continue;
}
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(),
"reconcile agora broadcaster missing");
"reconcile agora user missing");
}
}
}