bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-modal/service.js
prlanzarin a748d8ccbb fix(audio): remove listen only retry routines
Listen only has a built-in retry routine on join failures that's
convoluted half-broken. It stems from the Kurento era where it could
fail randomly due to a myriad of reasons.
Production logs indicate that the retry is seldom used nowadays in
mediasoup-based environments. The presence of the retry also breaks
the error troubleshooting modal when actual failures happening, leaving
users in the dark about what's happening.

Remove the listen only retry code from AudioManager and bubble up any
join failure to the callers.
2024-05-03 21:18:44 +00:00

92 lines
2.6 KiB
JavaScript

import Service from '../service';
import Storage from '/imports/ui/services/storage/session';
const CLIENT_DID_USER_SELECTED_MICROPHONE_KEY = 'clientUserSelectedMicrophone';
const CLIENT_DID_USER_SELECTED_LISTEN_ONLY_KEY = 'clientUserSelectedListenOnly';
const TROUBLESHOOTING_LINKS = Meteor.settings.public.media.audioTroubleshootingLinks;
export const setUserSelectedMicrophone = (value) => (
Storage.setItem(CLIENT_DID_USER_SELECTED_MICROPHONE_KEY, !!value)
);
export const setUserSelectedListenOnly = (value) => (
Storage.setItem(CLIENT_DID_USER_SELECTED_LISTEN_ONLY_KEY, !!value)
);
export const didUserSelectedMicrophone = () => (
!!Storage.getItem(CLIENT_DID_USER_SELECTED_MICROPHONE_KEY)
);
export const didUserSelectedListenOnly = () => (
!!Storage.getItem(CLIENT_DID_USER_SELECTED_LISTEN_ONLY_KEY)
);
export const joinMicrophone = (skipEchoTest = false) => {
Storage.setItem(CLIENT_DID_USER_SELECTED_MICROPHONE_KEY, true);
Storage.setItem(CLIENT_DID_USER_SELECTED_LISTEN_ONLY_KEY, false);
const call = new Promise((resolve, reject) => {
try {
if ((skipEchoTest && !Service.isConnected()) || Service.localEchoEnabled) {
return resolve(Service.joinMicrophone());
}
return resolve(Service.transferCall());
} catch {
return reject(Service.exitAudio);
}
});
return call.then(() => {
document.dispatchEvent(new Event("CLOSE_MODAL_AUDIO"));
}).catch((error) => {
throw error;
});
};
export const joinListenOnly = () => {
Storage.setItem(CLIENT_DID_USER_SELECTED_MICROPHONE_KEY, false);
Storage.setItem(CLIENT_DID_USER_SELECTED_LISTEN_ONLY_KEY, true);
return Service.joinListenOnly().then(() => {
// Autoplay block wasn't triggered. Close the modal. If autoplay was
// blocked, that'll be handled in the modal component when then
// prop transitions to a state where it was handled OR the user opts
// to close the modal.
if (!Service.autoplayBlocked()) {
document.dispatchEvent(new Event("CLOSE_MODAL_AUDIO"));
}
}).catch((error) => {
throw error;
});
};
export const leaveEchoTest = () => {
if (!Service.isEchoTest()) {
return Promise.resolve();
}
return Service.exitAudio();
};
export const closeModal = (callback) => {
if (Service.isConnecting()) {
Service.forceExitAudio();
}
callback();
};
const getTroubleshootingLink = (errorCode) => {
if (TROUBLESHOOTING_LINKS) return TROUBLESHOOTING_LINKS[errorCode] || TROUBLESHOOTING_LINKS[0];
return null;
};
export default {
joinMicrophone,
closeModal,
joinListenOnly,
leaveEchoTest,
didUserSelectedMicrophone,
didUserSelectedListenOnly,
getTroubleshootingLink,
};