Handle forced disconnects from Jitsi (#21697)
This commit is contained in:
parent
ecf1c41f7c
commit
ef1d90ad41
1 changed files with 21 additions and 10 deletions
|
@ -281,6 +281,18 @@ function createJWTToken() {
|
|||
);
|
||||
}
|
||||
|
||||
async function notifyHangup() {
|
||||
if (widgetApi) {
|
||||
// We send the hangup event before setAlwaysOnScreen, because the latter
|
||||
// can cause the receiving side to instantly stop listening.
|
||||
try {
|
||||
await widgetApi.transport.send(ElementWidgetActions.HangupCall, {});
|
||||
} finally {
|
||||
await widgetApi.setAlwaysOnScreen(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function joinConference() { // event handler bound in HTML
|
||||
let jwt;
|
||||
if (jitsiAuth === JITSI_OPENIDTOKEN_JWT_AUTH) {
|
||||
|
@ -353,16 +365,7 @@ function joinConference() { // event handler bound in HTML
|
|||
|
||||
meetApi.on("readyToClose", () => {
|
||||
switchVisibleContainers();
|
||||
|
||||
if (widgetApi) {
|
||||
// We send the hangup event before setAlwaysOnScreen, because the latter
|
||||
// can cause the receiving side to instantly stop listening.
|
||||
// ignored promise because we don't care if it works
|
||||
// noinspection JSIgnoredPromiseFromCall
|
||||
widgetApi.transport.send(ElementWidgetActions.HangupCall, {}).finally(() =>
|
||||
widgetApi.setAlwaysOnScreen(false),
|
||||
);
|
||||
}
|
||||
notifyHangup();
|
||||
|
||||
document.getElementById("jitsiContainer").innerHTML = "";
|
||||
meetApi = null;
|
||||
|
@ -372,6 +375,14 @@ function joinConference() { // event handler bound in HTML
|
|||
}
|
||||
});
|
||||
|
||||
meetApi.on("errorOccurred", ({ error }) => {
|
||||
if (error.isFatal) {
|
||||
// We got disconnected. Since Jitsi Meet might send us back to the
|
||||
// prejoin screen, we're forced to act as if we hung up entirely.
|
||||
notifyHangup();
|
||||
}
|
||||
});
|
||||
|
||||
meetApi.on("audioMuteStatusChanged", ({ muted }) => {
|
||||
const action = muted ? ElementWidgetActions.MuteAudio : ElementWidgetActions.UnmuteAudio;
|
||||
widgetApi.transport.send(action, {});
|
||||
|
|
Loading…
Reference in a new issue