UNPKG

sinch-rtc

Version:

RTC JavaScript/Web SDK

79 lines 2.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PublicCallListenerCallbackMapper = void 0; const Direction_1 = require("../session/Direction"); class PublicCallListenerCallbackMapper { constructor() { this.listeners = new Set(); } addListener(listener) { this.listeners.add(listener); } removeListener(listener) { this.listeners.delete(listener); } // We do not expose public onCallAccepted in CallListener, so we forward to onCallAnswered which // is executed for callee at the moment the call is accepted. onCallAccepted(call) { for (const listener of this.listeners) { if (listener.onCallAnswered) { listener.onCallAnswered(call); } } } // We forward onCallAnswered only for outbound calls, as for inbound calls it is called // when the call is accepted (see onCallAccepted above). onCallAnswered(call) { if (call.direction === Direction_1.Direction.Outbound) { for (const listener of this.listeners) { if (listener.onCallAnswered) { listener.onCallAnswered(call); } } } } onCallProgressing(call) { for (const listener of this.listeners) { if (listener.onCallProgressing) { listener.onCallProgressing(call); } } } onCallRinging(call) { for (const listener of this.listeners) { if (listener.onCallRinging) { listener.onCallRinging(call); } } } onCallEstablished(call) { for (const listener of this.listeners) { if (listener.onCallEstablished) { listener.onCallEstablished(call); } } } onCallEnded(call) { for (const listener of this.listeners) { if (listener.onCallEnded) { listener.onCallEnded(call); } } } onRemoteTrack(call, track) { for (const listener of this.listeners) { if (listener.onRemoteTrack) { listener.onRemoteTrack(call, track); } } } onCallQualityWarningEvent(call, callQualityWarningEvent) { for (const listener of this.listeners) { if (listener.onCallQualityWarningEvent) { listener.onCallQualityWarningEvent(call, callQualityWarningEvent); } } } } exports.PublicCallListenerCallbackMapper = PublicCallListenerCallbackMapper; //# sourceMappingURL=PublicCallListenerCallbackMapper.js.map