Partager via


Guide pratique pour détecter si une application qui utilise le SDK d’Azure Communication Services est active sous plusieurs onglets d’un navigateur

Conformément aux bonnes pratiques, votre application ne doit pas se connecter à des appels de plusieurs onglets de navigateur simultanément. La gestion d’appels multiples sous plusieurs onglets d’un navigateur sur un appareil mobile peut entraîner un comportement non défini en raison de l’allocation de ressources au microphone et à la caméra de l’appareil. Pour détecter si une application est active sous plusieurs onglets d’un navigateur, un développeur peut utiliser la méthode isCallClientActiveInAnotherTab et l’événement isCallClientActiveInAnotherTabChanged d’une instance CallClient.

const callClient = new CallClient();
// Check if an application is active in multiple tabs of a browser
const isCallClientActiveInAnotherTab = callClient.feature(SDK.Features.DebugInfo).isCallClientActiveInAnotherTab;
...
// Subscribe to the event to listen for changes 
callClient.feature(Features.DebugInfo).on('isCallClientActiveInAnotherTabChanged', () => {
    // callback();
});
...
// Unsubscribe from the event to stop listening for changes 
callClient.feature(Features.DebugInfo).off('isCallClientActiveInAnotherTabChanged', () => {
    // callback();
});