diff --git a/src/rtcSessionHelpers.ts b/src/rtcSessionHelpers.ts index 9e699319c..1bf9dda92 100644 --- a/src/rtcSessionHelpers.ts +++ b/src/rtcSessionHelpers.ts @@ -135,7 +135,20 @@ const widgetPostHangupProcedure = async ( // We send the hangup event after the memberships have been updated // calling leaveRTCSession. // We need to wait because this makes the client hosting this widget killing the IFrame. - await widget.api.transport.send(ElementWidgetActions.HangupCall, {}); + try { + await widget.api.transport.send(ElementWidgetActions.HangupCall, {}); + } catch (e) { + logger.error("Failed to send hangup action", e); + } + // To make the hangup procedure behave more similarly to what future versions + // of Element Call will do, we additionally send a close action (even though + // we're not yet employing the distinction between 'hangup' and 'close' to + // display error screens) + try { + await widget.api.transport.send(ElementWidgetActions.Close, {}); + } catch (e) { + logger.error("Failed to send close action", e); + } }; export async function leaveRTCSession( diff --git a/src/widget.ts b/src/widget.ts index fb1b1cfdc..765e151c8 100644 --- a/src/widget.ts +++ b/src/widget.ts @@ -17,10 +17,11 @@ import { getUrlParams } from "./UrlParams"; import { Config } from "./config/Config"; import { ElementCallReactionEventType } from "./reactions"; -// Subset of the actions in matrix-react-sdk +// Subset of the actions in element-web export enum ElementWidgetActions { JoinCall = "io.element.join", HangupCall = "im.vector.hangup", + Close = "io.element.close", TileLayout = "io.element.tile_layout", SpotlightLayout = "io.element.spotlight_layout", // This can be sent as from or to widget