@exotel-npm-dev/webrtc-client-sdk 2.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog +9 -0
- package/dist/exotelsdk.js +1881 -1536
- package/dist/exotelsdk.js.map +1 -1
- package/index.js +2 -1
- package/package.json +2 -2
- package/src/api/callAPI/Call.js +17 -13
- package/src/api/omAPI/Diagnostics.js +48 -19
- package/src/api/omAPI/DiagnosticsListener.js +19 -8
- package/src/api/registerAPI/RegisterListener.js +2 -2
- package/src/listeners/CallListener.js +28 -31
- package/src/listeners/Callback.js +59 -50
- package/src/listeners/ExWebClient.js +216 -200
- package/src/listeners/ExotelVoiceClientListener.js +18 -7
- package/src/listeners/SessionListeners.js +114 -96
package/dist/exotelsdk.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* WebRTC CLient SIP version
|
|
3
|
+
* WebRTC CLient SIP version 3.0.0
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
@@ -25,11 +25,13 @@ return /******/ (() => { // webpackBootstrap
|
|
|
25
25
|
"use strict";
|
|
26
26
|
__webpack_require__.r(__webpack_exports__);
|
|
27
27
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
28
|
-
/* harmony export */
|
|
28
|
+
/* harmony export */ WebrtcSIPPhone: () => (/* reexport safe */ _src_webrtcSIPPhone__WEBPACK_IMPORTED_MODULE_0__["default"]),
|
|
29
|
+
/* harmony export */ getLogger: () => (/* reexport safe */ _src_webrtcSIPPhone__WEBPACK_IMPORTED_MODULE_0__.getLogger)
|
|
29
30
|
/* harmony export */ });
|
|
30
31
|
/* harmony import */ var _src_webrtcSIPPhone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/webrtcSIPPhone */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/webrtcSIPPhone.js");
|
|
31
32
|
|
|
32
33
|
|
|
34
|
+
|
|
33
35
|
/***/ }),
|
|
34
36
|
|
|
35
37
|
/***/ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/audioDeviceManager.js":
|
|
@@ -20834,24 +20836,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
20834
20836
|
/* harmony import */ var _audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./audioDeviceManager.js */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/audioDeviceManager.js");
|
|
20835
20837
|
/* harmony import */ var _coreSDKLogger_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coreSDKLogger.js */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/coreSDKLogger.js");
|
|
20836
20838
|
/* harmony import */ var _webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webrtcSIPPhoneEventDelegate */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/webrtcSIPPhoneEventDelegate.js");
|
|
20837
|
-
/*
|
|
20838
|
-
* SIPJS WebRTC SIP Phone - to interact with SIPJS Library
|
|
20839
|
-
*/
|
|
20840
|
-
|
|
20841
20839
|
var SIP = __webpack_require__(/*! ./sip-0.20.0.js */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/sip-0.20.0.js")
|
|
20842
20840
|
;
|
|
20843
20841
|
|
|
20844
20842
|
|
|
20845
20843
|
|
|
20846
|
-
|
|
20847
|
-
|
|
20848
|
-
|
|
20849
|
-
var webRTCStatus = "offline"; // ready -> registered, offline -> unregistered,
|
|
20850
|
-
var callBackHandler = null;
|
|
20851
|
-
let txtPublicIdentity = "";
|
|
20852
|
-
var bMicEnable = true;
|
|
20853
|
-
var bHoldEnable = false;
|
|
20854
|
-
var bDisableVideo = true;
|
|
20844
|
+
let logger = _coreSDKLogger_js__WEBPACK_IMPORTED_MODULE_1__["default"];
|
|
20845
|
+
logger.log(SIP);
|
|
20846
|
+
|
|
20855
20847
|
var beeptone = document.createElement("audio");
|
|
20856
20848
|
beeptone.src = __webpack_require__(/*! ./static/beep.wav */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/static/beep.wav");
|
|
20857
20849
|
var ringtone = document.createElement("audio");
|
|
@@ -20863,27 +20855,12 @@ dtmftone.src = __webpack_require__(/*! ./static/dtmf.wav */ "./node_modules/@exo
|
|
|
20863
20855
|
|
|
20864
20856
|
var audioRemote = document.createElement("audio");
|
|
20865
20857
|
|
|
20866
|
-
|
|
20867
|
-
let txtDisplayName, txtPrivateIdentity, txtHostNameWithPort, txtHostName, txtWebSocketPort, txtAccountName;
|
|
20868
|
-
let txtSecurity, txtSipDomain, txtWSPort, txtSipPort, txtSipSecurePort, txtContactHost, endpoint;
|
|
20869
|
-
let txtPassword, txtRealm, txtTurnServer, txtCredential, txtTurnUri, txtWebsocketURL, txtUDPURL;
|
|
20870
|
-
|
|
20871
|
-
|
|
20872
|
-
let register_flag = false;
|
|
20873
|
-
var ctxSip = {};
|
|
20874
|
-
var registerer = null;
|
|
20875
|
-
|
|
20876
|
-
|
|
20877
|
-
let logger = _coreSDKLogger_js__WEBPACK_IMPORTED_MODULE_1__["default"];
|
|
20878
|
-
logger.log(SIP);
|
|
20879
|
-
/* NL Additions - Start */
|
|
20880
|
-
|
|
20881
20858
|
function getLogger() {
|
|
20859
|
+
let uaLogger;
|
|
20882
20860
|
|
|
20883
20861
|
try {
|
|
20884
20862
|
let userAgent = SIP.UserAgent
|
|
20885
20863
|
uaLogger = userAgent.getLogger("sip.WebrtcLib")
|
|
20886
|
-
//let loggerFactory = userAgent.getLoggerFactory()
|
|
20887
20864
|
} catch (e) {
|
|
20888
20865
|
logger.log("sipjsphone: getLogger: No userAgent.getLogger, Using console log")
|
|
20889
20866
|
return console;
|
|
@@ -20898,17 +20875,133 @@ function getLogger() {
|
|
|
20898
20875
|
}
|
|
20899
20876
|
}
|
|
20900
20877
|
|
|
20901
|
-
|
|
20878
|
+
class SIPJSPhone {
|
|
20879
|
+
|
|
20880
|
+
constructor(delegate, username) {
|
|
20881
|
+
this.webrtcSIPPhoneEventDelegate = delegate;
|
|
20882
|
+
this.username = username;
|
|
20883
|
+
this.ctxSip = {};
|
|
20884
|
+
this.lastRegistererState = "";
|
|
20885
|
+
this.lastTransportState = "";
|
|
20886
|
+
this.registererTimer = null;
|
|
20887
|
+
this.txtDisplayName = "";
|
|
20888
|
+
this.txtPassword = "";
|
|
20889
|
+
this.txtPrivateIdentity = "";
|
|
20890
|
+
this.txtPublicIdentity = "";
|
|
20891
|
+
this.txtRealm = "";
|
|
20892
|
+
this.txtHostName = "";
|
|
20893
|
+
this.txtSipDomain = "";
|
|
20894
|
+
this.txtWebsocketURL = "";
|
|
20895
|
+
this.txtWebSocketPort = "";
|
|
20896
|
+
this.txtHostNameWithPort = "";
|
|
20897
|
+
this.txtSecurity = "";
|
|
20898
|
+
this.txtWSPort = "";
|
|
20899
|
+
this.endpoint = "";
|
|
20900
|
+
this.preferredCodec = null;
|
|
20901
|
+
this.userAgent = null;
|
|
20902
|
+
this.registerer = null;
|
|
20903
|
+
this.session = null;
|
|
20904
|
+
this.remoteStream = null;
|
|
20905
|
+
this.localStream = null;
|
|
20906
|
+
this.registerAttempts = 0;
|
|
20907
|
+
this.maxRegisterAttempts = 3;
|
|
20908
|
+
this.registerTimer = null;
|
|
20909
|
+
this.isRegistered = false;
|
|
20910
|
+
this.isConnecting = false;
|
|
20911
|
+
this.isDisconnected = false;
|
|
20912
|
+
this.isMuted = false;
|
|
20913
|
+
this.isHold = false;
|
|
20914
|
+
this.isCallActive = false;
|
|
20915
|
+
this.isCallEnded = false;
|
|
20916
|
+
this.isCallRejected = false;
|
|
20917
|
+
this.isCallAccepted = false;
|
|
20918
|
+
this.isCallInProgress = false;
|
|
20919
|
+
this.isCallEstablished = false;
|
|
20920
|
+
this.isCallTerminated = false;
|
|
20921
|
+
this.isCallFailed = false;
|
|
20922
|
+
this.isCallBusy = false;
|
|
20923
|
+
this.isCallNoAnswer = false;
|
|
20924
|
+
this.isCallCanceled = false;
|
|
20925
|
+
this.isCallTimeout = false;
|
|
20926
|
+
this.isCallError = false;
|
|
20927
|
+
this.isCallUnknown = false;
|
|
20928
|
+
this.isCallOther = false;
|
|
20929
|
+
this.isCallNone = false;
|
|
20930
|
+
this.isCallAll = false;
|
|
20931
|
+
this.isCallAny = false;
|
|
20932
|
+
this.isCallSome = false;
|
|
20933
|
+
this.isCallMany = false;
|
|
20934
|
+
this.isCallFew = false;
|
|
20935
|
+
this.isCallSeveral = false;
|
|
20936
|
+
this.isCallNumerous = false;
|
|
20937
|
+
this.isCallCountless = false;
|
|
20938
|
+
this.isCallInnumerable = false;
|
|
20939
|
+
this.isCallUncountable = false;
|
|
20940
|
+
this.isCallInfinite = false;
|
|
20941
|
+
this.isCallEndless = false;
|
|
20942
|
+
this.isCallBoundless = false;
|
|
20943
|
+
this.isCallLimitless = false;
|
|
20944
|
+
this.isCallUnlimited = false;
|
|
20945
|
+
this.isCallUnrestricted = false;
|
|
20946
|
+
this.isCallUnconstrained = false;
|
|
20947
|
+
this.isCallUnbounded = false;
|
|
20948
|
+
this.isCallUnconfined = false;
|
|
20949
|
+
this.isCallUnfettered = false;
|
|
20950
|
+
this.isCallUnhampered = false;
|
|
20951
|
+
this.isCallUnhindered = false;
|
|
20952
|
+
this.isCallUnimpeded = false;
|
|
20953
|
+
this.isCallUnobstructed = false;
|
|
20954
|
+
this.isCallUnrestrained = false;
|
|
20955
|
+
this.isCallUnrestricted = false;
|
|
20956
|
+
this.isCallUnshackled = false;
|
|
20957
|
+
this.isCallUntrammeled = false;
|
|
20958
|
+
this.bMicEnable = true;
|
|
20959
|
+
this.bHoldEnable = false;
|
|
20960
|
+
this.register_flag = false;
|
|
20961
|
+
|
|
20962
|
+
this.ringtone = ringtone;
|
|
20963
|
+
this.beeptone = beeptone;
|
|
20964
|
+
this.ringbacktone = ringbacktone;
|
|
20965
|
+
this.dtmftone = dtmftone;
|
|
20966
|
+
this.audioRemote = document.createElement("audio");
|
|
20967
|
+
this.audioRemote.style.display = 'none';
|
|
20968
|
+
document.body.appendChild(this.audioRemote);
|
|
20969
|
+
|
|
20970
|
+
navigator.mediaDevices.addEventListener('devicechange', this._onDeviceChange.bind(this));
|
|
20971
|
+
|
|
20972
|
+
this.addPreferredCodec = this.addPreferredCodec.bind(this);
|
|
20973
|
+
|
|
20974
|
+
// In the constructor, after initializing audio elements:
|
|
20975
|
+
[this.ringtone, this.beeptone, this.ringbacktone, this.dtmftone].forEach(audio => {
|
|
20976
|
+
audio.muted = false;
|
|
20977
|
+
audio.volume = 1.0;
|
|
20978
|
+
});
|
|
20979
|
+
}
|
|
20980
|
+
|
|
20981
|
+
init(onInitDoneCallback) {
|
|
20982
|
+
|
|
20983
|
+
const preInit = () => {
|
|
20984
|
+
logger.log("sipjsphone: init:readyState, calling postInit")
|
|
20985
|
+
this.postInit(onInitDoneCallback);
|
|
20986
|
+
}
|
|
20987
|
+
|
|
20988
|
+
const oReadyStateTimer = setInterval(() => {
|
|
20989
|
+
if (document.readyState === "complete") {
|
|
20990
|
+
clearInterval(oReadyStateTimer);
|
|
20991
|
+
logger.log("sipjsphone: init:readyState, calling preinit")
|
|
20992
|
+
preInit();
|
|
20993
|
+
}
|
|
20994
|
+
}, 100);
|
|
20902
20995
|
|
|
20903
|
-
|
|
20904
|
-
function postInit(onInitDoneCallback) {
|
|
20996
|
+
}
|
|
20905
20997
|
|
|
20906
|
-
|
|
20998
|
+
postInit(onInitDoneCallback) {
|
|
20999
|
+
this.ctxSip = {
|
|
20907
21000
|
config: {},
|
|
20908
|
-
|
|
20909
|
-
|
|
20910
|
-
|
|
20911
|
-
|
|
21001
|
+
ringtone: this.ringtone,
|
|
21002
|
+
ringbacktone: this.ringbacktone,
|
|
21003
|
+
dtmfTone: this.dtmftone,
|
|
21004
|
+
beeptone: this.beeptone,
|
|
20912
21005
|
Sessions: [],
|
|
20913
21006
|
callTimers: {},
|
|
20914
21007
|
callActiveID: null,
|
|
@@ -20917,90 +21010,88 @@ function postInit(onInitDoneCallback) {
|
|
|
20917
21010
|
ringToneIntervalID: 0,
|
|
20918
21011
|
ringtoneCount: 30,
|
|
20919
21012
|
|
|
20920
|
-
|
|
21013
|
+
startRingTone: () => {
|
|
20921
21014
|
try {
|
|
20922
21015
|
var count = 0;
|
|
20923
|
-
if (!ctxSip.ringtone) {
|
|
20924
|
-
ctxSip.ringtone = ringtone;
|
|
21016
|
+
if (!this.ctxSip.ringtone) {
|
|
21017
|
+
this.ctxSip.ringtone = this.ringtone;
|
|
20925
21018
|
}
|
|
20926
|
-
ctxSip.ringtone
|
|
20927
|
-
|
|
20928
|
-
|
|
21019
|
+
logger.log('DEBUG: startRingTone called, audio element:', this.ctxSip.ringtone);
|
|
21020
|
+
logger.log('DEBUG: startRingTone src:', this.ctxSip.ringtone.src);
|
|
21021
|
+
this.ctxSip.ringtone.load();
|
|
21022
|
+
this.ctxSip.ringToneIntervalID = setInterval(() => {
|
|
21023
|
+
this.ctxSip.ringtone.play()
|
|
20929
21024
|
.then(() => {
|
|
20930
|
-
|
|
20931
|
-
logger.log("sipjsphone: startRingTone: Audio is playing: count=" + count + " ctxSip.ringToneIntervalID=" + ctxSip.ringToneIntervalID + " ctxSip.ringtoneCount=" + ctxSip.ringtoneCount);
|
|
21025
|
+
logger.log("DEBUG: startRingTone: Audio is playing...");
|
|
20932
21026
|
})
|
|
20933
21027
|
.catch(e => {
|
|
20934
|
-
logger.log("
|
|
21028
|
+
logger.log("DEBUG: startRingTone: Exception:", e);
|
|
20935
21029
|
});
|
|
20936
21030
|
count++;
|
|
20937
|
-
if (count > ctxSip.ringtoneCount) {
|
|
20938
|
-
clearInterval(ctxSip.ringToneIntervalID);
|
|
21031
|
+
if (count > this.ctxSip.ringtoneCount) {
|
|
21032
|
+
clearInterval(this.ctxSip.ringToneIntervalID);
|
|
20939
21033
|
}
|
|
20940
|
-
}, 500)
|
|
20941
|
-
|
|
20942
|
-
|
|
20943
|
-
|
|
20944
|
-
} catch (e) { logger.log("sipjsphone: startRingTone: Exception:", e); }
|
|
21034
|
+
}, 500);
|
|
21035
|
+
} catch (e) {
|
|
21036
|
+
logger.log("DEBUG: startRingTone: Exception:", e);
|
|
21037
|
+
}
|
|
20945
21038
|
},
|
|
20946
21039
|
|
|
20947
|
-
|
|
20948
|
-
|
|
21040
|
+
stopRingTone: () => {
|
|
21041
|
+
try {
|
|
20949
21042
|
|
|
20950
|
-
|
|
20951
|
-
|
|
20952
|
-
|
|
20953
|
-
|
|
20954
|
-
|
|
20955
|
-
|
|
21043
|
+
if (!this.ctxSip.ringtone) {
|
|
21044
|
+
this.ctxSip.ringtone = this.ringtone;
|
|
21045
|
+
}
|
|
21046
|
+
this.ctxSip.ringtone.pause();
|
|
21047
|
+
logger.log("sipjsphone: stopRingTone: intervalID:", this.ctxSip.ringToneIntervalID);
|
|
21048
|
+
clearInterval(this.ctxSip.ringToneIntervalID)
|
|
20956
21049
|
} catch (e) { logger.log("sipjsphone: stopRingTone: Exception:", e); }
|
|
20957
21050
|
},
|
|
20958
21051
|
|
|
20959
|
-
|
|
20960
|
-
|
|
20961
|
-
|
|
21052
|
+
startRingbackTone: () => {
|
|
21053
|
+
if (!this.ctxSip.ringbacktone) {
|
|
21054
|
+
this.ctxSip.ringbacktone = this.ringbacktone;
|
|
20962
21055
|
}
|
|
20963
21056
|
try {
|
|
20964
|
-
|
|
20965
|
-
|
|
20966
|
-
|
|
20967
|
-
|
|
20968
|
-
|
|
20969
|
-
|
|
20970
|
-
|
|
21057
|
+
this.ctxSip.ringbacktone.play()
|
|
21058
|
+
.then(() => {
|
|
21059
|
+
logger.log("sipjsphone: startRingbackTone: Audio is playing...");
|
|
21060
|
+
})
|
|
21061
|
+
.catch(e => {
|
|
21062
|
+
logger.log("sipjsphone: startRingbackTone: Exception:", e);
|
|
21063
|
+
// Optionally, prompt user to interact with the page to enable audio
|
|
21064
|
+
});
|
|
20971
21065
|
} catch (e) { logger.log("sipjsphone: startRingbackTone: Exception:", e); }
|
|
20972
21066
|
},
|
|
20973
21067
|
|
|
20974
|
-
|
|
20975
|
-
|
|
20976
|
-
|
|
20977
|
-
|
|
20978
|
-
|
|
20979
|
-
|
|
21068
|
+
stopRingbackTone: () => {
|
|
21069
|
+
if (!this.ctxSip.ringbacktone) {
|
|
21070
|
+
this.ctxSip.ringbacktone = this.ringbacktone;
|
|
21071
|
+
}
|
|
21072
|
+
try { this.ctxSip.ringbacktone.pause(); } catch (e) { logger.log("sipjsphone: stopRingbackTone: Exception:", e); }
|
|
21073
|
+
},
|
|
20980
21074
|
|
|
20981
|
-
|
|
20982
|
-
getUniqueID: function () {
|
|
21075
|
+
getUniqueID: () => {
|
|
20983
21076
|
return Math.random().toString(36).substr(2, 9);
|
|
20984
21077
|
},
|
|
20985
21078
|
|
|
20986
|
-
|
|
21079
|
+
newSession: (newSess) => {
|
|
20987
21080
|
|
|
20988
21081
|
newSess.displayName = newSess.remoteIdentity.displayName || newSess.remoteIdentity.uri.user;
|
|
20989
|
-
|
|
20990
|
-
|
|
21082
|
+
newSess.ctxid = this.ctxSip.getUniqueID();
|
|
21083
|
+
this.ctxSip.callActiveID = newSess.ctxid;
|
|
20991
21084
|
|
|
20992
21085
|
|
|
20993
21086
|
newSess.stateChange.addListener((newState) => {
|
|
20994
21087
|
switch (newState) {
|
|
20995
21088
|
case SIP.SessionState.Establishing:
|
|
20996
|
-
// Session is establishing.
|
|
20997
21089
|
break;
|
|
20998
21090
|
case SIP.SessionState.Established:
|
|
20999
|
-
|
|
21091
|
+
this.onInvitationSessionAccepted(newSess);
|
|
21000
21092
|
break;
|
|
21001
21093
|
case SIP.SessionState.Terminated:
|
|
21002
|
-
|
|
21003
|
-
onInvitationSessionTerminated();
|
|
21094
|
+
this.onInvitationSessionTerminated();
|
|
21004
21095
|
break;
|
|
21005
21096
|
default:
|
|
21006
21097
|
break;
|
|
@@ -21015,10 +21106,10 @@ function postInit(onInitDoneCallback) {
|
|
|
21015
21106
|
let lastIceState = "unknown";
|
|
21016
21107
|
|
|
21017
21108
|
try {
|
|
21018
|
-
|
|
21019
|
-
|
|
21109
|
+
let callId = this.ctxSip.callActiveID;
|
|
21110
|
+
let username = this.ctxSip.config.authorizationUsername;
|
|
21020
21111
|
let pc = sdh._peerConnection;
|
|
21021
|
-
|
|
21112
|
+
this.webrtcSIPPhoneEventDelegate.initGetStats(pc, callId, username);
|
|
21022
21113
|
} catch (e) {
|
|
21023
21114
|
logger.log("sipjsphone: newSession: something went wrong while initing getstats");
|
|
21024
21115
|
logger.log(e);
|
|
@@ -21026,48 +21117,49 @@ function postInit(onInitDoneCallback) {
|
|
|
21026
21117
|
|
|
21027
21118
|
sdh.peerConnectionDelegate = {
|
|
21028
21119
|
onnegotiationneeded: (event) => {
|
|
21029
|
-
|
|
21120
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatNegoNeeded();
|
|
21030
21121
|
},
|
|
21031
21122
|
onsignalingstatechange: (event) => {
|
|
21032
|
-
|
|
21123
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSignalingStateChange(event.target.signalingState);
|
|
21033
21124
|
},
|
|
21034
21125
|
onconnectionstatechange: (event) => {
|
|
21035
|
-
|
|
21126
|
+
this.webrtcSIPPhoneEventDelegate.onStatPeerConnectionConnectionStateChange(event.target.connectionState);
|
|
21036
21127
|
},
|
|
21037
21128
|
oniceconnectionstatechange: (event) => {
|
|
21038
|
-
|
|
21129
|
+
this.webrtcSIPPhoneEventDelegate.onStatPeerConnectionIceConnectionStateChange(event.target.iceConnectionState);
|
|
21039
21130
|
},
|
|
21040
21131
|
onicegatheringstatechange: (event) => {
|
|
21041
|
-
|
|
21132
|
+
this.webrtcSIPPhoneEventDelegate.onStatPeerConnectionIceGatheringStateChange(event.target.iceGatheringState);
|
|
21042
21133
|
}
|
|
21043
21134
|
|
|
21044
21135
|
};
|
|
21045
21136
|
|
|
21046
21137
|
};
|
|
21047
|
-
|
|
21138
|
+
this.ctxSip.Sessions[newSess.ctxid] = newSess;
|
|
21048
21139
|
|
|
21049
21140
|
let status;
|
|
21050
21141
|
if (newSess.direction === 'incoming') {
|
|
21051
|
-
|
|
21142
|
+
logger.log('DEBUG: Incoming call detected, about to start ring tone');
|
|
21143
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsSessionEvent('incoming');
|
|
21052
21144
|
status = "Incoming: " + newSess.displayName;
|
|
21053
|
-
|
|
21145
|
+
this.ctxSip.startRingTone();
|
|
21054
21146
|
//sip call method was invoking after 500 ms because of race between server push and
|
|
21055
21147
|
//webrtc websocket autoanswer
|
|
21056
|
-
|
|
21148
|
+
setTimeout(() => this.sipCall(), 500);
|
|
21057
21149
|
|
|
21058
21150
|
}
|
|
21059
|
-
|
|
21151
|
+
this.ctxSip.setCallSessionStatus(status);
|
|
21060
21152
|
|
|
21061
21153
|
|
|
21062
21154
|
},
|
|
21063
21155
|
|
|
21064
21156
|
// getUser media request refused or device was not present
|
|
21065
|
-
|
|
21157
|
+
getUserMediaFailure: (e) => {
|
|
21066
21158
|
|
|
21067
21159
|
},
|
|
21068
21160
|
|
|
21069
|
-
|
|
21070
|
-
|
|
21161
|
+
getUserMediaSuccess: (stream) => {
|
|
21162
|
+
this.ctxSip.Stream = stream;
|
|
21071
21163
|
},
|
|
21072
21164
|
|
|
21073
21165
|
/**
|
|
@@ -21076,7 +21168,7 @@ function postInit(onInitDoneCallback) {
|
|
|
21076
21168
|
* @param {string}
|
|
21077
21169
|
* status
|
|
21078
21170
|
*/
|
|
21079
|
-
|
|
21171
|
+
setCallSessionStatus: (status) => {
|
|
21080
21172
|
|
|
21081
21173
|
},
|
|
21082
21174
|
|
|
@@ -21086,7 +21178,7 @@ function postInit(onInitDoneCallback) {
|
|
|
21086
21178
|
* @param {string}
|
|
21087
21179
|
* status
|
|
21088
21180
|
*/
|
|
21089
|
-
|
|
21181
|
+
setStatus: (status) => {
|
|
21090
21182
|
},
|
|
21091
21183
|
|
|
21092
21184
|
/**
|
|
@@ -21098,14 +21190,14 @@ function postInit(onInitDoneCallback) {
|
|
|
21098
21190
|
* status Enum 'ringing', 'answered', 'ended', 'holding',
|
|
21099
21191
|
* 'resumed'
|
|
21100
21192
|
*/
|
|
21101
|
-
|
|
21193
|
+
logCall: (session, status) => { },
|
|
21102
21194
|
|
|
21103
21195
|
|
|
21104
21196
|
|
|
21105
21197
|
|
|
21106
|
-
|
|
21198
|
+
sipHangUp: (sessionid) => {
|
|
21107
21199
|
|
|
21108
|
-
|
|
21200
|
+
var s = this.ctxSip.Sessions[sessionid];
|
|
21109
21201
|
// s.terminate();
|
|
21110
21202
|
if (!s) {
|
|
21111
21203
|
return;
|
|
@@ -21123,13 +21215,13 @@ function postInit(onInitDoneCallback) {
|
|
|
21123
21215
|
|
|
21124
21216
|
},
|
|
21125
21217
|
|
|
21126
|
-
|
|
21218
|
+
sipSendDTMF: (digit) => {
|
|
21127
21219
|
|
|
21128
|
-
|
|
21220
|
+
try { this.ctxSip.dtmfTone.play(); } catch (e) { logger.log("sipjsphone: sipSendDTMF: Exception:", e); }
|
|
21129
21221
|
|
|
21130
|
-
|
|
21222
|
+
var a = this.ctxSip.callActiveID;
|
|
21131
21223
|
if (a) {
|
|
21132
|
-
|
|
21224
|
+
var s = this.ctxSip.Sessions[a];
|
|
21133
21225
|
|
|
21134
21226
|
if (!/^[0-9A-D#*,]$/.exec(digit)) {
|
|
21135
21227
|
return Promise.reject(new Error("Invalid DTMF tone."));
|
|
@@ -21153,31 +21245,31 @@ function postInit(onInitDoneCallback) {
|
|
|
21153
21245
|
}
|
|
21154
21246
|
},
|
|
21155
21247
|
|
|
21156
|
-
|
|
21248
|
+
setError: (err, title, msg, closable) => { },
|
|
21157
21249
|
|
|
21158
21250
|
|
|
21159
21251
|
|
|
21160
21252
|
|
|
21161
|
-
|
|
21162
|
-
|
|
21163
|
-
|
|
21253
|
+
phoneMuteButtonPressed: (sessionid) => {
|
|
21254
|
+
logger.log(" sipjsphone: phoneMuteButtonPressed: bMicEnable, sessionid", this.bMicEnable, sessionid);
|
|
21255
|
+
var s = this.ctxSip.Sessions[sessionid];
|
|
21164
21256
|
|
|
21165
|
-
|
|
21166
|
-
|
|
21167
|
-
|
|
21257
|
+
if (this.bMicEnable) {
|
|
21258
|
+
this.toggleMute(s, true);
|
|
21259
|
+
this.bMicEnable = false;
|
|
21168
21260
|
} else {
|
|
21169
|
-
|
|
21170
|
-
|
|
21261
|
+
this.toggleMute(s, false);
|
|
21262
|
+
this.bMicEnable = true;
|
|
21171
21263
|
}
|
|
21172
21264
|
},
|
|
21173
21265
|
|
|
21174
21266
|
//NL --Implement hold button start
|
|
21175
|
-
|
|
21267
|
+
phoneMute: (sessionid, bMute) => {
|
|
21176
21268
|
if (sessionid) {
|
|
21177
|
-
|
|
21269
|
+
var s = this.ctxSip.Sessions[sessionid];
|
|
21178
21270
|
logger.log(" sipjsphone: phoneMute: bMute", bMute)
|
|
21179
|
-
|
|
21180
|
-
|
|
21271
|
+
this.toggleMute(s, bMute);
|
|
21272
|
+
this.bMicEnable = !bMute;
|
|
21181
21273
|
}
|
|
21182
21274
|
else{
|
|
21183
21275
|
logger.log(" sipjsphone: phoneMute: doing nothing as sessionid not found")
|
|
@@ -21185,24 +21277,24 @@ function postInit(onInitDoneCallback) {
|
|
|
21185
21277
|
}
|
|
21186
21278
|
},
|
|
21187
21279
|
|
|
21188
|
-
|
|
21280
|
+
phoneHold: (sessionid, bHold) => {
|
|
21189
21281
|
if (sessionid) {
|
|
21190
|
-
|
|
21282
|
+
var s = this.ctxSip.Sessions[sessionid];
|
|
21191
21283
|
logger.log("sipjsphone: phoneHold: bHold", bHold)
|
|
21192
|
-
|
|
21193
|
-
|
|
21284
|
+
this.toggleHold(s, bHold);
|
|
21285
|
+
this.bHoldEnable = bHold;
|
|
21194
21286
|
}
|
|
21195
21287
|
},
|
|
21196
21288
|
|
|
21197
|
-
|
|
21289
|
+
phoneHoldButtonPressed: (sessionid) => {
|
|
21198
21290
|
if (sessionid) {
|
|
21199
|
-
|
|
21200
|
-
|
|
21201
|
-
|
|
21202
|
-
|
|
21291
|
+
var s = this.ctxSip.Sessions[sessionid];
|
|
21292
|
+
if (this.bHoldEnable) {
|
|
21293
|
+
this.toggleHold(s, false);
|
|
21294
|
+
this.bHoldEnable = false;
|
|
21203
21295
|
} else {
|
|
21204
|
-
|
|
21205
|
-
|
|
21296
|
+
this.toggleHold(s, true);
|
|
21297
|
+
this.bHoldEnable = true;
|
|
21206
21298
|
}
|
|
21207
21299
|
}
|
|
21208
21300
|
},
|
|
@@ -21212,7 +21304,7 @@ function postInit(onInitDoneCallback) {
|
|
|
21212
21304
|
* Tests for a capable browser, return bool, and shows an error modal on
|
|
21213
21305
|
* fail.
|
|
21214
21306
|
*/
|
|
21215
|
-
|
|
21307
|
+
hasWebRTC: () => {
|
|
21216
21308
|
|
|
21217
21309
|
if (navigator.webkitGetUserMedia) {
|
|
21218
21310
|
return true;
|
|
@@ -21221,7 +21313,7 @@ function postInit(onInitDoneCallback) {
|
|
|
21221
21313
|
} else if (navigator.getUserMedia) {
|
|
21222
21314
|
return true;
|
|
21223
21315
|
} else {
|
|
21224
|
-
|
|
21316
|
+
this.ctxSip.setError(true, 'Unsupported Browser.', 'Your browser does not support the features required for this phone.');
|
|
21225
21317
|
logger.error("WebRTC support not found");
|
|
21226
21318
|
return false;
|
|
21227
21319
|
}
|
|
@@ -21230,124 +21322,151 @@ function postInit(onInitDoneCallback) {
|
|
|
21230
21322
|
};
|
|
21231
21323
|
|
|
21232
21324
|
|
|
21233
|
-
|
|
21325
|
+
if (!this.ctxSip.hasWebRTC()) {
|
|
21234
21326
|
alert('Your browser don\'t support WebRTC.\naudio/video calls will be disabled.');
|
|
21235
21327
|
}
|
|
21236
|
-
|
|
21328
|
+
|
|
21329
|
+
// Use the correct delegate property
|
|
21330
|
+
if (this.webrtcSIPPhoneEventDelegate?.setWebRTCFSMMapper) {
|
|
21331
|
+
this.webrtcSIPPhoneEventDelegate.setWebRTCFSMMapper("sipjs");
|
|
21332
|
+
}
|
|
21333
|
+
|
|
21237
21334
|
logger.log("sipjsphone: init: Initialization complete...")
|
|
21238
|
-
|
|
21335
|
+
this.initializeComplete = true;
|
|
21336
|
+
if (onInitDoneCallback) {
|
|
21239
21337
|
onInitDoneCallback();
|
|
21338
|
+
}
|
|
21240
21339
|
}
|
|
21241
21340
|
|
|
21242
|
-
|
|
21243
|
-
|
|
21244
|
-
|
|
21245
|
-
|
|
21246
|
-
|
|
21247
|
-
|
|
21248
|
-
|
|
21341
|
+
addPreferredCodec(description) {
|
|
21342
|
+
logger.log("sipjsphone:addPreferredCodec entry");
|
|
21343
|
+
// Ensure a preferred codec is set
|
|
21344
|
+
if (!this.preferredCodec) {
|
|
21345
|
+
logger.info("sipjsphone:addPreferredCodec: No preferred codec set. Using default.");
|
|
21346
|
+
return Promise.resolve(description);
|
|
21347
|
+
}
|
|
21249
21348
|
|
|
21250
|
-
|
|
21251
|
-
|
|
21252
|
-
|
|
21349
|
+
const { payloadType, rtpMap, fmtp } = this.preferredCodec;
|
|
21350
|
+
const codecRtpMap = `a=rtpmap:${payloadType} ${rtpMap}`;
|
|
21351
|
+
const codecFmtp = fmtp ? `a=fmtp:${payloadType} ${fmtp}` : "";
|
|
21253
21352
|
|
|
21254
|
-
|
|
21353
|
+
logger.log("sipjsphone:addPreferredCodec: Original SDP:", description.sdp);
|
|
21255
21354
|
|
|
21256
|
-
|
|
21257
|
-
|
|
21355
|
+
// Parse SDP into lines
|
|
21356
|
+
let sdpLines = description.sdp.split("\r\n");
|
|
21258
21357
|
|
|
21259
|
-
|
|
21260
|
-
|
|
21261
|
-
|
|
21358
|
+
// Check if Opus is already in the SDP
|
|
21359
|
+
const existingOpusIndex = sdpLines.findIndex((line) => line.includes(`a=rtpmap`) && line.includes("opus/48000/2"));
|
|
21360
|
+
const audioMLineIndex = sdpLines.findIndex((line) => line.startsWith("m=audio"));
|
|
21262
21361
|
|
|
21263
|
-
|
|
21264
|
-
|
|
21362
|
+
if (existingOpusIndex !== -1 && audioMLineIndex !== -1) {
|
|
21363
|
+
logger.log("sipjsphone:addPreferredCodec: Opus codec already exists. Prioritizing it.");
|
|
21265
21364
|
|
|
21266
|
-
|
|
21267
|
-
|
|
21268
|
-
|
|
21365
|
+
// Extract and modify the audio m-line
|
|
21366
|
+
let audioMLine = sdpLines[audioMLineIndex];
|
|
21367
|
+
audioMLine = audioMLine.replace("RTP/SAVP", "RTP/AVP");
|
|
21269
21368
|
|
|
21270
|
-
|
|
21271
|
-
|
|
21272
|
-
|
|
21369
|
+
const codecs = audioMLine.split(" ");
|
|
21370
|
+
const mLineStart = codecs.slice(0, 3); // "m=audio <port> <protocol>"
|
|
21371
|
+
const mLineCodecs = codecs.slice(3);
|
|
21273
21372
|
|
|
21274
|
-
|
|
21275
|
-
|
|
21276
|
-
|
|
21373
|
+
// Move existing Opus payload type to the top
|
|
21374
|
+
const opusPayloadType = sdpLines[existingOpusIndex].match(/a=rtpmap:(\d+)/)[1];
|
|
21375
|
+
const opusIndex = mLineCodecs.indexOf(opusPayloadType);
|
|
21277
21376
|
|
|
21278
|
-
|
|
21279
|
-
|
|
21280
|
-
|
|
21281
|
-
|
|
21282
|
-
|
|
21283
|
-
|
|
21377
|
+
if (opusIndex !== -1) {
|
|
21378
|
+
// Remove Opus from its current position
|
|
21379
|
+
mLineCodecs.splice(opusIndex, 1);
|
|
21380
|
+
}
|
|
21381
|
+
// Add Opus to the beginning of the codec list
|
|
21382
|
+
mLineCodecs.unshift(opusPayloadType);
|
|
21284
21383
|
|
|
21285
|
-
|
|
21286
|
-
|
|
21287
|
-
|
|
21288
|
-
|
|
21384
|
+
// Update the audio m-line
|
|
21385
|
+
sdpLines[audioMLineIndex] = `${mLineStart.join(" ")} ${mLineCodecs.join(" ")}`;
|
|
21386
|
+
} else if (audioMLineIndex !== -1) {
|
|
21387
|
+
logger.log("sipjsphone:addPreferredCodec: Opus codec not found. Adding it to SDP.");
|
|
21289
21388
|
|
|
21290
|
-
|
|
21291
|
-
|
|
21292
|
-
|
|
21389
|
+
// Extract and modify the audio m-line
|
|
21390
|
+
let audioMLine = sdpLines[audioMLineIndex];
|
|
21391
|
+
audioMLine = audioMLine.replace("RTP/SAVP", "RTP/AVP");
|
|
21293
21392
|
|
|
21294
|
-
|
|
21295
|
-
|
|
21296
|
-
|
|
21393
|
+
const codecs = audioMLine.split(" ");
|
|
21394
|
+
const mLineStart = codecs.slice(0, 3); // "m=audio <port> <protocol>"
|
|
21395
|
+
const mLineCodecs = codecs.slice(3);
|
|
21297
21396
|
|
|
21298
|
-
|
|
21299
|
-
|
|
21397
|
+
// Add Opus payload type to the top
|
|
21398
|
+
mLineCodecs.unshift(payloadType.toString());
|
|
21300
21399
|
|
|
21301
|
-
|
|
21302
|
-
|
|
21400
|
+
// Update the audio m-line
|
|
21401
|
+
sdpLines[audioMLineIndex] = `${mLineStart.join(" ")} ${mLineCodecs.join(" ")}`;
|
|
21303
21402
|
|
|
21304
|
-
|
|
21305
|
-
|
|
21306
|
-
|
|
21307
|
-
|
|
21308
|
-
|
|
21309
|
-
|
|
21403
|
+
// Add Opus-specific attributes to the SDP
|
|
21404
|
+
if (!sdpLines.includes(codecRtpMap)) {
|
|
21405
|
+
sdpLines.splice(audioMLineIndex + 1, 0, codecRtpMap); // Add rtpmap after m=audio
|
|
21406
|
+
}
|
|
21407
|
+
if (fmtp && !sdpLines.includes(codecFmtp)) {
|
|
21408
|
+
sdpLines.splice(audioMLineIndex + 2, 0, codecFmtp); // Add fmtp after rtpmap
|
|
21409
|
+
}
|
|
21410
|
+
} else {
|
|
21411
|
+
logger.error("sipjsphone:addPreferredCodec: No audio m-line found in SDP. Cannot modify.");
|
|
21412
|
+
return Promise.resolve(description);
|
|
21310
21413
|
}
|
|
21311
|
-
} else {
|
|
21312
|
-
logger.error("sipjsphone:addPreferredCodec: No audio m-line found in SDP. Cannot modify.");
|
|
21313
|
-
return Promise.resolve(description);
|
|
21314
|
-
}
|
|
21315
21414
|
|
|
21316
|
-
|
|
21317
|
-
|
|
21415
|
+
// Remove any duplicate lines
|
|
21416
|
+
sdpLines = [...new Set(sdpLines)];
|
|
21318
21417
|
|
|
21319
|
-
|
|
21320
|
-
|
|
21321
|
-
|
|
21418
|
+
// Combine back into SDP
|
|
21419
|
+
description.sdp = sdpLines.join("\r\n");
|
|
21420
|
+
logger.log("sipjsphone:addPreferredCodec: Modified SDP:", description.sdp);
|
|
21322
21421
|
|
|
21323
|
-
|
|
21324
|
-
}
|
|
21422
|
+
return Promise.resolve(description);
|
|
21423
|
+
}
|
|
21325
21424
|
|
|
21326
|
-
|
|
21425
|
+
sipRegister() {
|
|
21426
|
+
logger.log("sipjsphone: sipRegister: Starting registration with config:", [{
|
|
21427
|
+
authorizationUsername: this.txtPrivateIdentity,
|
|
21428
|
+
authorizationPassword: this.txtPassword,
|
|
21429
|
+
uri: this.txtPublicIdentity,
|
|
21430
|
+
websocketURL: this.txtWebsocketURL,
|
|
21431
|
+
realm: this.txtRealm
|
|
21432
|
+
}]);
|
|
21327
21433
|
|
|
21328
|
-
|
|
21434
|
+
try {
|
|
21435
|
+
if (!this.txtRealm || !this.txtPrivateIdentity || !this.txtPublicIdentity) {
|
|
21436
|
+
logger.error("sipjsphone: sipRegister: Missing required credentials");
|
|
21437
|
+
return;
|
|
21438
|
+
}
|
|
21329
21439
|
|
|
21330
|
-
|
|
21440
|
+
const uri = SIP.UserAgent.makeURI(this.txtPublicIdentity);
|
|
21441
|
+
if (!uri) {
|
|
21442
|
+
logger.error("sipjsphone: sipRegister: Failed to create SIP URI");
|
|
21443
|
+
return;
|
|
21444
|
+
}
|
|
21331
21445
|
|
|
21332
|
-
|
|
21333
|
-
|
|
21334
|
-
authorizationPassword: txtPassword,
|
|
21335
|
-
authorizationUsername: txtDisplayName,
|
|
21336
|
-
displayName: txtDisplayName,
|
|
21337
|
-
uri: SIP.UserAgent.makeURI(txtPublicIdentity),
|
|
21338
|
-
hackWssInTransport: true,
|
|
21339
|
-
allowLegacyNotifications: true,
|
|
21340
|
-
contactParams: {
|
|
21341
|
-
transport: "wss"
|
|
21342
|
-
},
|
|
21446
|
+
const userAgentConfig = {
|
|
21447
|
+
uri: uri,
|
|
21343
21448
|
transportOptions: {
|
|
21344
|
-
|
|
21449
|
+
server: this.txtWebsocketURL,
|
|
21345
21450
|
traceSip: true,
|
|
21346
21451
|
reconnectionAttempts: 0
|
|
21347
|
-
|
|
21348
21452
|
},
|
|
21349
21453
|
logBuiltinEnabled: true,
|
|
21350
|
-
|
|
21454
|
+
logConfiguration: true,
|
|
21455
|
+
authorizationUsername: this.txtPrivateIdentity,
|
|
21456
|
+
authorizationPassword: this.txtPassword,
|
|
21457
|
+
registerOptions: {
|
|
21458
|
+
expires: 300
|
|
21459
|
+
},
|
|
21460
|
+
displayName: this.txtDisplayName,
|
|
21461
|
+
hackWssInTransport: true,
|
|
21462
|
+
stunServers: ["stun:stun.l.google.com:19302"],
|
|
21463
|
+
hackIpInContact: true,
|
|
21464
|
+
forceRport: true,
|
|
21465
|
+
hackViaTcp: false,
|
|
21466
|
+
hackAllowUnregisteredOptionTags: false,
|
|
21467
|
+
viaHost: this.txtHostName,
|
|
21468
|
+
allowLegacyNotifications: true,
|
|
21469
|
+
logConnector: this.sipPhoneLogger.bind(this),
|
|
21351
21470
|
logLevel: "log",
|
|
21352
21471
|
sessionDescriptionHandlerFactoryOptions: {
|
|
21353
21472
|
constraints: {
|
|
@@ -21355,337 +21474,245 @@ function sipRegister() {
|
|
|
21355
21474
|
video: false
|
|
21356
21475
|
}
|
|
21357
21476
|
},
|
|
21358
|
-
|
|
21359
|
-
|
|
21360
|
-
|
|
21361
|
-
|
|
21362
|
-
|
|
21363
|
-
|
|
21477
|
+
delegate: {
|
|
21478
|
+
onInvite: (incomingSession) => {
|
|
21479
|
+
logger.log("onInvite called");
|
|
21480
|
+
if (this.ctxSip.callActiveID == null) {
|
|
21481
|
+
// Tell the PSTN/SIP proxy we are ringing so it doesn't CANCEL
|
|
21482
|
+
incomingSession.progress({ statusCode: 180, reasonPhrase: "Ringing" });
|
|
21483
|
+
incomingSession.direction = "incoming";
|
|
21484
|
+
this.ctxSip.newSession(incomingSession);
|
|
21485
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("i_new_call", "CALL", incomingSession);
|
|
21486
|
+
} else {
|
|
21487
|
+
incomingSession.reject({ statusCode: 486 });
|
|
21488
|
+
}
|
|
21489
|
+
}
|
|
21490
|
+
}
|
|
21491
|
+
};
|
|
21364
21492
|
|
|
21365
|
-
|
|
21366
|
-
|
|
21367
|
-
|
|
21368
|
-
|
|
21369
|
-
|
|
21370
|
-
|
|
21371
|
-
|
|
21372
|
-
|
|
21493
|
+
logger.log("sipjsphone: sipRegister: Created UserAgent with config:", [userAgentConfig]);
|
|
21494
|
+
this.ctxSip.userAgent = new SIP.UserAgent(userAgentConfig);
|
|
21495
|
+
this.ctxSip.userAgent.start();
|
|
21496
|
+
this.ctxSip.phone = this.ctxSip.userAgent;
|
|
21497
|
+
const registererConfig = {
|
|
21498
|
+
expires: 300,
|
|
21499
|
+
refreshFrequency: 80,
|
|
21500
|
+
registrar: SIP.UserAgent.makeURI(`sip:${this.txtSipDomain}`),
|
|
21501
|
+
logConfiguration: true
|
|
21502
|
+
};
|
|
21373
21503
|
|
|
21374
|
-
|
|
21375
|
-
|
|
21504
|
+
this.ctxSip.registerer = new SIP.Registerer(this.ctxSip.userAgent, registererConfig);
|
|
21505
|
+
this.registerer = this.ctxSip.registerer;
|
|
21506
|
+
this.ctxSip.registerer.stateChange.addListener(this.registererStateEventListner.bind(this));
|
|
21507
|
+
this.ctxSip.registerer.waitingChange.addListener(this.registererWaitingChangeListener.bind(this));
|
|
21508
|
+
this.registerer = this.ctxSip.registerer;
|
|
21376
21509
|
|
|
21377
|
-
|
|
21378
|
-
|
|
21379
|
-
|
|
21380
|
-
|
|
21381
|
-
callBackHandler.onResponse("error");
|
|
21510
|
+
this.ctxSip.userAgent.transport.stateChange.addListener(this.transportStateChangeListener.bind(this));
|
|
21511
|
+
} catch (error) {
|
|
21512
|
+
logger.error("sipjsphone: sipRegister: Error during registration setup:", error);
|
|
21513
|
+
}
|
|
21382
21514
|
}
|
|
21383
|
-
register_flag = false;
|
|
21384
|
-
}
|
|
21385
21515
|
|
|
21386
|
-
|
|
21516
|
+
registererStateEventListner(newState) {
|
|
21517
|
+
logger.log("sipjsphone: registererStateEventListner: Registration state changed to:", [newState]);
|
|
21387
21518
|
|
|
21388
|
-
|
|
21389
|
-
|
|
21390
|
-
|
|
21519
|
+
switch (newState) {
|
|
21520
|
+
case "Registered":
|
|
21521
|
+
logger.log("sipjsphone: registererStateEventListner: Registration successful");
|
|
21522
|
+
this.webRTCStatus = "ready";
|
|
21523
|
+
this.isRegistered = true;
|
|
21524
|
+
|
|
21525
|
+
// Update UI state
|
|
21526
|
+
if (this.callBackHandler && typeof this.callBackHandler.onResponse === 'function') {
|
|
21527
|
+
this.callBackHandler.onResponse("ready");
|
|
21528
|
+
}
|
|
21391
21529
|
|
|
21392
|
-
|
|
21393
|
-
|
|
21394
|
-
|
|
21395
|
-
case SIP.RegistererState.Unregistered:
|
|
21396
|
-
onUserAgentRegistrationFailed();
|
|
21530
|
+
if (this.webrtcSIPPhoneEventDelegate && typeof this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM === 'function') {
|
|
21531
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("registered", "CONNECTION");
|
|
21532
|
+
}
|
|
21397
21533
|
break;
|
|
21398
|
-
case
|
|
21399
|
-
|
|
21534
|
+
case "Unregistered":
|
|
21535
|
+
logger.error("sipjsphone: registererStateEventListner: Registration failed");
|
|
21536
|
+
this.webRTCStatus = "offline";
|
|
21537
|
+
this.isRegistered = false;
|
|
21538
|
+
|
|
21539
|
+
// Update UI state
|
|
21540
|
+
if (this.callBackHandler && typeof this.callBackHandler.onResponse === 'function') {
|
|
21541
|
+
this.callBackHandler.onResponse("error");
|
|
21542
|
+
}
|
|
21543
|
+
|
|
21544
|
+
if (this.webrtcSIPPhoneEventDelegate && typeof this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM === 'function') {
|
|
21545
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("unregistered", "CONNECTION");
|
|
21546
|
+
}
|
|
21400
21547
|
break;
|
|
21548
|
+
case "Terminated":
|
|
21549
|
+
logger.log("sipjsphone: registererStateEventListner: Registration terminated");
|
|
21550
|
+
this.webRTCStatus = "offline";
|
|
21551
|
+
this.isRegistered = false;
|
|
21552
|
+
|
|
21553
|
+
// Update UI state
|
|
21554
|
+
if (this.callBackHandler && typeof this.callBackHandler.onResponse === 'function') {
|
|
21555
|
+
this.callBackHandler.onResponse("error");
|
|
21556
|
+
}
|
|
21401
21557
|
|
|
21402
|
-
|
|
21558
|
+
if (this.webrtcSIPPhoneEventDelegate && typeof this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM === 'function') {
|
|
21559
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("terminated", "CONNECTION");
|
|
21560
|
+
}
|
|
21403
21561
|
break;
|
|
21404
21562
|
}
|
|
21563
|
+
this.lastRegistererState = newState;
|
|
21405
21564
|
}
|
|
21406
21565
|
|
|
21407
21566
|
|
|
21408
|
-
};
|
|
21409
|
-
|
|
21410
|
-
|
|
21411
|
-
|
|
21412
|
-
let registererWaitingChangeListener = (b) => {
|
|
21413
|
-
if (registerer && registerer.state == SIP.RegistererState.Registered) {
|
|
21414
|
-
onUserAgentRegistered();
|
|
21415
|
-
}
|
|
21416
|
-
|
|
21417
|
-
};
|
|
21418
|
-
|
|
21419
|
-
let transportStateChangeListener = (newState) => {
|
|
21420
|
-
lastTransportState = newState;
|
|
21421
|
-
sipPhoneLogger("debug", "", "", "sipjslog transport new state " + newState);
|
|
21422
|
-
|
|
21423
|
-
switch (newState) {
|
|
21424
|
-
|
|
21425
|
-
case SIP.TransportState.Connecting:
|
|
21426
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].onCallStatSipJsTransportEvent('connecting');
|
|
21427
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("starting", "CONNECTION");
|
|
21428
|
-
break;
|
|
21429
|
-
case SIP.TransportState.Connected:
|
|
21430
|
-
onUserAgentTransportConnected();
|
|
21431
|
-
break;
|
|
21432
|
-
case SIP.TransportState.Disconnected:
|
|
21433
|
-
onUserAgentTransportDisconnected();
|
|
21434
|
-
break;
|
|
21435
|
-
default:
|
|
21436
|
-
break;
|
|
21437
21567
|
|
|
21568
|
+
registererWaitingChangeListener(b) {
|
|
21569
|
+
if (this.registerer && this.registerer.state == SIP.RegistererState.Registered) {
|
|
21570
|
+
this.registererStateEventListner("Registered");
|
|
21571
|
+
}
|
|
21438
21572
|
|
|
21439
21573
|
}
|
|
21440
|
-
};
|
|
21441
|
-
|
|
21442
|
-
function registerPhoneEventListeners() {
|
|
21443
|
-
|
|
21444
|
-
ctxSip.phone.delegate = {};
|
|
21445
|
-
|
|
21446
|
-
|
|
21447
|
-
|
|
21448
|
-
|
|
21449
|
-
ctxSip.phone.transport.stateChange.addListener(transportStateChangeListener);
|
|
21450
|
-
|
|
21451
|
-
registerer = new SIP.Registerer(ctxSip.phone, { expires: 300, refreshFrequency: 80 });
|
|
21452
21574
|
|
|
21575
|
+
transportStateChangeListener(newState) {
|
|
21576
|
+
logger.log("sipjsphone: transportStateChangeListener: Transport state changed to:", [newState]);
|
|
21577
|
+
this.lastTransportState = newState;
|
|
21453
21578
|
|
|
21454
|
-
|
|
21455
|
-
|
|
21456
|
-
|
|
21457
|
-
s.direction = 'incoming';
|
|
21458
|
-
ctxSip.newSession(s);
|
|
21459
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].onRecieveInvite(incomingSession);
|
|
21460
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("i_new_call", "CALL");
|
|
21461
|
-
} else {
|
|
21462
|
-
incomingSession.reject({
|
|
21463
|
-
statusCode: 480,
|
|
21464
|
-
reasonPhrase: "4001"
|
|
21465
|
-
});
|
|
21579
|
+
if (newState === "Connected") {
|
|
21580
|
+
logger.log("sipjsphone: transportStateChangeListener: WebSocket connected");
|
|
21581
|
+
this.onUserAgentTransportConnected();
|
|
21466
21582
|
}
|
|
21467
|
-
};
|
|
21468
|
-
|
|
21469
21583
|
|
|
21584
|
+
if (newState === "Disconnected") {
|
|
21585
|
+
logger.log("sipjsphone: transportStateChangeListener: WebSocket disconnected");
|
|
21470
21586
|
|
|
21471
|
-
|
|
21472
|
-
|
|
21473
|
-
}
|
|
21474
|
-
|
|
21587
|
+
if (this.webrtcSIPPhoneEventDelegate && typeof this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent === 'function') {
|
|
21588
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent("disconnected");
|
|
21589
|
+
}
|
|
21475
21590
|
|
|
21591
|
+
// PATCH: Surface this as an 'unregistered' terminal state
|
|
21592
|
+
this.registererStateEventListner("Unregistered");
|
|
21476
21593
|
|
|
21477
|
-
|
|
21478
|
-
|
|
21479
|
-
// connected,
|
|
21480
|
-
// terminating,
|
|
21481
|
-
// terminated
|
|
21482
|
-
if (b_connected || b_connecting) {
|
|
21483
|
-
register_flag = true;
|
|
21484
|
-
webRTCStatus = "ready";
|
|
21485
|
-
} else {
|
|
21486
|
-
register_flag = false;
|
|
21487
|
-
destroySocketConnection();
|
|
21594
|
+
this.onUserAgentTransportDisconnected();
|
|
21595
|
+
}
|
|
21488
21596
|
|
|
21597
|
+
if (this.webrtcSIPPhoneEventDelegate && this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent) {
|
|
21598
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent(newState);
|
|
21599
|
+
}
|
|
21489
21600
|
}
|
|
21490
21601
|
|
|
21491
|
-
|
|
21492
|
-
|
|
21493
|
-
|
|
21494
|
-
|
|
21495
|
-
|
|
21602
|
+
/**
|
|
21603
|
+
* Closes the underlying WebSocket transport and removes listeners so
|
|
21604
|
+
* that SIP.js can GC everything cleanly.
|
|
21605
|
+
* Call-site: disconnect(), sipUnRegister(), uiOnConnectionEvent()…
|
|
21606
|
+
*/
|
|
21607
|
+
destroySocketConnection() {
|
|
21496
21608
|
try {
|
|
21497
|
-
|
|
21498
|
-
|
|
21499
|
-
|
|
21500
|
-
|
|
21501
|
-
|
|
21502
|
-
|
|
21609
|
+
// The transport object lives on the SIP.js Phone (UserAgent.transport)
|
|
21610
|
+
const transport = this.ctxSip?.phone?.transport;
|
|
21611
|
+
if (!transport) {
|
|
21612
|
+
return; // nothing to do
|
|
21613
|
+
}
|
|
21614
|
+
|
|
21615
|
+
// SIP.js 0.20 ⇢ state-driven API; older builds still expose isConnected()
|
|
21616
|
+
const connected =
|
|
21617
|
+
typeof transport.isConnected === "function"
|
|
21618
|
+
? transport.isConnected()
|
|
21619
|
+
: transport.state === 2; // TransportState.Connected === 2
|
|
21620
|
+
|
|
21621
|
+
if (connected) {
|
|
21622
|
+
// 0.20 has async disconnect; earlier versions are sync – await is OK for both
|
|
21623
|
+
transport.disconnect();
|
|
21624
|
+
}
|
|
21625
|
+
} catch (e) {
|
|
21626
|
+
logger.error("destroySocketConnection: cleanup failed", e);
|
|
21503
21627
|
}
|
|
21504
|
-
}
|
|
21505
|
-
|
|
21506
|
-
|
|
21507
|
-
function uiCallTerminated(s_description) {
|
|
21508
|
-
if (window.btnBFCP)
|
|
21509
|
-
window.btnBFCP.disabled = true;
|
|
21510
|
-
|
|
21511
|
-
ctxSip.stopRingTone();
|
|
21512
|
-
ctxSip.stopRingbackTone();
|
|
21513
|
-
|
|
21514
|
-
if (callBackHandler != null)
|
|
21515
|
-
if (callBackHandler.onResponse)
|
|
21516
|
-
callBackHandler.onResponse("disconnected");
|
|
21517
|
-
|
|
21518
|
-
|
|
21519
|
-
}
|
|
21520
|
-
|
|
21521
|
-
|
|
21522
|
-
function sipCall() {
|
|
21523
|
-
logger.log("sipjsphone: sipCall: testing emit accept_reject");
|
|
21524
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("accept_reject", "CALL");
|
|
21525
|
-
}
|
|
21628
|
+
}
|
|
21526
21629
|
|
|
21527
21630
|
|
|
21631
|
+
uiOnConnectionEvent(b_connected, b_connecting) {
|
|
21632
|
+
logger.log("sipjsphone: uiOnConnectionEvent: Connection state changed:", [b_connected, b_connecting]);
|
|
21528
21633
|
|
|
21634
|
+
if (b_connecting) {
|
|
21635
|
+
this.webRTCStatus = "connecting";
|
|
21636
|
+
} else if (b_connected) {
|
|
21637
|
+
this.webRTCStatus = "ready";
|
|
21638
|
+
} else {
|
|
21639
|
+
this.webRTCStatus = "offline";
|
|
21640
|
+
}
|
|
21529
21641
|
|
|
21530
|
-
|
|
21531
|
-
|
|
21532
|
-
|
|
21533
|
-
if (
|
|
21534
|
-
|
|
21535
|
-
} else
|
|
21536
|
-
|
|
21642
|
+
if (this.callBackHandler && typeof this.callBackHandler.onResponse === 'function') {
|
|
21643
|
+
if (b_connected) {
|
|
21644
|
+
this.callBackHandler.onResponse("ready");
|
|
21645
|
+
} else if (b_connecting) {
|
|
21646
|
+
this.callBackHandler.onResponse("connecting");
|
|
21647
|
+
} else {
|
|
21648
|
+
this.callBackHandler.onResponse("error");
|
|
21537
21649
|
}
|
|
21538
|
-
logger.log("sipjsphone: sipPhoneLogger:" + level + " sipjslog: " + category + ": " + content);
|
|
21539
21650
|
}
|
|
21540
|
-
} catch (e) {
|
|
21541
|
-
logger.error("sipjsphone:sipPhoneLogger ERROR", e);
|
|
21542
|
-
}
|
|
21543
|
-
|
|
21544
|
-
}
|
|
21545
|
-
|
|
21546
|
-
|
|
21547
|
-
function onInvitationSessionAccepted(newSess) {
|
|
21548
|
-
ctxSip.Stream = newSess.sessionDescriptionHandler.localMediaStream;
|
|
21549
|
-
assignStream(newSess.sessionDescriptionHandler.remoteMediaStream, audioRemote);
|
|
21550
|
-
|
|
21551
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].onCallStatSipJsSessionEvent('accepted');
|
|
21552
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("connected", "CALL");
|
|
21553
|
-
|
|
21554
|
-
// If there is another active call, hold it
|
|
21555
|
-
if (ctxSip.callActiveID && ctxSip.callActiveID !== newSess.ctxid) {
|
|
21556
|
-
ctxSip.phoneHoldButtonPressed(ctxSip.callActiveID);
|
|
21557
|
-
}
|
|
21558
|
-
|
|
21559
|
-
ctxSip.stopRingbackTone();
|
|
21560
|
-
ctxSip.stopRingTone();
|
|
21561
|
-
ctxSip.setCallSessionStatus('Answered');
|
|
21562
|
-
ctxSip.logCall(newSess, 'answered');
|
|
21563
|
-
ctxSip.callActiveID = newSess.ctxid;
|
|
21564
|
-
|
|
21565
|
-
webRTCStatus = "busy";
|
|
21566
|
-
if (callBackHandler != null)
|
|
21567
|
-
if (callBackHandler.onResponse)
|
|
21568
|
-
callBackHandler.onResponse("connected");
|
|
21569
|
-
}
|
|
21570
|
-
|
|
21571
|
-
function onInvitationSessionTerminated() {
|
|
21572
|
-
SIPJSPhone.stopStreamTracks(ctxSip.Stream);
|
|
21573
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].stopCallStat();
|
|
21574
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].onCallStatSipJsSessionEvent('terminated');
|
|
21575
|
-
ctxSip.stopRingTone();
|
|
21576
|
-
ctxSip.stopRingbackTone();
|
|
21577
|
-
ctxSip.setCallSessionStatus("");
|
|
21578
|
-
ctxSip.callActiveID = null;
|
|
21579
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].playBeepTone();
|
|
21580
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("terminated", "CALL");
|
|
21581
|
-
|
|
21582
|
-
uiCallTerminated();
|
|
21583
|
-
if (register_flag == true) {
|
|
21584
|
-
webRTCStatus = "ready";
|
|
21585
|
-
} else {
|
|
21586
|
-
destroySocketConnection();
|
|
21587
21651
|
}
|
|
21588
|
-
if (callBackHandler != null)
|
|
21589
|
-
if (callBackHandler.onResponse)
|
|
21590
|
-
callBackHandler.onResponse("disconnected");
|
|
21591
|
-
}
|
|
21592
|
-
|
|
21593
|
-
|
|
21594
|
-
function onUserAgentRegistered() {
|
|
21595
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("connected", "CONNECTION");
|
|
21596
|
-
var bConnected = true;
|
|
21597
|
-
uiOnConnectionEvent(bConnected, !bConnected);
|
|
21598
|
-
register_flag = true;
|
|
21599
|
-
webRTCStatus = "ready";
|
|
21600
|
-
if (callBackHandler != null)
|
|
21601
|
-
if (callBackHandler.onResponse)
|
|
21602
|
-
callBackHandler.onResponse("ready");
|
|
21603
|
-
|
|
21604
|
-
|
|
21605
|
-
var closePhone = function () {
|
|
21606
|
-
// stop the phone on unload
|
|
21607
|
-
localStorage.removeItem('ctxPhone');
|
|
21608
|
-
ctxSip.phone.stop();
|
|
21609
|
-
};
|
|
21610
|
-
|
|
21611
|
-
window.onunload = closePhone;
|
|
21612
|
-
localStorage.setItem('ctxPhone', 'true');
|
|
21613
|
-
}
|
|
21614
21652
|
|
|
21615
|
-
|
|
21616
|
-
|
|
21617
|
-
}
|
|
21653
|
+
onUserAgentTransportConnected() {
|
|
21654
|
+
logger.log("sipjsphone: onUserAgentTransportConnected: Transport connected");
|
|
21618
21655
|
|
|
21619
|
-
|
|
21656
|
+
if (this.webrtcSIPPhoneEventDelegate && typeof this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent === 'function') {
|
|
21657
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent('connected');
|
|
21658
|
+
}
|
|
21620
21659
|
|
|
21660
|
+
this.webRTCStatus = "ready";
|
|
21621
21661
|
|
|
21622
|
-
|
|
21623
|
-
|
|
21624
|
-
register_flag = false;
|
|
21625
|
-
if (callBackHandler != null) {
|
|
21626
|
-
if (callBackHandler.onResponse) {
|
|
21627
|
-
callBackHandler.onResponse("error");
|
|
21662
|
+
if (this.webrtcSIPPhoneEventDelegate && typeof this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM === 'function') {
|
|
21663
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("started", "CONNECTION");
|
|
21628
21664
|
}
|
|
21629
|
-
}
|
|
21630
|
-
}
|
|
21631
21665
|
|
|
21666
|
+
// Update UI state to show connected
|
|
21667
|
+
this.uiOnConnectionEvent(true, false);
|
|
21632
21668
|
|
|
21633
|
-
|
|
21634
|
-
|
|
21635
|
-
|
|
21636
|
-
|
|
21637
|
-
if (callBackHandler != null) {
|
|
21638
|
-
if (callBackHandler.onResponse) {
|
|
21639
|
-
callBackHandler.onResponse("offline");
|
|
21669
|
+
if (this.ctxSip.registerer) {
|
|
21670
|
+
this.ctxSip.registerer.stateChange.addListener(this.registererStateEventListner.bind(this));
|
|
21671
|
+
this.ctxSip.registerer.waitingChange.addListener(this.registererWaitingChangeListener.bind(this));
|
|
21672
|
+
this.ctxSip.registerer.register();
|
|
21640
21673
|
}
|
|
21641
21674
|
}
|
|
21642
21675
|
|
|
21643
|
-
|
|
21644
|
-
|
|
21645
|
-
registerer.register();
|
|
21646
|
-
|
|
21647
|
-
}
|
|
21648
|
-
|
|
21676
|
+
cleanupRegistererTimer() {
|
|
21677
|
+
if (this.registerer) {
|
|
21649
21678
|
|
|
21650
|
-
|
|
21651
|
-
|
|
21652
|
-
|
|
21653
|
-
|
|
21654
|
-
registerer.clearTimers();
|
|
21655
|
-
registerer.stateChange.removeListener(registererStateEventListner);
|
|
21656
|
-
registerer.waitingChange.removeListener(registererWaitingChangeListener);
|
|
21679
|
+
try {
|
|
21680
|
+
this.registerer.clearTimers();
|
|
21681
|
+
this.registerer.stateChange.removeListener(this.registererStateEventListner);
|
|
21682
|
+
this.registerer.waitingChange.removeListener(this.registererWaitingChangeListener);
|
|
21657
21683
|
|
|
21658
21684
|
|
|
21659
21685
|
} catch (e) {
|
|
21660
21686
|
logger.log("sipjsphone: cleanupRegistererTimer: ERROR", e);
|
|
21661
21687
|
|
|
21662
21688
|
}
|
|
21663
|
-
|
|
21689
|
+
this.registerer = null;
|
|
21690
|
+
|
|
21691
|
+
}
|
|
21664
21692
|
}
|
|
21665
|
-
}
|
|
21666
21693
|
|
|
21667
|
-
|
|
21694
|
+
onUserAgentTransportDisconnected() {
|
|
21668
21695
|
|
|
21669
|
-
|
|
21670
|
-
|
|
21696
|
+
this.webRTCStatus = "offline";
|
|
21697
|
+
this.setRegisterFlag(false);
|
|
21671
21698
|
|
|
21672
|
-
|
|
21699
|
+
this.cleanupRegistererTimer();
|
|
21673
21700
|
|
|
21674
|
-
|
|
21675
|
-
|
|
21676
|
-
|
|
21677
|
-
|
|
21678
|
-
|
|
21701
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent('disconnected');
|
|
21702
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("failed_to_start", "CONNECTION");
|
|
21703
|
+
if (this.callBackHandler != null) {
|
|
21704
|
+
if (this.callBackHandler.onResponse) {
|
|
21705
|
+
this.callBackHandler.onResponse("error");
|
|
21706
|
+
}
|
|
21679
21707
|
}
|
|
21680
|
-
}
|
|
21681
21708
|
|
|
21682
21709
|
|
|
21683
21710
|
|
|
21684
21711
|
|
|
21685
|
-
}
|
|
21712
|
+
}
|
|
21686
21713
|
|
|
21687
21714
|
|
|
21688
|
-
|
|
21715
|
+
parseSipMessage(message) {
|
|
21689
21716
|
var lines = message.split("\n");
|
|
21690
21717
|
var firstLine = lines[0];
|
|
21691
21718
|
lines.slice(0, 1);
|
|
@@ -21713,26 +21740,26 @@ function parseSipMessage(message) {
|
|
|
21713
21740
|
return sipob;
|
|
21714
21741
|
}
|
|
21715
21742
|
|
|
21716
|
-
|
|
21743
|
+
handleWebSocketMessageContent(content, direction) {
|
|
21717
21744
|
var lines = content.split('\n');
|
|
21718
21745
|
lines.splice(0, 2);
|
|
21719
21746
|
var newtext = lines.join('\n');
|
|
21720
21747
|
|
|
21721
21748
|
|
|
21722
|
-
|
|
21749
|
+
var sipMessage = this.parseSipMessage(newtext);
|
|
21723
21750
|
|
|
21724
21751
|
switch (direction) {
|
|
21725
21752
|
case "sent":
|
|
21726
21753
|
|
|
21727
21754
|
if (sipMessage.method == "CONNECTION")
|
|
21728
|
-
|
|
21755
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("sent_request", sipMessage.method);
|
|
21729
21756
|
|
|
21730
|
-
|
|
21757
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipSendCallback(newtext, "sipjs");
|
|
21731
21758
|
|
|
21732
21759
|
|
|
21733
21760
|
break;
|
|
21734
21761
|
case "recv":
|
|
21735
|
-
|
|
21762
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipRecvCallback(newtext, "sipjs");
|
|
21736
21763
|
break;
|
|
21737
21764
|
default:
|
|
21738
21765
|
break;
|
|
@@ -21744,68 +21771,74 @@ function handleWebSocketMessageContent(content, direction) {
|
|
|
21744
21771
|
|
|
21745
21772
|
|
|
21746
21773
|
|
|
21747
|
-
|
|
21748
|
-
|
|
21774
|
+
setRegisterFlag(b) {
|
|
21775
|
+
this.register_flag = b;
|
|
21749
21776
|
}
|
|
21750
21777
|
|
|
21751
|
-
|
|
21778
|
+
toggleMute(s, mute) {
|
|
21752
21779
|
let pc = s.sessionDescriptionHandler.peerConnection;
|
|
21753
21780
|
if (pc.getSenders) {
|
|
21754
|
-
|
|
21781
|
+
pc.getSenders().forEach((sender) => {
|
|
21755
21782
|
if (sender.track) {
|
|
21756
21783
|
sender.track.enabled = !mute;
|
|
21757
21784
|
}
|
|
21758
21785
|
});
|
|
21759
21786
|
} else {
|
|
21760
|
-
|
|
21761
|
-
|
|
21787
|
+
pc.getLocalStreams().forEach((stream) => {
|
|
21788
|
+
stream.getAudioTracks().forEach((track) => {
|
|
21762
21789
|
track.enabled = !mute;
|
|
21763
21790
|
});
|
|
21764
|
-
|
|
21791
|
+
stream.getVideoTracks().forEach((track) => {
|
|
21765
21792
|
track.enabled = !mute;
|
|
21766
21793
|
});
|
|
21767
21794
|
});
|
|
21768
21795
|
}
|
|
21769
21796
|
if (mute) {
|
|
21770
|
-
|
|
21797
|
+
this.onMuted(s);
|
|
21771
21798
|
} else {
|
|
21772
|
-
|
|
21799
|
+
this.onUnmuted(s);
|
|
21773
21800
|
}
|
|
21774
21801
|
}
|
|
21775
21802
|
|
|
21776
21803
|
|
|
21777
|
-
|
|
21778
|
-
|
|
21779
|
-
|
|
21780
|
-
|
|
21781
|
-
|
|
21804
|
+
onMuted(s) {
|
|
21805
|
+
logger.log(`[onMuted] Before: s.isMuted=${s && s.isMuted}, global isMuted=${this.isMuted}`);
|
|
21806
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsSessionEvent('muted');
|
|
21807
|
+
if (s) s.isMuted = true;
|
|
21808
|
+
this.isMuted = true;
|
|
21809
|
+
logger.log(`[onMuted] After: s.isMuted=${s && s.isMuted}, global isMuted=${this.isMuted}`);
|
|
21810
|
+
this.ctxSip.setCallSessionStatus("Muted");
|
|
21811
|
+
}
|
|
21782
21812
|
|
|
21783
|
-
|
|
21784
|
-
|
|
21785
|
-
|
|
21786
|
-
|
|
21787
|
-
|
|
21813
|
+
onUnmuted(s) {
|
|
21814
|
+
logger.log(`[onUnmuted] Before: s.isMuted=${s && s.isMuted}, global isMuted=${this.isMuted}`);
|
|
21815
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsSessionEvent('unmuted');
|
|
21816
|
+
if (s) s.isMuted = false;
|
|
21817
|
+
this.isMuted = false;
|
|
21818
|
+
logger.log(`[onUnmuted] After: s.isMuted=${s && s.isMuted}, global isMuted=${this.isMuted}`);
|
|
21819
|
+
this.ctxSip.setCallSessionStatus("Answered");
|
|
21820
|
+
}
|
|
21788
21821
|
|
|
21789
|
-
|
|
21822
|
+
onHold(s) {
|
|
21790
21823
|
//webrtcSIPPhoneEventDelegate.onCallStatSipJsSessionEvent('hold');
|
|
21791
21824
|
logger.warn(`[${s.id}] re-invite request was accepted`);
|
|
21792
21825
|
s.held = true;
|
|
21793
|
-
|
|
21794
|
-
|
|
21795
|
-
|
|
21796
|
-
}
|
|
21826
|
+
this.enableSenderTracks(s, !s.held && !s.isMuted);
|
|
21827
|
+
this.enableReceiverTracks(s, !s.held);
|
|
21828
|
+
//this.ctxSip.setCallSessionStatus("Hold");
|
|
21829
|
+
}
|
|
21797
21830
|
|
|
21798
|
-
|
|
21831
|
+
onUnhold(s) {
|
|
21799
21832
|
//webrtcSIPPhoneEventDelegate.onCallStatSipJsSessionEvent('unhold');
|
|
21800
21833
|
logger.warn(`[${s.id}] re-invite request was rejected`);
|
|
21801
21834
|
s.held = false;
|
|
21802
|
-
|
|
21803
|
-
|
|
21804
|
-
|
|
21835
|
+
this.enableSenderTracks(s, !s.held && !s.isMuted);
|
|
21836
|
+
this.enableReceiverTracks(s, !s.held);
|
|
21837
|
+
//this.ctxSip.setCallSessionStatus("Unhold");
|
|
21805
21838
|
}
|
|
21806
21839
|
|
|
21807
21840
|
/** Helper function to enable/disable media tracks. */
|
|
21808
|
-
|
|
21841
|
+
enableReceiverTracks(s, enable) {
|
|
21809
21842
|
try {
|
|
21810
21843
|
const sessionDescriptionHandler = s.sessionDescriptionHandler;
|
|
21811
21844
|
const peerConnection = sessionDescriptionHandler.peerConnection;
|
|
@@ -21825,7 +21858,7 @@ function enableReceiverTracks(s, enable) {
|
|
|
21825
21858
|
}
|
|
21826
21859
|
|
|
21827
21860
|
/** Helper function to enable/disable media tracks. */
|
|
21828
|
-
|
|
21861
|
+
enableSenderTracks(s, enable) {
|
|
21829
21862
|
try {
|
|
21830
21863
|
const sessionDescriptionHandler = s.sessionDescriptionHandler;
|
|
21831
21864
|
const peerConnection = sessionDescriptionHandler.peerConnection;
|
|
@@ -21842,14 +21875,14 @@ function enableSenderTracks(s, enable) {
|
|
|
21842
21875
|
}
|
|
21843
21876
|
}
|
|
21844
21877
|
|
|
21845
|
-
|
|
21878
|
+
toggleHold(s, hold) {
|
|
21846
21879
|
const options = {
|
|
21847
21880
|
requestDelegate: {
|
|
21848
21881
|
onAccept: () => {
|
|
21849
|
-
|
|
21882
|
+
this.onHold(s)
|
|
21850
21883
|
},
|
|
21851
21884
|
onReject: () => {
|
|
21852
|
-
|
|
21885
|
+
this.onUnhold(s)
|
|
21853
21886
|
}
|
|
21854
21887
|
},
|
|
21855
21888
|
sessionDescriptionHandlerOptions: {
|
|
@@ -21858,14 +21891,14 @@ function toggleHold(s, hold) {
|
|
|
21858
21891
|
};
|
|
21859
21892
|
s.invite(options).then(() => {
|
|
21860
21893
|
// preemptively enable/disable tracks
|
|
21861
|
-
|
|
21862
|
-
|
|
21894
|
+
this.enableReceiverTracks(s, !hold);
|
|
21895
|
+
this.enableSenderTracks(s, !hold && !s.isMuted);
|
|
21863
21896
|
}).catch((error) => {
|
|
21864
21897
|
logger.error(`Error in hold request [${s.id}]`);
|
|
21865
21898
|
});
|
|
21866
21899
|
}
|
|
21867
21900
|
|
|
21868
|
-
|
|
21901
|
+
assignStream(stream, element) {
|
|
21869
21902
|
if (_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioOutputDeviceId != "default")
|
|
21870
21903
|
element.setSinkId(_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioOutputDeviceId);
|
|
21871
21904
|
// Set element source.
|
|
@@ -21898,296 +21931,326 @@ function assignStream(stream, element) {
|
|
|
21898
21931
|
};
|
|
21899
21932
|
}
|
|
21900
21933
|
|
|
21901
|
-
|
|
21934
|
+
onUserSessionAcceptFailed(e) {
|
|
21902
21935
|
if (e.name == "NotAllowedError" || e.name == "NotFoundError") {
|
|
21903
|
-
|
|
21904
|
-
|
|
21905
|
-
|
|
21936
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("m_permission_refused", "CALL");
|
|
21937
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsSessionEvent('userMediaFailed');
|
|
21938
|
+
this.webrtcSIPPhoneEventDelegate.onGetUserMediaErrorCallstatCallback();
|
|
21906
21939
|
} else {
|
|
21907
21940
|
logger.log("sipjsphone: onUserSessionAcceptFailed: user media failed due to error ", e);
|
|
21908
21941
|
}
|
|
21909
|
-
|
|
21910
|
-
}
|
|
21911
|
-
|
|
21912
|
-
const SIPJSPhone = {
|
|
21942
|
+
this.uiCallTerminated('Media stream permission denied');
|
|
21943
|
+
}
|
|
21913
21944
|
|
|
21914
|
-
|
|
21945
|
+
loadCredentials(sipAccountInfo) {
|
|
21946
|
+
this.txtDisplayName = sipAccountInfo['userName'];
|
|
21947
|
+
this.txtPrivateIdentity = sipAccountInfo['authUser'];
|
|
21948
|
+
this.txtHostNameWithPort = sipAccountInfo["domain"];
|
|
21949
|
+
this.txtHostName = this.txtHostNameWithPort.split(":")[0];
|
|
21950
|
+
this.txtWebSocketPort = this.txtHostNameWithPort.split(":")[1];
|
|
21951
|
+
this.txtAccountName = sipAccountInfo['accountName'];
|
|
21915
21952
|
|
|
21916
|
-
|
|
21917
|
-
|
|
21918
|
-
|
|
21953
|
+
// Use sipdomain for public identity if available, otherwise use hostname
|
|
21954
|
+
if (sipAccountInfo['sipdomain']) {
|
|
21955
|
+
this.txtSipDomain = sipAccountInfo["sipdomain"];
|
|
21956
|
+
this.txtPublicIdentity = "sip:" + this.txtPrivateIdentity + "@" + this.txtSipDomain;
|
|
21957
|
+
} else {
|
|
21958
|
+
this.txtSipDomain = this.txtHostName;
|
|
21959
|
+
this.txtPublicIdentity = "sip:" + this.txtPrivateIdentity + "@" + this.txtHostNameWithPort;
|
|
21919
21960
|
}
|
|
21920
|
-
var oReadyStateTimer = setInterval(function () {
|
|
21921
|
-
if (document.readyState === "complete") {
|
|
21922
|
-
clearInterval(oReadyStateTimer);
|
|
21923
|
-
logger.log("sipjsphone: init:readyState, calling preinit")
|
|
21924
|
-
preInit();
|
|
21925
|
-
}
|
|
21926
|
-
}, 100);
|
|
21927
21961
|
|
|
21928
|
-
|
|
21929
|
-
|
|
21930
|
-
|
|
21931
|
-
|
|
21932
|
-
|
|
21933
|
-
txtPrivateIdentity = sipAccountInfo['authUser'];
|
|
21934
|
-
txtHostNameWithPort = sipAccountInfo["domain"];
|
|
21935
|
-
txtHostName = txtHostNameWithPort.split(":")[0];
|
|
21936
|
-
txtWebSocketPort = txtHostNameWithPort.split(":")[1];
|
|
21937
|
-
txtAccountName = sipAccountInfo['accountName'];
|
|
21938
|
-
txtPublicIdentity = "sip:" + txtPrivateIdentity + "@" + txtHostNameWithPort;
|
|
21939
|
-
txtPassword = sipAccountInfo["secret"];
|
|
21940
|
-
txtRealm = txtHostName;
|
|
21941
|
-
txtTurnServer = "drishti@" + txtRealm + ":3478";
|
|
21942
|
-
txtCredential = "jrp931";
|
|
21943
|
-
txtTurnUri = "'turn:" + txtRealm + ":3478?transport=udp', credential: '" + txtCredential + "', username: 'drishti'";
|
|
21962
|
+
this.txtPassword = sipAccountInfo["secret"];
|
|
21963
|
+
this.txtRealm = this.txtSipDomain; // Use sipdomain as realm
|
|
21964
|
+
this.txtTurnServer = "drishti@" + this.txtRealm + ":3478";
|
|
21965
|
+
this.txtCredential = "jrp931";
|
|
21966
|
+
this.txtTurnUri = "'turn:" + this.txtRealm + ":3478?transport=udp', credential: '" + this.txtCredential + "', username: 'drishti'";
|
|
21944
21967
|
|
|
21945
21968
|
|
|
21946
21969
|
var default_values = {
|
|
21947
21970
|
'security': window.location.protocol == "http:" ? 'ws' : 'wss',
|
|
21948
|
-
'sipdomain': txtHostName,
|
|
21949
|
-
'contactHost': txtHostName,
|
|
21971
|
+
'sipdomain': this.txtHostName,
|
|
21972
|
+
'contactHost': this.txtHostName,
|
|
21950
21973
|
'wsPort': window.location.protocol == "http:" ? 8088 : 8089,
|
|
21951
21974
|
'sipPort': window.location.protocol == "http:" ? 5060 : 5061,
|
|
21952
21975
|
'endpoint': 'ws'
|
|
21953
21976
|
}
|
|
21954
21977
|
|
|
21955
|
-
txtSecurity = sipAccountInfo['security'] ? sipAccountInfo['security'] : default_values['security'];
|
|
21956
|
-
txtWSPort = txtWebSocketPort ? txtWebSocketPort : default_values['wsPort'];
|
|
21978
|
+
this.txtSecurity = sipAccountInfo['security'] ? sipAccountInfo['security'] : default_values['security'];
|
|
21979
|
+
this.txtWSPort = this.txtWebSocketPort ? this.txtWebSocketPort : default_values['wsPort'];
|
|
21957
21980
|
|
|
21958
21981
|
if (sipAccountInfo['sipdomain']) {
|
|
21959
|
-
txtSipDomain = sipAccountInfo["sipdomain"];
|
|
21960
|
-
txtPublicIdentity = "sip:" + txtPrivateIdentity + "@" + txtSipDomain;
|
|
21982
|
+
this.txtSipDomain = sipAccountInfo["sipdomain"];
|
|
21983
|
+
this.txtPublicIdentity = "sip:" + this.txtPrivateIdentity + "@" + this.txtSipDomain;
|
|
21961
21984
|
} else {
|
|
21962
|
-
txtSipDomain = default_values["sipdomain"];
|
|
21985
|
+
this.txtSipDomain = default_values["sipdomain"];
|
|
21963
21986
|
}
|
|
21964
21987
|
|
|
21965
21988
|
if (sipAccountInfo['contactHost']) {
|
|
21966
|
-
txtContactHost = sipAccountInfo["contactHost"];
|
|
21989
|
+
this.txtContactHost = sipAccountInfo["contactHost"];
|
|
21967
21990
|
} else {
|
|
21968
|
-
txtContactHost = default_values["contactHost"];
|
|
21991
|
+
this.txtContactHost = default_values["contactHost"];
|
|
21969
21992
|
}
|
|
21970
21993
|
|
|
21971
|
-
txtSipPort = sipAccountInfo['sipPort'] ? sipAccountInfo["sipPort"] : default_values["sipPort"];
|
|
21972
|
-
endpoint = sipAccountInfo['endpoint'] ? sipAccountInfo['endpoint'] : default_values['endpoint'];
|
|
21994
|
+
this.txtSipPort = sipAccountInfo['sipPort'] ? sipAccountInfo["sipPort"] : default_values["sipPort"];
|
|
21973
21995
|
|
|
21974
|
-
|
|
21975
|
-
|
|
21996
|
+
// Fix: Handle endpoint value to avoid double 'wss' path
|
|
21997
|
+
this.endpoint = sipAccountInfo['endpoint'] ? sipAccountInfo['endpoint'] : default_values['endpoint'];
|
|
21998
|
+
|
|
21999
|
+
// Construct WebSocket URL
|
|
22000
|
+
this.txtWebsocketURL = this.txtSecurity + "://" + this.txtHostName + ":" + this.txtWSPort;
|
|
22001
|
+
// Always append endpoint if it exists, regardless of its value
|
|
22002
|
+
if (this.endpoint) {
|
|
22003
|
+
this.txtWebsocketURL += "/" + this.endpoint;
|
|
22004
|
+
}
|
|
22005
|
+
this.txtUDPURL = "udp://" + this.txtHostName + ":" + this.txtSipPort;
|
|
21976
22006
|
|
|
21977
22007
|
|
|
21978
|
-
var oInitializeCompleteTimer =
|
|
21979
|
-
if (initializeComplete
|
|
21980
|
-
sipRegister()
|
|
22008
|
+
var oInitializeCompleteTimer = setTimeout(() => {
|
|
22009
|
+
if (this.initializeComplete) {
|
|
22010
|
+
this.sipRegister()
|
|
21981
22011
|
}
|
|
21982
22012
|
}, 500);
|
|
21983
|
-
}
|
|
22013
|
+
}
|
|
21984
22014
|
|
|
21985
|
-
getStatus
|
|
21986
|
-
return webRTCStatus;
|
|
21987
|
-
}
|
|
22015
|
+
getStatus() {
|
|
22016
|
+
return this.webRTCStatus;
|
|
22017
|
+
}
|
|
21988
22018
|
|
|
21989
|
-
registerCallBacks
|
|
21990
|
-
callBackHandler = handler;
|
|
21991
|
-
}
|
|
22019
|
+
registerCallBacks(handler) {
|
|
22020
|
+
this.callBackHandler = handler;
|
|
22021
|
+
}
|
|
21992
22022
|
|
|
21993
|
-
sipSendDTMF
|
|
21994
|
-
ctxSip.sipSendDTMF(c);
|
|
21995
|
-
}
|
|
22023
|
+
sipSendDTMF(c) {
|
|
22024
|
+
this.ctxSip.sipSendDTMF(c);
|
|
22025
|
+
}
|
|
21996
22026
|
|
|
21997
|
-
sipToggleRegister
|
|
21998
|
-
if (register_flag == false) {
|
|
21999
|
-
register_flag = true;
|
|
22000
|
-
sipRegister();
|
|
22027
|
+
sipToggleRegister() {
|
|
22028
|
+
if (this.register_flag == false) {
|
|
22029
|
+
this.register_flag = true;
|
|
22030
|
+
this.sipRegister();
|
|
22001
22031
|
|
|
22002
|
-
} else if (register_flag == true) {
|
|
22003
|
-
registerer.unregister({});
|
|
22004
|
-
register_flag = false;
|
|
22005
|
-
webRTCStatus = "offline";
|
|
22006
|
-
if (callBackHandler != null)
|
|
22007
|
-
if (callBackHandler.onResponse)
|
|
22008
|
-
callBackHandler.onResponse("error");
|
|
22032
|
+
} else if (this.register_flag == true) {
|
|
22033
|
+
this.registerer.unregister({});
|
|
22034
|
+
this.register_flag = false;
|
|
22035
|
+
this.webRTCStatus = "offline";
|
|
22036
|
+
if (this.callBackHandler != null)
|
|
22037
|
+
if (this.callBackHandler.onResponse)
|
|
22038
|
+
this.callBackHandler.onResponse("error");
|
|
22009
22039
|
|
|
22010
22040
|
}
|
|
22011
|
-
}
|
|
22041
|
+
}
|
|
22012
22042
|
|
|
22013
|
-
reRegister
|
|
22043
|
+
reRegister() {
|
|
22014
22044
|
logger.log("sipjsphone: reRegister: registering in case of relogin");
|
|
22015
|
-
if (ctxSip.phone && registerer) {
|
|
22016
|
-
registerer.register({});
|
|
22045
|
+
if (this.ctxSip.phone && this.registerer) {
|
|
22046
|
+
this.registerer.register({});
|
|
22017
22047
|
} else {
|
|
22018
22048
|
logger.log("sipjsphone: reRegister: SIP Session does not exist for re registration");
|
|
22019
22049
|
}
|
|
22020
22050
|
|
|
22021
|
-
}
|
|
22051
|
+
}
|
|
22022
22052
|
|
|
22023
|
-
sipToggleMic
|
|
22024
|
-
ctxSip.phoneMuteButtonPressed(ctxSip.callActiveID);
|
|
22025
|
-
}
|
|
22053
|
+
sipToggleMic() {
|
|
22054
|
+
this.ctxSip.phoneMuteButtonPressed(this.ctxSip.callActiveID);
|
|
22055
|
+
}
|
|
22026
22056
|
|
|
22027
|
-
sipMute
|
|
22028
|
-
ctxSip.phoneMute(ctxSip.callActiveID, bMute);
|
|
22029
|
-
}
|
|
22057
|
+
sipMute(bMute) {
|
|
22058
|
+
this.ctxSip.phoneMute(this.ctxSip.callActiveID, bMute);
|
|
22059
|
+
}
|
|
22030
22060
|
|
|
22031
|
-
holdCall
|
|
22032
|
-
if (ctxSip.callActiveID) {
|
|
22033
|
-
ctxSip.phoneHoldButtonPressed(ctxSip.callActiveID);
|
|
22061
|
+
holdCall() {
|
|
22062
|
+
if (this.ctxSip.callActiveID) {
|
|
22063
|
+
this.ctxSip.phoneHoldButtonPressed(this.ctxSip.callActiveID);
|
|
22034
22064
|
}
|
|
22035
|
-
}
|
|
22065
|
+
}
|
|
22036
22066
|
|
|
22037
|
-
sipHold
|
|
22038
|
-
if (ctxSip.callActiveID) {
|
|
22039
|
-
ctxSip.phoneHold(ctxSip.callActiveID, bHold);
|
|
22067
|
+
sipHold(bHold) {
|
|
22068
|
+
if (this.ctxSip.callActiveID) {
|
|
22069
|
+
this.ctxSip.phoneHold(this.ctxSip.callActiveID, bHold);
|
|
22040
22070
|
}
|
|
22041
|
-
}
|
|
22071
|
+
}
|
|
22042
22072
|
|
|
22043
|
-
getMicMuteStatus
|
|
22044
|
-
|
|
22045
|
-
|
|
22073
|
+
getMicMuteStatus() {
|
|
22074
|
+
// Prefer session mute state if available
|
|
22075
|
+
let sessionMuted = undefined;
|
|
22076
|
+
if (this.ctxSip && this.ctxSip.callActiveID && this.ctxSip.Sessions && this.ctxSip.Sessions[this.ctxSip.callActiveID]) {
|
|
22077
|
+
sessionMuted = !!this.ctxSip.Sessions[this.ctxSip.callActiveID].isMuted;
|
|
22078
|
+
logger.log(`[getMicMuteStatus] sessionMuted: ${sessionMuted}, global isMuted: ${this.isMuted}`);
|
|
22079
|
+
return sessionMuted;
|
|
22080
|
+
}
|
|
22081
|
+
logger.log(`[getMicMuteStatus] No active session, global isMuted: ${this.isMuted}`);
|
|
22082
|
+
return this.isMuted;
|
|
22083
|
+
}
|
|
22046
22084
|
|
|
22047
|
-
setPreferredCodec
|
|
22085
|
+
setPreferredCodec(codecName) {
|
|
22048
22086
|
logger.log("sipjsphone:setPreferredCodec entry");
|
|
22049
22087
|
const codecPayloadTypes = {
|
|
22050
22088
|
opus: { payloadType: 111, rtpMap: "opus/48000/2", fmtp: "minptime=10;useinbandfec=1" },
|
|
22051
22089
|
};
|
|
22052
22090
|
|
|
22053
|
-
|
|
22054
|
-
if (
|
|
22055
|
-
|
|
22056
|
-
|
|
22057
|
-
|
|
22091
|
+
let codec = "opus"; // Default to opus
|
|
22092
|
+
if (codecName && codecPayloadTypes[codecName.toLowerCase()]) {
|
|
22093
|
+
codec = codecName.toLowerCase();
|
|
22094
|
+
} else if (codecName) {
|
|
22095
|
+
logger.error("sipjsphone:setPreferredCodec: Unsupported codec " + codecName + " specified. Defaulting to opus.");
|
|
22058
22096
|
}
|
|
22059
22097
|
|
|
22060
|
-
|
|
22061
|
-
|
|
22062
|
-
|
|
22098
|
+
this.preferredCodec = codecPayloadTypes[codec];
|
|
22099
|
+
|
|
22100
|
+
logger.log("sipjsphone:setPreferredCodec: Preferred codec set to " + codec);
|
|
22101
|
+
}
|
|
22063
22102
|
|
|
22064
|
-
pickPhoneCall
|
|
22065
|
-
var newSess = ctxSip.Sessions[ctxSip.callActiveID];
|
|
22066
|
-
logger.log("sipjsphone: pickphonecall: ", ctxSip.callActiveID);
|
|
22103
|
+
pickPhoneCall() {
|
|
22104
|
+
var newSess = this.ctxSip.Sessions[this.ctxSip.callActiveID];
|
|
22105
|
+
logger.log("sipjsphone: pickphonecall: ", this.ctxSip.callActiveID);
|
|
22067
22106
|
if (newSess) {
|
|
22068
22107
|
if (_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId != "default") {
|
|
22069
22108
|
newSess.accept({
|
|
22070
22109
|
sessionDescriptionHandlerOptions: {
|
|
22071
22110
|
constraints: { audio: { deviceId: _audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId }, video: false }
|
|
22072
22111
|
},
|
|
22073
|
-
sessionDescriptionHandlerModifiers: [addPreferredCodec]
|
|
22112
|
+
sessionDescriptionHandlerModifiers: [this.addPreferredCodec]
|
|
22074
22113
|
}).catch((e) => {
|
|
22075
|
-
onUserSessionAcceptFailed(e);
|
|
22114
|
+
this.onUserSessionAcceptFailed(e);
|
|
22076
22115
|
});
|
|
22077
22116
|
} else {
|
|
22078
22117
|
|
|
22079
22118
|
newSess.accept({
|
|
22080
|
-
sessionDescriptionHandlerModifiers: [addPreferredCodec]
|
|
22119
|
+
sessionDescriptionHandlerModifiers: [this.addPreferredCodec]
|
|
22081
22120
|
}).catch((e) => {
|
|
22082
|
-
onUserSessionAcceptFailed(e);
|
|
22121
|
+
this.onUserSessionAcceptFailed(e);
|
|
22083
22122
|
});
|
|
22084
22123
|
}
|
|
22085
22124
|
}
|
|
22086
22125
|
|
|
22087
|
-
}
|
|
22126
|
+
}
|
|
22088
22127
|
|
|
22089
22128
|
|
|
22090
|
-
sipHangUp
|
|
22091
|
-
ctxSip.sipHangUp(ctxSip.callActiveID);
|
|
22092
|
-
}
|
|
22129
|
+
sipHangUp() {
|
|
22130
|
+
this.ctxSip.sipHangUp(this.ctxSip.callActiveID);
|
|
22131
|
+
}
|
|
22093
22132
|
|
|
22094
22133
|
|
|
22095
|
-
playBeep
|
|
22134
|
+
playBeep() {
|
|
22096
22135
|
try {
|
|
22097
|
-
ctxSip.beeptone.play();
|
|
22136
|
+
this.ctxSip.beeptone.play();
|
|
22098
22137
|
} catch (e) {
|
|
22099
22138
|
logger.log("sipjsphone: playBeep: Exception:", e);
|
|
22100
22139
|
}
|
|
22101
|
-
}
|
|
22140
|
+
}
|
|
22102
22141
|
|
|
22103
|
-
sipUnRegister
|
|
22104
|
-
if (ctxSip.phone && registerer) {
|
|
22105
|
-
registerer.unregister({}).then(
|
|
22106
|
-
destroySocketConnection();
|
|
22142
|
+
sipUnRegister() {
|
|
22143
|
+
if (this.ctxSip.phone && this.registerer) {
|
|
22144
|
+
this.registerer.unregister({}).then(() => {
|
|
22145
|
+
this.destroySocketConnection();
|
|
22107
22146
|
});
|
|
22108
22147
|
} else {
|
|
22109
|
-
if (ctxSip.phone) {
|
|
22110
|
-
destroySocketConnection();
|
|
22148
|
+
if (this.ctxSip.phone) {
|
|
22149
|
+
this.destroySocketConnection();
|
|
22111
22150
|
}
|
|
22112
22151
|
}
|
|
22113
|
-
}
|
|
22152
|
+
}
|
|
22114
22153
|
|
|
22115
|
-
connect
|
|
22154
|
+
connect() {
|
|
22116
22155
|
try {
|
|
22117
|
-
sipRegister();
|
|
22156
|
+
this.sipRegister();
|
|
22118
22157
|
} catch (e) {
|
|
22119
22158
|
}
|
|
22120
|
-
}
|
|
22159
|
+
}
|
|
22121
22160
|
|
|
22122
|
-
disconnect
|
|
22123
|
-
if (registerer) {
|
|
22124
|
-
cleanupRegistererTimer();
|
|
22161
|
+
disconnect() {
|
|
22162
|
+
if (this.registerer) {
|
|
22163
|
+
this.cleanupRegistererTimer();
|
|
22125
22164
|
}
|
|
22126
|
-
if (ctxSip.phone && ctxSip.phone.transport) {
|
|
22127
|
-
ctxSip.phone.transport.stateChange.removeListener(transportStateChangeListener);
|
|
22128
|
-
if (ctxSip.phone && ctxSip.phone.transport.isConnected()) {
|
|
22129
|
-
destroySocketConnection();
|
|
22165
|
+
if (this.ctxSip.phone && this.ctxSip.phone.transport) {
|
|
22166
|
+
this.ctxSip.phone.transport.stateChange.removeListener(this.transportStateChangeListener);
|
|
22167
|
+
if (this.ctxSip.phone && this.ctxSip.phone.transport.isConnected()) {
|
|
22168
|
+
this.destroySocketConnection();
|
|
22130
22169
|
}
|
|
22131
22170
|
}
|
|
22132
|
-
}
|
|
22171
|
+
}
|
|
22133
22172
|
/* NL Additions - Start */
|
|
22134
|
-
getSpeakerTestTone
|
|
22135
|
-
logger.log("sipjsphone: getSpeakerTestTone: Returning speaker test tone:", ringtone);
|
|
22136
|
-
return ringtone;
|
|
22137
|
-
}
|
|
22173
|
+
getSpeakerTestTone() {
|
|
22174
|
+
logger.log("sipjsphone: getSpeakerTestTone: Returning speaker test tone:", this.ringtone);
|
|
22175
|
+
return this.ringtone;
|
|
22176
|
+
}
|
|
22138
22177
|
|
|
22139
22178
|
|
|
22140
|
-
getWSSUrl
|
|
22141
|
-
logger.log("sipjsphone: getWSSUrl: Returning txtWebsocketURL:", txtWebsocketURL);
|
|
22142
|
-
return txtWebsocketURL;
|
|
22143
|
-
}
|
|
22179
|
+
getWSSUrl() {
|
|
22180
|
+
logger.log("sipjsphone: getWSSUrl: Returning txtWebsocketURL:", this.txtWebsocketURL);
|
|
22181
|
+
return this.txtWebsocketURL;
|
|
22182
|
+
}
|
|
22144
22183
|
/* NL Additions - End */
|
|
22145
|
-
getTransportState
|
|
22146
|
-
logger.log("sipjsphone: getTransportState: Returning Transport State : ", lastTransportState);
|
|
22147
|
-
return lastTransportState;
|
|
22148
|
-
}
|
|
22149
|
-
getRegistrationState
|
|
22150
|
-
logger.log("sipjsphone: getRegistrationState: Returning Registration State : ", lastRegistererState);
|
|
22151
|
-
return lastRegistererState;
|
|
22152
|
-
}
|
|
22184
|
+
getTransportState() {
|
|
22185
|
+
logger.log("sipjsphone: getTransportState: Returning Transport State : ", this.lastTransportState);
|
|
22186
|
+
return this.lastTransportState;
|
|
22187
|
+
}
|
|
22188
|
+
getRegistrationState() {
|
|
22189
|
+
logger.log("sipjsphone: getRegistrationState: Returning Registration State : ", this.lastRegistererState);
|
|
22190
|
+
return this.lastRegistererState;
|
|
22191
|
+
}
|
|
22153
22192
|
|
|
22154
22193
|
changeAudioInputDevice(deviceId, onSuccess, onError) {
|
|
22155
|
-
|
|
22156
|
-
|
|
22194
|
+
logger.log("sipjsphone: changeAudioInputDevice : ", deviceId, onSuccess, onError);
|
|
22195
|
+
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.changeAudioInputDevice(deviceId, (stream) => {
|
|
22196
|
+
const trackChanged = this.replaceSenderTrack(stream, deviceId);
|
|
22157
22197
|
if (trackChanged) {
|
|
22158
22198
|
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId = deviceId;
|
|
22159
22199
|
logger.log(`sipjsphone: changeAudioInputDevice: Input device changed to: ${deviceId}`);
|
|
22160
|
-
|
|
22161
|
-
onSuccess();
|
|
22200
|
+
if (onSuccess) onSuccess();
|
|
22162
22201
|
} else {
|
|
22163
22202
|
logger.error("sipjsphone: changeAudioInputDevice: failed");
|
|
22164
|
-
onError("replaceSenderTrack failed for webrtc");
|
|
22203
|
+
if (onError) onError("replaceSenderTrack failed for webrtc");
|
|
22165
22204
|
}
|
|
22166
|
-
},
|
|
22167
|
-
|
|
22168
|
-
|
|
22169
|
-
|
|
22170
|
-
|
|
22171
|
-
|
|
22205
|
+
}, (err) => {
|
|
22206
|
+
logger.error("sipjsphone: changeAudioInputDevice error:", err);
|
|
22207
|
+
if (onError) onError(err);
|
|
22208
|
+
});
|
|
22209
|
+
}
|
|
22210
|
+
|
|
22211
|
+
async changeAudioOutputDevice(deviceId, onSuccess, onError) {
|
|
22172
22212
|
try {
|
|
22173
|
-
|
|
22174
|
-
|
|
22175
|
-
|
|
22176
|
-
|
|
22213
|
+
// Ensure device list is up-to-date
|
|
22214
|
+
await _audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.enumerateDevices();
|
|
22215
|
+
if (!this.audioRemote) {
|
|
22216
|
+
const errorMsg = 'SIPJSPhone:changeAudioOutputDevice audioRemote element is not set.';
|
|
22217
|
+
logger.error(errorMsg);
|
|
22218
|
+
if (onError) onError(errorMsg);
|
|
22219
|
+
return;
|
|
22220
|
+
}
|
|
22221
|
+
if (typeof this.audioRemote.sinkId === 'undefined') {
|
|
22222
|
+
const errorMsg = 'SIPJSPhone:changeAudioOutputDevice Browser does not support output device selection.';
|
|
22223
|
+
logger.error(errorMsg);
|
|
22224
|
+
if (onError) onError(errorMsg);
|
|
22225
|
+
return;
|
|
22177
22226
|
}
|
|
22227
|
+
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.changeAudioOutputDevice(this.audioRemote, deviceId, () => {
|
|
22228
|
+
this.changeAudioOutputDeviceForAdditionalAudioElement(deviceId);
|
|
22229
|
+
if (onSuccess) onSuccess();
|
|
22230
|
+
}, (err) => {
|
|
22231
|
+
logger.error('SIPJSPhone:changeAudioOutputDevice error:', err);
|
|
22232
|
+
if (onError) onError(err);
|
|
22233
|
+
});
|
|
22178
22234
|
} catch (e) {
|
|
22179
|
-
logger.error(
|
|
22235
|
+
logger.error('SIPJSPhone:changeAudioOutputDevice unexpected error:', e);
|
|
22236
|
+
if (onError) onError(e);
|
|
22180
22237
|
}
|
|
22181
|
-
}
|
|
22182
|
-
|
|
22183
|
-
|
|
22184
|
-
|
|
22238
|
+
}
|
|
22239
|
+
|
|
22240
|
+
changeAudioOutputDeviceForAdditionalAudioElement(deviceId) {
|
|
22241
|
+
const additionalAudioElements = [this.ringtone, this.beeptone, this.ringbacktone, this.dtmftone];
|
|
22242
|
+
let i = 0;
|
|
22243
|
+
let elem;
|
|
22244
|
+
try {
|
|
22245
|
+
for (i = 0; i < additionalAudioElements.length; i++) {
|
|
22246
|
+
elem = additionalAudioElements[i];
|
|
22247
|
+
elem.load();
|
|
22248
|
+
elem.setSinkId(deviceId);
|
|
22249
|
+
}
|
|
22250
|
+
} catch (e) {
|
|
22251
|
+
logger.error("sipjsphone:changeAudioOutputDeviceForAdditionalAudioElement failed to setSink for additonal AudioElements", e);
|
|
22185
22252
|
}
|
|
22186
|
-
|
|
22187
|
-
SIPJSPhone.changeAudioOutputDeviceForAdditionalAudioElement(deviceId);
|
|
22188
|
-
onSuccess();
|
|
22189
|
-
}, onError);
|
|
22190
|
-
},
|
|
22253
|
+
}
|
|
22191
22254
|
|
|
22192
22255
|
stopStreamTracks(stream) {
|
|
22193
22256
|
try {
|
|
@@ -22200,17 +22263,17 @@ const SIPJSPhone = {
|
|
|
22200
22263
|
} catch (e) {
|
|
22201
22264
|
logger.error("sipjsphone:stopStreamTracks failed to stop tracks");
|
|
22202
22265
|
}
|
|
22203
|
-
}
|
|
22266
|
+
}
|
|
22204
22267
|
replaceSenderTrack(stream, deviceId) {
|
|
22205
22268
|
try {
|
|
22206
22269
|
|
|
22207
22270
|
if (_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId == deviceId) {
|
|
22208
|
-
|
|
22271
|
+
this.stopStreamTracks(stream);
|
|
22209
22272
|
return false;
|
|
22210
22273
|
}
|
|
22211
|
-
if (ctxSip.callActiveID) {
|
|
22212
|
-
ctxSip.Stream = stream;
|
|
22213
|
-
const s = ctxSip.Sessions[ctxSip.callActiveID];
|
|
22274
|
+
if (this.ctxSip.callActiveID) {
|
|
22275
|
+
this.ctxSip.Stream = stream;
|
|
22276
|
+
const s = this.ctxSip.Sessions[this.ctxSip.callActiveID];
|
|
22214
22277
|
const pc = s.sessionDescriptionHandler.peerConnection;
|
|
22215
22278
|
if (pc.getSenders) {
|
|
22216
22279
|
try {
|
|
@@ -22223,64 +22286,199 @@ const SIPJSPhone = {
|
|
|
22223
22286
|
}
|
|
22224
22287
|
}
|
|
22225
22288
|
} else {
|
|
22226
|
-
|
|
22289
|
+
this.stopStreamTracks(stream);
|
|
22227
22290
|
}
|
|
22228
22291
|
return true;
|
|
22229
22292
|
} catch (e) {
|
|
22230
22293
|
return false;
|
|
22231
22294
|
}
|
|
22232
22295
|
|
|
22233
|
-
}
|
|
22296
|
+
}
|
|
22234
22297
|
registerLogger(customLogger) {
|
|
22235
22298
|
logger = customLogger;
|
|
22236
|
-
}
|
|
22237
|
-
audioInputDeviceChangeCallback: null,
|
|
22238
|
-
audioOutputDeviceChangeCallback: null,
|
|
22239
|
-
onDeviceChangeCallback: null,
|
|
22299
|
+
}
|
|
22240
22300
|
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback) {
|
|
22241
22301
|
logger.log(`sipjsphone: registerAudioDeviceChangeCallback: entry`);
|
|
22242
|
-
|
|
22243
|
-
|
|
22244
|
-
|
|
22302
|
+
this.audioInputDeviceChangeCallback = audioInputDeviceChangeCallback;
|
|
22303
|
+
this.audioOutputDeviceChangeCallback = audioOutputDeviceChangeCallback;
|
|
22304
|
+
this.onDeviceChangeCallback = onDeviceChangeCallback;
|
|
22245
22305
|
}
|
|
22246
22306
|
|
|
22247
|
-
|
|
22307
|
+
uiCallTerminated(s_description) {
|
|
22308
|
+
if (window.btnBFCP)
|
|
22309
|
+
window.btnBFCP.disabled = true;
|
|
22310
|
+
this.ctxSip.stopRingTone();
|
|
22311
|
+
this.ctxSip.stopRingbackTone();
|
|
22312
|
+
if (this.callBackHandler && this.callBackHandler.onResponse)
|
|
22313
|
+
this.callBackHandler.onResponse("disconnected");
|
|
22314
|
+
}
|
|
22248
22315
|
|
|
22316
|
+
sipCall() {
|
|
22317
|
+
logger.log("sipjsphone: sipCall: testing emit accept_reject");
|
|
22318
|
+
if (this.webrtcSIPPhoneEventDelegate)
|
|
22319
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("accept_reject", "CALL");
|
|
22320
|
+
}
|
|
22249
22321
|
|
|
22250
|
-
|
|
22251
|
-
|
|
22252
|
-
|
|
22253
|
-
|
|
22322
|
+
onInvitationSessionAccepted(newSess) {
|
|
22323
|
+
// Reset mute state at the start of every call
|
|
22324
|
+
logger.log(`[onInvitationSessionAccepted] Resetting mute state. Before: newSess.isMuted=${newSess && newSess.isMuted}, global isMuted=${this.isMuted}`);
|
|
22325
|
+
this.isMuted = false;
|
|
22326
|
+
if (newSess && newSess.isMuted !== undefined) {
|
|
22327
|
+
newSess.isMuted = false;
|
|
22328
|
+
}
|
|
22329
|
+
logger.log(`[onInvitationSessionAccepted] After reset: newSess.isMuted=${newSess && newSess.isMuted}, global isMuted=${this.isMuted}`);
|
|
22330
|
+
this.ctxSip.Stream = newSess.sessionDescriptionHandler.localMediaStream;
|
|
22331
|
+
logger.log('onInvitationSessionAccepted: assigning remote stream to audioRemote');
|
|
22332
|
+
this.assignStream(newSess.sessionDescriptionHandler.remoteMediaStream, this.audioRemote);
|
|
22333
|
+
logger.log('onInvitationSessionAccepted: assignStream called');
|
|
22334
|
+
if (this.webrtcSIPPhoneEventDelegate) {
|
|
22335
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsSessionEvent('accepted');
|
|
22336
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("connected", "CALL");
|
|
22254
22337
|
}
|
|
22255
|
-
|
|
22338
|
+
// If there is another active call, hold it
|
|
22339
|
+
if (this.ctxSip.callActiveID && this.ctxSip.callActiveID !== newSess.ctxid) {
|
|
22340
|
+
this.ctxSip.phoneHoldButtonPressed(this.ctxSip.callActiveID);
|
|
22341
|
+
}
|
|
22342
|
+
this.ctxSip.stopRingbackTone();
|
|
22343
|
+
this.ctxSip.stopRingTone();
|
|
22344
|
+
this.ctxSip.setCallSessionStatus('Answered');
|
|
22345
|
+
this.ctxSip.logCall(newSess, 'answered');
|
|
22346
|
+
this.ctxSip.callActiveID = newSess.ctxid;
|
|
22347
|
+
this.webRTCStatus = "busy";
|
|
22348
|
+
if (this.callBackHandler && this.callBackHandler.onResponse)
|
|
22349
|
+
this.callBackHandler.onResponse("connected");
|
|
22350
|
+
}
|
|
22256
22351
|
|
|
22257
|
-
|
|
22352
|
+
onInvitationSessionTerminated() {
|
|
22353
|
+
this.stopStreamTracks(this.ctxSip.Stream);
|
|
22354
|
+
if (this.webrtcSIPPhoneEventDelegate) {
|
|
22355
|
+
this.webrtcSIPPhoneEventDelegate.stopCallStat();
|
|
22356
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsSessionEvent('terminated');
|
|
22357
|
+
}
|
|
22358
|
+
this.ctxSip.stopRingTone();
|
|
22359
|
+
this.ctxSip.stopRingbackTone();
|
|
22360
|
+
this.ctxSip.setCallSessionStatus("");
|
|
22361
|
+
this.ctxSip.callActiveID = null;
|
|
22362
|
+
if (this.webrtcSIPPhoneEventDelegate) {
|
|
22363
|
+
this.webrtcSIPPhoneEventDelegate.playBeepTone();
|
|
22364
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("terminated", "CALL");
|
|
22365
|
+
}
|
|
22366
|
+
this.uiCallTerminated();
|
|
22367
|
+
this.webRTCStatus = "ready";
|
|
22368
|
+
if (this.callBackHandler && this.callBackHandler.onResponse)
|
|
22369
|
+
this.callBackHandler.onResponse("disconnected");
|
|
22370
|
+
}
|
|
22371
|
+
|
|
22372
|
+
onUserAgentRegistered() {
|
|
22373
|
+
if (this.webrtcSIPPhoneEventDelegate) {
|
|
22374
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("connected", "CONNECTION");
|
|
22375
|
+
}
|
|
22376
|
+
this.uiOnConnectionEvent(true, false);
|
|
22377
|
+
this.register_flag = true;
|
|
22378
|
+
this.webRTCStatus = "ready";
|
|
22379
|
+
if (this.callBackHandler && this.callBackHandler.onResponse)
|
|
22380
|
+
this.callBackHandler.onResponse("ready");
|
|
22381
|
+
window.onunload = () => {
|
|
22382
|
+
localStorage.removeItem('ctxPhone');
|
|
22383
|
+
if (this.ctxSip.phone) this.ctxSip.phone.stop();
|
|
22384
|
+
};
|
|
22385
|
+
localStorage.setItem('ctxPhone', 'true');
|
|
22386
|
+
}
|
|
22387
|
+
|
|
22388
|
+
onUserAgentRegistrationTerminated() {
|
|
22389
|
+
this.uiOnConnectionEvent(false, false);
|
|
22390
|
+
}
|
|
22391
|
+
|
|
22392
|
+
onUserAgentRegistrationFailed() {
|
|
22393
|
+
if (this.webrtcSIPPhoneEventDelegate) {
|
|
22394
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("terminated", "CONNECTION");
|
|
22395
|
+
}
|
|
22396
|
+
this.uiOnConnectionEvent(false, false);
|
|
22397
|
+
this.register_flag = false;
|
|
22398
|
+
if (this.callBackHandler && this.callBackHandler.onResponse) {
|
|
22399
|
+
this.callBackHandler.onResponse("error");
|
|
22400
|
+
}
|
|
22401
|
+
}
|
|
22402
|
+
|
|
22403
|
+
sipPhoneLogger(level, category, label, content) {
|
|
22404
|
+
try {
|
|
22405
|
+
if (content) {
|
|
22406
|
+
if (content.startsWith("Sending WebSocket")) {
|
|
22407
|
+
this.handleWebSocketMessageContent(content, "sent");
|
|
22408
|
+
} else if (content.startsWith("Received WebSocket text message")) {
|
|
22409
|
+
this.handleWebSocketMessageContent(content, "recv");
|
|
22410
|
+
}
|
|
22411
|
+
logger.log("sipjsphone: sipPhoneLogger:" + level + " sipjslog: " + category + ": " + content);
|
|
22412
|
+
}
|
|
22413
|
+
} catch (e) {
|
|
22414
|
+
logger.error("sipjsphone:sipPhoneLogger ERROR", e);
|
|
22415
|
+
}
|
|
22416
|
+
}
|
|
22417
|
+
|
|
22418
|
+
_onDeviceChange(event) {
|
|
22419
|
+
try {
|
|
22420
|
+
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.enumerateDevices(() => {
|
|
22421
|
+
if (this.onDeviceChangeCallback) {
|
|
22258
22422
|
logger.info("SIPJSPhone:ondevicechange relaying event to callback");
|
|
22259
|
-
|
|
22423
|
+
this.onDeviceChangeCallback(event);
|
|
22260
22424
|
return;
|
|
22261
22425
|
}
|
|
22262
|
-
|
|
22263
|
-
|
|
22264
|
-
|
|
22426
|
+
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.onAudioDeviceChange(
|
|
22427
|
+
this.audioRemote,
|
|
22428
|
+
(stream, deviceId) => {
|
|
22429
|
+
const trackChanged = this.replaceSenderTrack(stream, deviceId);
|
|
22265
22430
|
if (trackChanged) {
|
|
22266
22431
|
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId = deviceId;
|
|
22267
|
-
|
|
22268
|
-
|
|
22432
|
+
if (this.audioInputDeviceChangeCallback) {
|
|
22433
|
+
this.audioInputDeviceChangeCallback(deviceId);
|
|
22269
22434
|
}
|
|
22270
22435
|
}
|
|
22271
|
-
|
|
22272
|
-
|
|
22436
|
+
},
|
|
22437
|
+
(deviceId) => {
|
|
22438
|
+
this.changeAudioOutputDeviceForAdditionalAudioElement(deviceId);
|
|
22273
22439
|
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioOutputDeviceId = deviceId;
|
|
22274
|
-
|
|
22275
|
-
|
|
22440
|
+
if (this.audioOutputDeviceChangeCallback) {
|
|
22441
|
+
this.audioOutputDeviceChangeCallback(deviceId);
|
|
22442
|
+
}
|
|
22276
22443
|
}
|
|
22444
|
+
);
|
|
22277
22445
|
});
|
|
22278
|
-
});
|
|
22279
|
-
|
|
22280
22446
|
} catch (e) {
|
|
22281
22447
|
logger.error("SIPJSPhone:ondevicechange something went wrong during device change", e);
|
|
22282
22448
|
}
|
|
22283
|
-
}
|
|
22449
|
+
}
|
|
22450
|
+
|
|
22451
|
+
_makeAudio(src) { const a = new Audio(src); return a; }
|
|
22452
|
+
|
|
22453
|
+
registerPhoneEventListeners() {
|
|
22454
|
+
this.ctxSip.phone.start();
|
|
22455
|
+
this.ctxSip.phone.transport.stateChange.addListener((s) => {
|
|
22456
|
+
if (s === SIP.TransportState.Connected && !this.registerer) {
|
|
22457
|
+
this.registerer = new SIP.Registerer(this.ctxSip.phone, {expires:300, refreshFrequency: 80 });
|
|
22458
|
+
this.registerer.register();
|
|
22459
|
+
}
|
|
22460
|
+
});
|
|
22461
|
+
}
|
|
22462
|
+
|
|
22463
|
+
registerWebRTCClient(sipAccountInfo, webrtcSIPPhoneEventDelegate) {
|
|
22464
|
+
this.webrtcSIPPhoneEventDelegate = webrtcSIPPhoneEventDelegate;
|
|
22465
|
+
this.init(sipAccountInfo, () => {
|
|
22466
|
+
this.setPreferredCodec(sipAccountInfo.preferredCodec);
|
|
22467
|
+
this.registerPhoneEventListeners(this.ctxSip);
|
|
22468
|
+
});
|
|
22469
|
+
}
|
|
22470
|
+
|
|
22471
|
+
muteAction(bMute) {
|
|
22472
|
+
logger.log("webrtcSIPPhone: muteAction: ", [bMute]);
|
|
22473
|
+
// Always operate on the current session
|
|
22474
|
+
if (this.ctxSip && this.ctxSip.callActiveID && this.ctxSip.Sessions && this.ctxSip.Sessions[this.ctxSip.callActiveID]) {
|
|
22475
|
+
this.phone.sipMute(bMute);
|
|
22476
|
+
} else {
|
|
22477
|
+
logger.warn("webrtcSIPPhone: muteAction: No active session to mute/unmute");
|
|
22478
|
+
}
|
|
22479
|
+
}
|
|
22480
|
+
|
|
22481
|
+
}
|
|
22284
22482
|
|
|
22285
22483
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SIPJSPhone);
|
|
22286
22484
|
|
|
@@ -22297,55 +22495,101 @@ navigator.mediaDevices.addEventListener('devicechange', function (event) {
|
|
|
22297
22495
|
__webpack_require__.r(__webpack_exports__);
|
|
22298
22496
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
22299
22497
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
|
|
22300
|
-
/* harmony export */
|
|
22498
|
+
/* harmony export */ getLogger: () => (/* binding */ getLogger)
|
|
22301
22499
|
/* harmony export */ });
|
|
22302
22500
|
/* harmony import */ var _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./coreSDKLogger */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/coreSDKLogger.js");
|
|
22303
22501
|
/* harmony import */ var _sipjsphone__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sipjsphone */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/sipjsphone.js");
|
|
22304
22502
|
/* harmony import */ var _webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webrtcSIPPhoneEventDelegate */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/webrtcSIPPhoneEventDelegate.js");
|
|
22305
|
-
/**
|
|
22306
|
-
* Communication from Webrtc flows and feature handling for web RTC as WebRTC Phone Interface
|
|
22307
|
-
*
|
|
22308
|
-
*/
|
|
22309
|
-
|
|
22310
22503
|
|
|
22311
22504
|
|
|
22312
22505
|
|
|
22313
22506
|
|
|
22314
|
-
var phone = null;
|
|
22315
|
-
let webrtcSIPEngine = null;
|
|
22316
22507
|
const logger = _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
22317
22508
|
|
|
22509
|
+
function getLogger() {
|
|
22510
|
+
return _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
22511
|
+
}
|
|
22512
|
+
|
|
22318
22513
|
function sendWebRTCEventsToFSM(eventType, sipMethod) {
|
|
22319
22514
|
logger.log("webrtcSIPPhone: sendWebRTCEventsToFSM : ",eventType,sipMethod);
|
|
22320
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"]
|
|
22515
|
+
this.webrtcSIPPhoneEventDelegate = new _webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"]();
|
|
22516
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM(eventType, sipMethod);
|
|
22321
22517
|
}
|
|
22322
22518
|
|
|
22323
|
-
|
|
22519
|
+
class WebrtcSIPPhone {
|
|
22520
|
+
|
|
22521
|
+
constructor(username) {
|
|
22522
|
+
if (!username) {
|
|
22523
|
+
throw new Error("username is required for WebrtcSIPPhone");
|
|
22524
|
+
}
|
|
22525
|
+
this.username = username;
|
|
22526
|
+
this.webrtcSIPEngine = null;
|
|
22527
|
+
this.webrtcSIPPhoneEventDelegate = new _webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"](username);
|
|
22528
|
+
this.phone = null;
|
|
22529
|
+
}
|
|
22530
|
+
|
|
22531
|
+
static getLogger() {
|
|
22532
|
+
return _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
22533
|
+
}
|
|
22324
22534
|
|
|
22325
|
-
|
|
22535
|
+
registerPhone(engine, delegate) {
|
|
22536
|
+
logger.log("webrtcSIPPhone: registerPhone : ", engine);
|
|
22537
|
+
this.webrtcSIPEngine = engine;
|
|
22538
|
+
|
|
22539
|
+
if (!this.webrtcSIPPhoneEventDelegate) {
|
|
22540
|
+
this.webrtcSIPPhoneEventDelegate = new _webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"](this.username);
|
|
22541
|
+
}
|
|
22542
|
+
|
|
22543
|
+
this.webrtcSIPPhoneEventDelegate.registerDelegate(delegate);
|
|
22544
|
+
|
|
22545
|
+
switch (engine) {
|
|
22546
|
+
case "sipjs":
|
|
22547
|
+
this.phone = new _sipjsphone__WEBPACK_IMPORTED_MODULE_1__["default"](
|
|
22548
|
+
this.webrtcSIPPhoneEventDelegate,
|
|
22549
|
+
this.username
|
|
22550
|
+
);
|
|
22551
|
+
break;
|
|
22552
|
+
default:
|
|
22553
|
+
logger.log("webrtcSIPPhone: Unsupported engine type:", engine);
|
|
22554
|
+
break;
|
|
22555
|
+
}
|
|
22556
|
+
|
|
22557
|
+
this.webrtcSIPPhoneEventDelegate.onRegisterWebRTCSIPEngine(engine);
|
|
22558
|
+
}
|
|
22326
22559
|
|
|
22560
|
+
getWebRTCStatus() {
|
|
22561
|
+
logger.log("webrtcSIPPhone: getWebRTCStatus entry");
|
|
22562
|
+
if (!this.phone) {
|
|
22563
|
+
logger.log("webrtcSIPPhone: getWebRTCStatus: phone not initialized");
|
|
22564
|
+
return "offline";
|
|
22565
|
+
}
|
|
22566
|
+
const status = this.phone.getStatus();
|
|
22567
|
+
logger.log("webrtcSIPPhone: getWebRTCStatus: current status:", status);
|
|
22568
|
+
return status;
|
|
22569
|
+
}
|
|
22327
22570
|
|
|
22328
|
-
isConnected
|
|
22571
|
+
isConnected() {
|
|
22329
22572
|
logger.log("webrtcSIPPhone: isConnected entry");
|
|
22330
|
-
|
|
22331
|
-
|
|
22332
|
-
return true;
|
|
22333
|
-
} else {
|
|
22573
|
+
if (!this.phone) {
|
|
22574
|
+
logger.log("webrtcSIPPhone: isConnected: phone not initialized");
|
|
22334
22575
|
return false;
|
|
22335
22576
|
}
|
|
22336
|
-
|
|
22577
|
+
const status = this.phone.getStatus();
|
|
22578
|
+
logger.log("webrtcSIPPhone: isConnected: current status:", status);
|
|
22579
|
+
return status !== "offline";
|
|
22580
|
+
}
|
|
22337
22581
|
|
|
22338
|
-
sendDTMFWebRTC
|
|
22582
|
+
sendDTMFWebRTC (dtmfValue){
|
|
22339
22583
|
logger.log("webrtcSIPPhone: sendDTMFWebRTC : ",dtmfValue);
|
|
22340
|
-
phone.sipSendDTMF(dtmfValue);
|
|
22341
|
-
}
|
|
22584
|
+
this.phone.sipSendDTMF(dtmfValue);
|
|
22585
|
+
}
|
|
22342
22586
|
|
|
22343
|
-
registerWebRTCClient
|
|
22587
|
+
registerWebRTCClient (sipAccountInfo, handler){
|
|
22344
22588
|
logger.log("webrtcSIPPhone: registerWebRTCClient : ",sipAccountInfo,handler);
|
|
22345
|
-
sipAccountInfoData = sipAccountInfo;
|
|
22346
|
-
phone.init(() => {
|
|
22347
|
-
phone.loadCredentials(sipAccountInfo);
|
|
22348
|
-
if (
|
|
22589
|
+
this.sipAccountInfoData = sipAccountInfo;
|
|
22590
|
+
this.phone.init(() => {
|
|
22591
|
+
this.phone.loadCredentials(sipAccountInfo);
|
|
22592
|
+
if (this.getWebRTCStatus() == "offline") {
|
|
22349
22593
|
if (handler != null)
|
|
22350
22594
|
if (handler.onFailure)
|
|
22351
22595
|
handler.onFailure();
|
|
@@ -22355,204 +22599,171 @@ const webrtcSIPPhone = {
|
|
|
22355
22599
|
handler.onResponse();
|
|
22356
22600
|
}
|
|
22357
22601
|
});
|
|
22602
|
+
}
|
|
22358
22603
|
|
|
22359
|
-
|
|
22360
|
-
|
|
22361
|
-
|
|
22362
|
-
configureWebRTCClientDevice: (handler) => {
|
|
22604
|
+
configureWebRTCClientDevice (handler){
|
|
22363
22605
|
logger.log("webrtcSIPPhone: configureWebRTCClientDevice : ",handler);
|
|
22364
|
-
phone.registerCallBacks(handler);
|
|
22365
|
-
}
|
|
22606
|
+
this.phone.registerCallBacks(handler);
|
|
22607
|
+
}
|
|
22366
22608
|
|
|
22367
22609
|
setAuthenticatorServerURL(serverURL) {
|
|
22368
22610
|
logger.log("webrtcSIPPhone: setAuthenticatorServerURL : ",serverURL);
|
|
22369
|
-
|
|
22370
|
-
},
|
|
22611
|
+
}
|
|
22371
22612
|
|
|
22372
|
-
toggleSipRegister
|
|
22613
|
+
toggleSipRegister (){
|
|
22373
22614
|
logger.log("webrtcSIPPhone: toggleSipRegister entry");
|
|
22374
|
-
phone.resetRegisterAttempts();
|
|
22375
|
-
phone.sipToggleRegister();
|
|
22376
|
-
}
|
|
22615
|
+
this.phone.resetRegisterAttempts();
|
|
22616
|
+
this.phone.sipToggleRegister();
|
|
22617
|
+
}
|
|
22377
22618
|
|
|
22378
|
-
webRTCMuteUnmute
|
|
22619
|
+
webRTCMuteUnmute (){
|
|
22379
22620
|
logger.log("webrtcSIPPhone: webRTCMuteUnmute");
|
|
22380
|
-
phone.sipToggleMic();
|
|
22381
|
-
}
|
|
22621
|
+
this.phone.sipToggleMic();
|
|
22622
|
+
}
|
|
22382
22623
|
|
|
22383
|
-
getMuteStatus
|
|
22624
|
+
getMuteStatus (){
|
|
22384
22625
|
logger.log("webrtcSIPPhone: getMuteStatus entry");
|
|
22385
|
-
return phone.getMicMuteStatus();
|
|
22386
|
-
}
|
|
22626
|
+
return this.phone.getMicMuteStatus();
|
|
22627
|
+
}
|
|
22387
22628
|
|
|
22388
|
-
muteAction
|
|
22629
|
+
muteAction (bMute){
|
|
22389
22630
|
logger.log("webrtcSIPPhone: muteAction: ",bMute);
|
|
22390
|
-
phone.sipMute(bMute);
|
|
22391
|
-
}
|
|
22631
|
+
this.phone.sipMute(bMute);
|
|
22632
|
+
}
|
|
22392
22633
|
|
|
22393
|
-
holdAction
|
|
22634
|
+
holdAction (bHold){
|
|
22394
22635
|
logger.log("webrtcSIPPhone: holdAction: ",bHold);
|
|
22395
|
-
phone.sipHold(bHold);
|
|
22396
|
-
}
|
|
22636
|
+
this.phone.sipHold(bHold);
|
|
22637
|
+
}
|
|
22397
22638
|
|
|
22398
|
-
holdCall
|
|
22639
|
+
holdCall (){
|
|
22399
22640
|
logger.log("webrtcSIPPhone: holdCall entry");
|
|
22400
|
-
phone.holdCall();
|
|
22401
|
-
}
|
|
22641
|
+
this.phone.holdCall();
|
|
22642
|
+
}
|
|
22402
22643
|
|
|
22403
|
-
pickCall
|
|
22644
|
+
pickCall (){
|
|
22404
22645
|
logger.log("webrtcSIPPhone: pickCall entry");
|
|
22405
|
-
phone.pickPhoneCall();
|
|
22646
|
+
this.phone.pickPhoneCall();
|
|
22406
22647
|
|
|
22407
|
-
|
|
22408
|
-
}
|
|
22648
|
+
this.webrtcSIPPhoneEventDelegate.onPickCall();
|
|
22649
|
+
}
|
|
22409
22650
|
|
|
22410
|
-
rejectCall
|
|
22651
|
+
rejectCall (){
|
|
22411
22652
|
logger.log("webrtcSIPPhone: rejectCall entry");
|
|
22412
|
-
phone.sipHangUp();
|
|
22653
|
+
this.phone.sipHangUp();
|
|
22413
22654
|
|
|
22414
|
-
|
|
22415
|
-
}
|
|
22655
|
+
this.webrtcSIPPhoneEventDelegate.onRejectCall();
|
|
22656
|
+
}
|
|
22416
22657
|
|
|
22417
|
-
reRegisterWebRTCPhone
|
|
22658
|
+
reRegisterWebRTCPhone (){
|
|
22418
22659
|
logger.log("webrtcSIPPhone: reRegisterWebRTCPhone entry");
|
|
22419
|
-
phone.reRegister();
|
|
22420
|
-
}
|
|
22421
|
-
|
|
22660
|
+
this.phone.reRegister();
|
|
22661
|
+
}
|
|
22422
22662
|
|
|
22423
|
-
playBeepTone
|
|
22663
|
+
playBeepTone (){
|
|
22424
22664
|
logger.log("webrtcSIPPhone: playBeepTone entry");
|
|
22425
|
-
phone.playBeep();
|
|
22426
|
-
|
|
22427
|
-
},
|
|
22665
|
+
this.phone.playBeep();
|
|
22666
|
+
}
|
|
22428
22667
|
|
|
22429
|
-
sipUnRegisterWebRTC
|
|
22668
|
+
sipUnRegisterWebRTC (){
|
|
22430
22669
|
logger.log("webrtcSIPPhone: sipUnRegisterWebRTC entry");
|
|
22431
|
-
phone.sipUnRegister();
|
|
22432
|
-
}
|
|
22670
|
+
this.phone.sipUnRegister();
|
|
22671
|
+
}
|
|
22433
22672
|
|
|
22434
|
-
startWSNetworkTest
|
|
22673
|
+
startWSNetworkTest (){
|
|
22435
22674
|
logger.log("webrtcSIPPhone: startWSNetworkTest entry");
|
|
22436
|
-
|
|
22437
|
-
phone.sipRegister();
|
|
22438
|
-
}
|
|
22675
|
+
this.testingMode = true;
|
|
22676
|
+
this.phone.sipRegister();
|
|
22677
|
+
}
|
|
22439
22678
|
|
|
22440
|
-
stopWSNetworkTest
|
|
22679
|
+
stopWSNetworkTest (){
|
|
22441
22680
|
logger.log("webrtcSIPPhone stopWSNetworkTest entry");
|
|
22442
|
-
phone.sipUnRegister();
|
|
22443
|
-
}
|
|
22444
|
-
|
|
22445
|
-
|
|
22446
|
-
|
|
22447
|
-
registerPhone: (engine, delegate) => {
|
|
22448
|
-
logger.log("webrtcSIPPhone: registerPhone : ",engine);
|
|
22449
|
-
webrtcSIPEngine = engine;
|
|
22450
|
-
switch (engine) {
|
|
22451
|
-
case "sipjs":
|
|
22452
|
-
phone = _sipjsphone__WEBPACK_IMPORTED_MODULE_1__["default"];
|
|
22453
|
-
break;
|
|
22454
|
-
default:
|
|
22455
|
-
break;
|
|
22456
|
-
}
|
|
22457
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].registerDelegate(delegate);
|
|
22458
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].onRegisterWebRTCSIPEngine(engine);
|
|
22459
|
-
|
|
22460
|
-
|
|
22461
|
-
},
|
|
22462
|
-
|
|
22463
|
-
getWebRTCStatus: () => {
|
|
22464
|
-
logger.log("webrtcSIPPhone: getWebRTCStatus entry");
|
|
22465
|
-
var status = phone.getStatus();
|
|
22466
|
-
return status;
|
|
22467
|
-
},
|
|
22681
|
+
this.phone.sipUnRegister();
|
|
22682
|
+
}
|
|
22468
22683
|
|
|
22469
|
-
disconnect
|
|
22684
|
+
disconnect (){
|
|
22470
22685
|
logger.log("webrtcSIPPhone: disconnect entry");
|
|
22471
|
-
if (phone) {
|
|
22472
|
-
phone.disconnect();
|
|
22686
|
+
if (this.phone) {
|
|
22687
|
+
this.phone.disconnect();
|
|
22473
22688
|
}
|
|
22474
|
-
}
|
|
22689
|
+
}
|
|
22475
22690
|
|
|
22476
|
-
connect
|
|
22691
|
+
connect (){
|
|
22477
22692
|
logger.log("webrtcSIPPhone: connect entry");
|
|
22478
|
-
phone.connect();
|
|
22479
|
-
}
|
|
22693
|
+
this.phone.connect();
|
|
22694
|
+
}
|
|
22480
22695
|
|
|
22481
22696
|
getSIPAccountInfo() {
|
|
22482
22697
|
logger.log("webrtcSIPPhone: getSIPAccountInfo entry");
|
|
22483
|
-
return sipAccountInfoData;
|
|
22484
|
-
}
|
|
22698
|
+
return this.sipAccountInfoData;
|
|
22699
|
+
}
|
|
22700
|
+
|
|
22485
22701
|
getWebRTCSIPEngine() {
|
|
22486
22702
|
logger.log("webrtcSIPPhone: getWebRTCSIPEngine entry");
|
|
22487
|
-
return webrtcSIPEngine;
|
|
22488
|
-
}
|
|
22703
|
+
return this.webrtcSIPEngine;
|
|
22704
|
+
}
|
|
22489
22705
|
|
|
22490
22706
|
/* NL Addition - Start */
|
|
22491
22707
|
getSpeakerTestTone() {
|
|
22492
22708
|
logger.log("webrtcSIPPhone: getSpeakerTestTone entry");
|
|
22493
22709
|
try {
|
|
22494
|
-
return
|
|
22710
|
+
return this.phone.getSpeakerTestTone()
|
|
22495
22711
|
} catch (e) {
|
|
22496
22712
|
logger.log("getSpeakerTestTone: Exception ", e)
|
|
22497
22713
|
}
|
|
22498
|
-
}
|
|
22714
|
+
}
|
|
22499
22715
|
|
|
22500
22716
|
getWSSUrl() {
|
|
22501
22717
|
logger.log("webrtcSIPPhone: getWSSUrl entry");
|
|
22502
22718
|
try {
|
|
22503
|
-
return
|
|
22719
|
+
return this.phone.getWSSUrl()
|
|
22504
22720
|
} catch (e) {
|
|
22505
22721
|
logger.log("getWSSUrl: Exception ", e)
|
|
22506
22722
|
}
|
|
22507
|
-
}
|
|
22508
|
-
/* NL Addition - End */
|
|
22723
|
+
}
|
|
22509
22724
|
|
|
22510
22725
|
getTransportState() {
|
|
22511
22726
|
logger.log("webrtcSIPPhone: getTransportState entry");
|
|
22512
22727
|
try {
|
|
22513
|
-
return
|
|
22728
|
+
return this.phone.getTransportState();
|
|
22514
22729
|
} catch (e) {
|
|
22515
22730
|
logger.log("getTransportState: Exception ", e);
|
|
22516
22731
|
return "unknown";
|
|
22517
22732
|
}
|
|
22518
|
-
}
|
|
22733
|
+
}
|
|
22519
22734
|
|
|
22520
22735
|
getRegistrationState() {
|
|
22521
22736
|
logger.log("webrtcSIPPhone: getRegistrationState entry");
|
|
22522
22737
|
try {
|
|
22523
|
-
return
|
|
22738
|
+
return this.phone.getRegistrationState();
|
|
22524
22739
|
} catch (e) {
|
|
22525
22740
|
logger.log("getTransportState: Exception ", e);
|
|
22526
22741
|
return "unknown";
|
|
22527
22742
|
}
|
|
22528
|
-
}
|
|
22743
|
+
}
|
|
22529
22744
|
|
|
22530
22745
|
changeAudioInputDevice(deviceId, onSuccess, onError) {
|
|
22531
22746
|
logger.log("webrtcSIPPhone: changeAudioInputDevice : ", deviceId, onSuccess, onError);
|
|
22532
|
-
|
|
22533
|
-
}
|
|
22747
|
+
this.phone.changeAudioInputDevice(deviceId, onSuccess, onError);
|
|
22748
|
+
}
|
|
22534
22749
|
|
|
22535
22750
|
changeAudioOutputDevice(deviceId, onSuccess, onError) {
|
|
22536
22751
|
logger.log("webrtcSIPPhone: changeAudioOutputDevice : ", deviceId, onSuccess, onError);
|
|
22537
|
-
|
|
22538
|
-
}
|
|
22752
|
+
this.phone.changeAudioOutputDevice(deviceId, onSuccess, onError);
|
|
22753
|
+
}
|
|
22754
|
+
|
|
22539
22755
|
setPreferredCodec(codecName) {
|
|
22540
22756
|
logger.log("webrtcSIPPhone: setPreferredCodec : ", codecName);
|
|
22541
|
-
|
|
22542
|
-
}
|
|
22757
|
+
this.phone.setPreferredCodec(codecName);
|
|
22758
|
+
}
|
|
22759
|
+
|
|
22543
22760
|
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback) {
|
|
22544
22761
|
logger.log("webrtcSIPPhone: registerAudioDeviceChangeCallback entry");
|
|
22545
|
-
|
|
22546
|
-
},
|
|
22547
|
-
getLogger() {
|
|
22548
|
-
return _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
22762
|
+
this.phone.registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback);
|
|
22549
22763
|
}
|
|
22764
|
+
}
|
|
22550
22765
|
|
|
22551
|
-
|
|
22552
|
-
|
|
22553
|
-
|
|
22554
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (webrtcSIPPhone);
|
|
22555
|
-
|
|
22766
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (WebrtcSIPPhone);
|
|
22556
22767
|
|
|
22557
22768
|
/***/ }),
|
|
22558
22769
|
|
|
@@ -22567,183 +22778,257 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
22567
22778
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
22568
22779
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
22569
22780
|
/* harmony export */ });
|
|
22570
|
-
/*
|
|
22571
|
-
* delegate listener , webrtc sip phone could invoke events to delegate and it will further send event to registered delegator
|
|
22572
|
-
*/
|
|
22573
|
-
let testingMode = false;
|
|
22574
|
-
let delegate = null;
|
|
22781
|
+
/* harmony import */ var _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./coreSDKLogger */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/coreSDKLogger.js");
|
|
22575
22782
|
|
|
22576
22783
|
|
|
22577
|
-
const
|
|
22578
|
-
|
|
22579
|
-
registerDelegate : (webrtcDelegate) => {
|
|
22580
|
-
delegate = webrtcDelegate;
|
|
22581
|
-
},
|
|
22784
|
+
const logger = _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
22582
22785
|
|
|
22583
|
-
|
|
22584
|
-
if(delegate) {
|
|
22585
|
-
delegate.setTestingMode(mode);
|
|
22586
|
-
}
|
|
22587
|
-
},
|
|
22588
|
-
|
|
22589
|
-
onCallStatSipJsSessionEvent : (ev) => {
|
|
22590
|
-
if(delegate) {
|
|
22591
|
-
delegate.onCallStatSipJsSessionEvent(ev);
|
|
22592
|
-
}
|
|
22593
|
-
},
|
|
22594
|
-
|
|
22595
|
-
sendWebRTCEventsToFSM : (eventType, sipMethod) => {
|
|
22596
|
-
if(delegate) {
|
|
22597
|
-
delegate.sendWebRTCEventsToFSM(eventType, sipMethod);
|
|
22598
|
-
}
|
|
22599
|
-
},
|
|
22600
|
-
|
|
22601
|
-
playBeepTone : () => {
|
|
22602
|
-
if(delegate) {
|
|
22603
|
-
delegate.playBeepTone();
|
|
22604
|
-
}
|
|
22605
|
-
},
|
|
22606
|
-
|
|
22607
|
-
onStatPeerConnectionIceGatheringStateChange: (iceGatheringState) => {
|
|
22608
|
-
if(delegate) {
|
|
22609
|
-
delegate.onStatPeerConnectionIceGatheringStateChange(iceGatheringState);
|
|
22610
|
-
}
|
|
22611
|
-
},
|
|
22612
|
-
|
|
22613
|
-
onCallStatIceCandidate: (ev, icestate) => {
|
|
22614
|
-
if(delegate) {
|
|
22615
|
-
delegate.onCallStatIceCandidate(ev,icestate);
|
|
22616
|
-
}
|
|
22617
|
-
},
|
|
22618
|
-
|
|
22619
|
-
|
|
22620
|
-
onCallStatNegoNeeded: (icestate) => {
|
|
22621
|
-
if(delegate) {
|
|
22622
|
-
delegate.onCallStatNegoNeeded(icestate);
|
|
22623
|
-
}
|
|
22624
|
-
},
|
|
22786
|
+
class WebrtcSIPPhoneEventDelegate {
|
|
22625
22787
|
|
|
22626
|
-
|
|
22627
|
-
|
|
22628
|
-
|
|
22629
|
-
|
|
22630
|
-
}
|
|
22788
|
+
constructor(username) {
|
|
22789
|
+
this.username = username;
|
|
22790
|
+
this._listeners = new Map();
|
|
22791
|
+
this.delegates = new Set();
|
|
22792
|
+
}
|
|
22631
22793
|
|
|
22632
|
-
|
|
22633
|
-
|
|
22634
|
-
|
|
22635
|
-
|
|
22636
|
-
|
|
22637
|
-
},
|
|
22638
|
-
|
|
22639
|
-
|
|
22640
|
-
onStatPeerConnectionConnectionStateChange: () => {
|
|
22641
|
-
if(delegate) {
|
|
22642
|
-
delegate.onStatPeerConnectionConnectionStateChange();
|
|
22643
|
-
}
|
|
22644
|
-
},
|
|
22645
|
-
|
|
22646
|
-
onGetUserMediaSuccessCallstatCallback: () => {
|
|
22647
|
-
if(delegate) {
|
|
22648
|
-
delegate.onGetUserMediaSuccessCallstatCallback();
|
|
22649
|
-
}
|
|
22650
|
-
},
|
|
22794
|
+
/**
|
|
22795
|
+
* @param {string} event
|
|
22796
|
+
* @param {Function} handler
|
|
22797
|
+
* @returns {Function}
|
|
22798
|
+
*/
|
|
22651
22799
|
|
|
22652
|
-
|
|
22653
|
-
if(
|
|
22654
|
-
|
|
22655
|
-
}
|
|
22656
|
-
},
|
|
22657
|
-
|
|
22658
|
-
|
|
22659
|
-
onCallStatAddStream: () => {
|
|
22660
|
-
if(delegate) {
|
|
22661
|
-
delegate.onCallStatAddStream();
|
|
22800
|
+
attach(event, handler) {
|
|
22801
|
+
if (!this._listeners.has(event)) {
|
|
22802
|
+
this._listeners.set(event, new Set());
|
|
22662
22803
|
}
|
|
22663
|
-
|
|
22804
|
+
this._listeners.get(event).add(handler);
|
|
22664
22805
|
|
|
22665
|
-
|
|
22666
|
-
|
|
22667
|
-
delegate.onCallStatRemoveStream();
|
|
22668
|
-
}
|
|
22669
|
-
},
|
|
22670
|
-
|
|
22671
|
-
setWebRTCFSMMapper : () => {
|
|
22672
|
-
if(delegate) {
|
|
22673
|
-
delegate.setWebRTCFSMMapper();
|
|
22674
|
-
}
|
|
22675
|
-
},
|
|
22676
|
-
|
|
22677
|
-
onCallStatSipJsTransportEvent : () => {
|
|
22678
|
-
if(delegate) {
|
|
22679
|
-
delegate.onCallStatSipJsTransportEvent();
|
|
22680
|
-
}
|
|
22681
|
-
},
|
|
22682
|
-
|
|
22683
|
-
onCallStatSipSendCallback: (tsipData, sipStack) => {
|
|
22684
|
-
if(delegate) {
|
|
22685
|
-
delegate.onCallStatSipSendCallback();
|
|
22686
|
-
}
|
|
22687
|
-
},
|
|
22806
|
+
return () => this._listeners.get(event)?.delete(handler);
|
|
22807
|
+
}
|
|
22688
22808
|
|
|
22689
|
-
|
|
22690
|
-
|
|
22691
|
-
|
|
22692
|
-
|
|
22693
|
-
|
|
22809
|
+
emit(event, ...args) {
|
|
22810
|
+
this._listeners.get(event)?.forEach((h) => {
|
|
22811
|
+
try {
|
|
22812
|
+
h(...args);
|
|
22813
|
+
} catch (e) {
|
|
22814
|
+
console.error(`[Delegate:${this.username}]`, e);
|
|
22815
|
+
}
|
|
22816
|
+
});
|
|
22817
|
+
}
|
|
22694
22818
|
|
|
22695
|
-
|
|
22696
|
-
|
|
22697
|
-
|
|
22698
|
-
}
|
|
22699
|
-
},
|
|
22700
|
-
|
|
22701
|
-
onRecieveInvite: (incomingSession) => {
|
|
22702
|
-
if(delegate) {
|
|
22703
|
-
delegate.onRecieveInvite(incomingSession);
|
|
22704
|
-
}
|
|
22705
|
-
},
|
|
22706
|
-
|
|
22707
|
-
onPickCall: () => {
|
|
22708
|
-
if(delegate) {
|
|
22709
|
-
delegate.onPickCall();
|
|
22710
|
-
}
|
|
22711
|
-
},
|
|
22819
|
+
registerDelegate(webrtcDelegate) {
|
|
22820
|
+
this.delegates.add(webrtcDelegate);
|
|
22821
|
+
}
|
|
22712
22822
|
|
|
22713
|
-
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
}
|
|
22717
|
-
},
|
|
22718
|
-
|
|
22719
|
-
onCreaterAnswer: () => {
|
|
22720
|
-
if(delegate) {
|
|
22721
|
-
delegate.onCreaterAnswer();
|
|
22722
|
-
}
|
|
22723
|
-
},
|
|
22823
|
+
unregisterDelegate(webrtcDelegate) {
|
|
22824
|
+
this.delegates.delete(webrtcDelegate);
|
|
22825
|
+
}
|
|
22724
22826
|
|
|
22725
|
-
|
|
22726
|
-
|
|
22727
|
-
delegate.
|
|
22728
|
-
|
|
22729
|
-
|
|
22827
|
+
setTestingMode(mode) {
|
|
22828
|
+
this.delegates.forEach(delegate => {
|
|
22829
|
+
if (delegate && typeof delegate.setTestingMode === 'function') {
|
|
22830
|
+
delegate.setTestingMode(mode);
|
|
22831
|
+
}
|
|
22832
|
+
});
|
|
22833
|
+
}
|
|
22730
22834
|
|
|
22731
|
-
|
|
22732
|
-
|
|
22733
|
-
delegate.
|
|
22734
|
-
|
|
22735
|
-
|
|
22736
|
-
|
|
22737
|
-
|
|
22738
|
-
|
|
22739
|
-
|
|
22740
|
-
|
|
22835
|
+
onCallStatSipJsSessionEvent(ev) {
|
|
22836
|
+
this.delegates.forEach(delegate => {
|
|
22837
|
+
if (delegate && typeof delegate.onCallStatSipJsSessionEvent === 'function') {
|
|
22838
|
+
delegate.onCallStatSipJsSessionEvent(ev);
|
|
22839
|
+
}
|
|
22840
|
+
});
|
|
22841
|
+
}
|
|
22842
|
+
|
|
22843
|
+
sendWebRTCEventsToFSM(eventType, sipMethod) {
|
|
22844
|
+
logger.log("delegationHandler: sendWebRTCEventsToFSM");
|
|
22845
|
+
logger.log("delegationHandler: eventType", [eventType]);
|
|
22846
|
+
logger.log("delegationHandler: sipMethod", [sipMethod]);
|
|
22847
|
+
this.delegates.forEach(delegate => {
|
|
22848
|
+
if (delegate && typeof delegate.sendWebRTCEventsToFSM === 'function') {
|
|
22849
|
+
delegate.sendWebRTCEventsToFSM(eventType, sipMethod);
|
|
22850
|
+
}
|
|
22851
|
+
});
|
|
22852
|
+
}
|
|
22853
|
+
|
|
22854
|
+
playBeepTone() {
|
|
22855
|
+
this.delegates.forEach(delegate => {
|
|
22856
|
+
if (delegate && typeof delegate.playBeepTone === 'function') {
|
|
22857
|
+
delegate.playBeepTone();
|
|
22858
|
+
}
|
|
22859
|
+
});
|
|
22860
|
+
}
|
|
22861
|
+
|
|
22862
|
+
onStatPeerConnectionIceGatheringStateChange(iceGatheringState) {
|
|
22863
|
+
this.delegates.forEach(delegate => {
|
|
22864
|
+
if (delegate && typeof delegate.onStatPeerConnectionIceGatheringStateChange === 'function') {
|
|
22865
|
+
delegate.onStatPeerConnectionIceGatheringStateChange(iceGatheringState);
|
|
22866
|
+
}
|
|
22867
|
+
});
|
|
22868
|
+
}
|
|
22869
|
+
|
|
22870
|
+
onCallStatIceCandidate(ev, icestate) {
|
|
22871
|
+
this.delegates.forEach(delegate => {
|
|
22872
|
+
if (delegate && typeof delegate.onCallStatIceCandidate === 'function') {
|
|
22873
|
+
delegate.onCallStatIceCandidate(ev, icestate);
|
|
22874
|
+
}
|
|
22875
|
+
});
|
|
22876
|
+
}
|
|
22877
|
+
|
|
22878
|
+
onCallStatNegoNeeded(icestate) {
|
|
22879
|
+
this.delegates.forEach(delegate => {
|
|
22880
|
+
if (delegate && typeof delegate.onCallStatNegoNeeded === 'function') {
|
|
22881
|
+
delegate.onCallStatNegoNeeded(icestate);
|
|
22882
|
+
}
|
|
22883
|
+
});
|
|
22884
|
+
}
|
|
22885
|
+
|
|
22886
|
+
onCallStatSignalingStateChange(cstate) {
|
|
22887
|
+
this.delegates.forEach(delegate => {
|
|
22888
|
+
if (delegate && typeof delegate.onCallStatSignalingStateChange === 'function') {
|
|
22889
|
+
delegate.onCallStatSignalingStateChange(cstate);
|
|
22890
|
+
}
|
|
22891
|
+
});
|
|
22892
|
+
}
|
|
22893
|
+
|
|
22894
|
+
onStatPeerConnectionIceConnectionStateChange() {
|
|
22895
|
+
this.delegates.forEach(delegate => {
|
|
22896
|
+
if (delegate && typeof delegate.onStatPeerConnectionIceConnectionStateChange === 'function') {
|
|
22897
|
+
delegate.onStatPeerConnectionIceConnectionStateChange();
|
|
22898
|
+
}
|
|
22899
|
+
});
|
|
22900
|
+
}
|
|
22901
|
+
|
|
22902
|
+
onStatPeerConnectionConnectionStateChange() {
|
|
22903
|
+
this.delegates.forEach(delegate => {
|
|
22904
|
+
if (delegate && typeof delegate.onStatPeerConnectionConnectionStateChange === 'function') {
|
|
22905
|
+
delegate.onStatPeerConnectionConnectionStateChange();
|
|
22906
|
+
}
|
|
22907
|
+
});
|
|
22908
|
+
}
|
|
22909
|
+
|
|
22910
|
+
onGetUserMediaSuccessCallstatCallback() {
|
|
22911
|
+
this.delegates.forEach(delegate => {
|
|
22912
|
+
if (delegate && typeof delegate.onGetUserMediaSuccessCallstatCallback === 'function') {
|
|
22913
|
+
delegate.onGetUserMediaSuccessCallstatCallback();
|
|
22914
|
+
}
|
|
22915
|
+
});
|
|
22916
|
+
}
|
|
22917
|
+
|
|
22918
|
+
onGetUserMediaErrorCallstatCallback() {
|
|
22919
|
+
this.delegates.forEach(delegate => {
|
|
22920
|
+
if (delegate && typeof delegate.onGetUserMediaErrorCallstatCallback === 'function') {
|
|
22921
|
+
delegate.onGetUserMediaErrorCallstatCallback();
|
|
22922
|
+
}
|
|
22923
|
+
});
|
|
22924
|
+
}
|
|
22925
|
+
|
|
22926
|
+
onCallStatAddStream() {
|
|
22927
|
+
this.delegates.forEach(delegate => {
|
|
22928
|
+
if (delegate && typeof delegate.onCallStatAddStream === 'function') {
|
|
22929
|
+
delegate.onCallStatAddStream();
|
|
22930
|
+
}
|
|
22931
|
+
});
|
|
22932
|
+
}
|
|
22933
|
+
|
|
22934
|
+
onCallStatRemoveStream() {
|
|
22935
|
+
this.delegates.forEach(delegate => {
|
|
22936
|
+
if (delegate && typeof delegate.onCallStatRemoveStream === 'function') {
|
|
22937
|
+
delegate.onCallStatRemoveStream();
|
|
22938
|
+
}
|
|
22939
|
+
});
|
|
22940
|
+
}
|
|
22941
|
+
|
|
22942
|
+
setWebRTCFSMMapper(stack) {
|
|
22943
|
+
logger.log("webrtcSIPPhoneEventDelegate: setWebRTCFSMMapper: Initialisation complete");
|
|
22944
|
+
}
|
|
22945
|
+
|
|
22946
|
+
onCallStatSipJsTransportEvent(ev) {
|
|
22947
|
+
this.delegates.forEach(delegate => {
|
|
22948
|
+
if (delegate && typeof delegate.onCallStatSipJsTransportEvent === 'function') {
|
|
22949
|
+
delegate.onCallStatSipJsTransportEvent(ev);
|
|
22950
|
+
}
|
|
22951
|
+
});
|
|
22952
|
+
}
|
|
22953
|
+
|
|
22954
|
+
onCallStatSipSendCallback(tsipData, sipStack) {
|
|
22955
|
+
this.delegates.forEach(delegate => {
|
|
22956
|
+
if (delegate && typeof delegate.onCallStatSipSendCallback === 'function') {
|
|
22957
|
+
delegate.onCallStatSipSendCallback(tsipData, sipStack);
|
|
22958
|
+
}
|
|
22959
|
+
});
|
|
22960
|
+
}
|
|
22961
|
+
|
|
22962
|
+
onCallStatSipRecvCallback(tsipData, sipStack) {
|
|
22963
|
+
this.delegates.forEach(delegate => {
|
|
22964
|
+
if (delegate && typeof delegate.onCallStatSipRecvCallback === 'function') {
|
|
22965
|
+
delegate.onCallStatSipRecvCallback(tsipData, sipStack);
|
|
22966
|
+
}
|
|
22967
|
+
});
|
|
22968
|
+
}
|
|
22969
|
+
|
|
22970
|
+
stopCallStat() {
|
|
22971
|
+
this.delegates.forEach(delegate => {
|
|
22972
|
+
if (delegate && typeof delegate.stopCallStat === 'function') {
|
|
22973
|
+
delegate.stopCallStat();
|
|
22974
|
+
}
|
|
22975
|
+
});
|
|
22976
|
+
}
|
|
22977
|
+
|
|
22978
|
+
onRecieveInvite(incomingSession) {
|
|
22979
|
+
this.delegates.forEach(delegate => {
|
|
22980
|
+
if (delegate && typeof delegate.onRecieveInvite === 'function') {
|
|
22981
|
+
delegate.onRecieveInvite(incomingSession);
|
|
22982
|
+
}
|
|
22983
|
+
});
|
|
22984
|
+
}
|
|
22985
|
+
|
|
22986
|
+
onPickCall() {
|
|
22987
|
+
this.delegates.forEach(delegate => {
|
|
22988
|
+
if (delegate && typeof delegate.onPickCall === 'function') {
|
|
22989
|
+
delegate.onPickCall();
|
|
22990
|
+
}
|
|
22991
|
+
});
|
|
22992
|
+
}
|
|
22993
|
+
|
|
22994
|
+
onRejectCall() {
|
|
22995
|
+
this.delegates.forEach(delegate => {
|
|
22996
|
+
if (delegate && typeof delegate.onRejectCall === 'function') {
|
|
22997
|
+
delegate.onRejectCall();
|
|
22998
|
+
}
|
|
22999
|
+
});
|
|
23000
|
+
}
|
|
23001
|
+
|
|
23002
|
+
onCreaterAnswer() {
|
|
23003
|
+
this.delegates.forEach(delegate => {
|
|
23004
|
+
if (delegate && typeof delegate.onCreaterAnswer === 'function') {
|
|
23005
|
+
delegate.onCreaterAnswer();
|
|
23006
|
+
}
|
|
23007
|
+
});
|
|
23008
|
+
}
|
|
23009
|
+
|
|
23010
|
+
onSettingLocalDesc() {
|
|
23011
|
+
this.delegates.forEach(delegate => {
|
|
23012
|
+
if (delegate && typeof delegate.onSettingLocalDesc === 'function') {
|
|
23013
|
+
delegate.onSettingLocalDesc();
|
|
23014
|
+
}
|
|
23015
|
+
});
|
|
23016
|
+
}
|
|
23017
|
+
|
|
23018
|
+
initGetStats(pc, callid, username) {
|
|
23019
|
+
this.delegates.forEach(delegate => {
|
|
23020
|
+
if (delegate && typeof delegate.initGetStats === 'function') {
|
|
23021
|
+
delegate.initGetStats(pc, callid, username);
|
|
23022
|
+
}
|
|
23023
|
+
});
|
|
23024
|
+
}
|
|
23025
|
+
|
|
23026
|
+
onRegisterWebRTCSIPEngine(engine) {
|
|
23027
|
+
this.emit("engine-selected", engine);
|
|
22741
23028
|
}
|
|
22742
|
-
|
|
22743
|
-
|
|
22744
23029
|
}
|
|
22745
23030
|
|
|
22746
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (
|
|
23031
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (WebrtcSIPPhoneEventDelegate);
|
|
22747
23032
|
|
|
22748
23033
|
/***/ }),
|
|
22749
23034
|
|
|
@@ -22811,51 +23096,54 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
22811
23096
|
/* harmony import */ var _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @exotel-npm-dev/webrtc-core-sdk */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/index.js");
|
|
22812
23097
|
|
|
22813
23098
|
|
|
22814
|
-
|
|
22815
|
-
function Call() {
|
|
23099
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_1__.getLogger)();
|
|
23100
|
+
function Call(webrtcSIPPhone) {
|
|
23101
|
+
if (!webrtcSIPPhone) {
|
|
23102
|
+
throw new Error("webrtcSIPPhone is required for Call");
|
|
23103
|
+
}
|
|
22816
23104
|
this.Answer = function () {
|
|
22817
23105
|
/**
|
|
22818
23106
|
* When agent accepts phone, add appropriate msg to be sent to webclient
|
|
22819
23107
|
*/
|
|
22820
23108
|
logger.log('Call answered');
|
|
22821
|
-
|
|
23109
|
+
webrtcSIPPhone.pickCall();
|
|
22822
23110
|
};
|
|
22823
23111
|
this.Hangup = function () {
|
|
22824
23112
|
/**
|
|
22825
23113
|
* When call is terminated
|
|
22826
23114
|
*/
|
|
22827
23115
|
logger.log('call ended');
|
|
22828
|
-
|
|
23116
|
+
webrtcSIPPhone.rejectCall();
|
|
22829
23117
|
};
|
|
22830
23118
|
this.MuteToggle = function () {
|
|
22831
23119
|
/**
|
|
22832
23120
|
* When agent clicks on mute
|
|
22833
23121
|
*/
|
|
22834
23122
|
logger.log('Call: MuteToggle');
|
|
22835
|
-
|
|
23123
|
+
webrtcSIPPhone.webRTCMuteUnmute();
|
|
22836
23124
|
};
|
|
22837
23125
|
this.Mute = function () {
|
|
22838
23126
|
/**
|
|
22839
23127
|
* When agent clicks on mute
|
|
22840
23128
|
*/
|
|
22841
|
-
var
|
|
22842
|
-
logger.log('Call: Mute:
|
|
22843
|
-
if (
|
|
22844
|
-
|
|
23129
|
+
var isMuted = webrtcSIPPhone.getMuteStatus();
|
|
23130
|
+
logger.log('Call: Mute: isMuted: ', isMuted);
|
|
23131
|
+
if (!isMuted) {
|
|
23132
|
+
webrtcSIPPhone.muteAction(true);
|
|
22845
23133
|
} else {
|
|
22846
|
-
logger.log('Call: Mute:
|
|
23134
|
+
logger.log('Call: Mute: Already muted');
|
|
22847
23135
|
}
|
|
22848
23136
|
};
|
|
22849
23137
|
this.UnMute = function () {
|
|
22850
23138
|
/**
|
|
22851
|
-
* When agent clicks on
|
|
23139
|
+
* When agent clicks on unmute
|
|
22852
23140
|
*/
|
|
22853
|
-
var
|
|
22854
|
-
logger.log('Call: UnMute:
|
|
22855
|
-
if (
|
|
22856
|
-
|
|
23141
|
+
var isMuted = webrtcSIPPhone.getMuteStatus();
|
|
23142
|
+
logger.log('Call: UnMute: isMuted: ', isMuted);
|
|
23143
|
+
if (isMuted) {
|
|
23144
|
+
webrtcSIPPhone.muteAction(false);
|
|
22857
23145
|
} else {
|
|
22858
|
-
|
|
23146
|
+
logger.log('Call: UnMute: Already unmuted');
|
|
22859
23147
|
}
|
|
22860
23148
|
};
|
|
22861
23149
|
this.HoldToggle = function () {
|
|
@@ -22863,7 +23151,7 @@ function Call() {
|
|
|
22863
23151
|
* When user clicks on hold
|
|
22864
23152
|
*/
|
|
22865
23153
|
logger.log('Hold toggle clicked');
|
|
22866
|
-
|
|
23154
|
+
webrtcSIPPhone.holdCall();
|
|
22867
23155
|
};
|
|
22868
23156
|
this.Hold = function () {
|
|
22869
23157
|
/**
|
|
@@ -22871,7 +23159,7 @@ function Call() {
|
|
|
22871
23159
|
*/
|
|
22872
23160
|
logger.log('hold clicked');
|
|
22873
23161
|
let dummyFlag = true;
|
|
22874
|
-
|
|
23162
|
+
webrtcSIPPhone.holdCall();
|
|
22875
23163
|
};
|
|
22876
23164
|
this.UnHold = function () {
|
|
22877
23165
|
/**
|
|
@@ -22879,7 +23167,7 @@ function Call() {
|
|
|
22879
23167
|
*/
|
|
22880
23168
|
logger.log('unhold clicked');
|
|
22881
23169
|
let dummyFlag = true;
|
|
22882
|
-
|
|
23170
|
+
webrtcSIPPhone.holdCall();
|
|
22883
23171
|
};
|
|
22884
23172
|
this.callDetails = function () {
|
|
22885
23173
|
/**
|
|
@@ -22892,7 +23180,7 @@ function Call() {
|
|
|
22892
23180
|
* sends dtmf digit as SIP info over websocket
|
|
22893
23181
|
*/
|
|
22894
23182
|
logger.log("trying to send dtmf " + digit);
|
|
22895
|
-
|
|
23183
|
+
webrtcSIPPhone.sendDTMFWebRTC(digit);
|
|
22896
23184
|
};
|
|
22897
23185
|
}
|
|
22898
23186
|
|
|
@@ -22997,13 +23285,14 @@ var CallDetails = {
|
|
|
22997
23285
|
"use strict";
|
|
22998
23286
|
__webpack_require__.r(__webpack_exports__);
|
|
22999
23287
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23288
|
+
/* harmony export */ Diagnostics: () => (/* binding */ Diagnostics),
|
|
23000
23289
|
/* harmony export */ ameyoWebRTCTroubleshooter: () => (/* binding */ ameyoWebRTCTroubleshooter)
|
|
23001
23290
|
/* harmony export */ });
|
|
23002
|
-
/* harmony import */ var
|
|
23003
|
-
/* harmony import */ var
|
|
23291
|
+
/* harmony import */ var _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @exotel-npm-dev/webrtc-core-sdk */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/index.js");
|
|
23292
|
+
/* harmony import */ var _listeners_Callback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../listeners/Callback */ "./src/listeners/Callback.js");
|
|
23004
23293
|
|
|
23005
23294
|
|
|
23006
|
-
|
|
23295
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.getLogger)();
|
|
23007
23296
|
var speakerNode;
|
|
23008
23297
|
var micNode;
|
|
23009
23298
|
var audioTrack;
|
|
@@ -23025,6 +23314,18 @@ eventMapper.sipml5.transport_error = "WS_TEST_FAIL";
|
|
|
23025
23314
|
eventMapper.sipml5.connected_REGISTER = "USER_REG_TEST_PASS";
|
|
23026
23315
|
eventMapper.sipml5.terminated_REGISTER = "USER_REG_TEST_FAIL";
|
|
23027
23316
|
var candidateProcessData = {};
|
|
23317
|
+
class Diagnostics {
|
|
23318
|
+
constructor() {
|
|
23319
|
+
this.report = {};
|
|
23320
|
+
}
|
|
23321
|
+
setReport(key, value) {
|
|
23322
|
+
this.report[key] = value;
|
|
23323
|
+
logger.log("Diagnostics: setReport", key, value);
|
|
23324
|
+
}
|
|
23325
|
+
getReport() {
|
|
23326
|
+
return this.report;
|
|
23327
|
+
}
|
|
23328
|
+
}
|
|
23028
23329
|
var ameyoWebRTCTroubleshooter = {
|
|
23029
23330
|
js_yyyy_mm_dd_hh_mm_ss: function () {
|
|
23030
23331
|
var now = new Date();
|
|
@@ -23063,7 +23364,7 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23063
23364
|
msg = oldMsg + msg;
|
|
23064
23365
|
}
|
|
23065
23366
|
window.localStorage.setItem('troubleShootReport', msg);
|
|
23066
|
-
|
|
23367
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerDiagnosticsSaveCallback('troubleShootReport', msg);
|
|
23067
23368
|
//}
|
|
23068
23369
|
},
|
|
23069
23370
|
|
|
@@ -23116,29 +23417,40 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23116
23417
|
}
|
|
23117
23418
|
return browserName + "/" + version;
|
|
23118
23419
|
},
|
|
23119
|
-
stopSpeakerTesttone: function () {
|
|
23120
|
-
|
|
23420
|
+
stopSpeakerTesttone: function (webrtcSIPPhone) {
|
|
23421
|
+
if (!webrtcSIPPhone) {
|
|
23422
|
+
logger.log("stopSpeakerTesttone: webrtcSIPPhone not provided");
|
|
23423
|
+
return;
|
|
23424
|
+
}
|
|
23425
|
+
speakerTestTone = webrtcSIPPhone.getSpeakerTestTone();
|
|
23121
23426
|
speakerTestTone.pause();
|
|
23122
23427
|
},
|
|
23123
|
-
stopSpeakerTesttoneWithSuccess: function () {
|
|
23124
|
-
this.stopSpeakerTest();
|
|
23428
|
+
stopSpeakerTesttoneWithSuccess: function (webrtcSIPPhone) {
|
|
23429
|
+
this.stopSpeakerTest(webrtcSIPPhone);
|
|
23125
23430
|
this.sendDeviceTestingEvent("SPEAKER_TEST_PASS");
|
|
23126
23431
|
this.addToTrobuleshootReport("INFO", "Speaker device testing is successfull");
|
|
23127
23432
|
this.addToTrobuleshootReport("INFO", "Speaker device testing is completed");
|
|
23128
23433
|
},
|
|
23129
|
-
stopSpeakerTesttoneWithFailure: function () {
|
|
23130
|
-
this.stopSpeakerTest();
|
|
23434
|
+
stopSpeakerTesttoneWithFailure: function (webrtcSIPPhone) {
|
|
23435
|
+
this.stopSpeakerTest(webrtcSIPPhone);
|
|
23131
23436
|
this.sendDeviceTestingEvent("SPEAKER_TEST_FAIL");
|
|
23132
23437
|
this.addToTrobuleshootReport("INFO", "Speaker device testing is failed");
|
|
23133
23438
|
this.addToTrobuleshootReport("INFO", "Speaker device testing is completed");
|
|
23134
23439
|
},
|
|
23135
|
-
startSpeakerTest: function () {
|
|
23440
|
+
startSpeakerTest: function (webrtcSIPPhone) {
|
|
23136
23441
|
var parent = this;
|
|
23442
|
+
if (!webrtcSIPPhone) {
|
|
23443
|
+
logger.log("startSpeakerTest: webrtcSIPPhone not provided");
|
|
23444
|
+
return;
|
|
23445
|
+
}
|
|
23446
|
+
if (intervalID) {
|
|
23447
|
+
logger.log("startSpeakerTest: already running");
|
|
23448
|
+
return;
|
|
23449
|
+
}
|
|
23137
23450
|
try {
|
|
23138
23451
|
intervalID = setInterval(function () {
|
|
23139
23452
|
try {
|
|
23140
|
-
speakerTestTone =
|
|
23141
|
-
/* Close last pending tracks.. */
|
|
23453
|
+
speakerTestTone = webrtcSIPPhone.getSpeakerTestTone();
|
|
23142
23454
|
logger.log("close last track");
|
|
23143
23455
|
speakerTestTone.pause();
|
|
23144
23456
|
parent.closeAudioTrack();
|
|
@@ -23185,14 +23497,18 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23185
23497
|
//Enable this for tone loop - End
|
|
23186
23498
|
},
|
|
23187
23499
|
|
|
23188
|
-
stopSpeakerTest: function () {
|
|
23500
|
+
stopSpeakerTest: function (webrtcSIPPhone) {
|
|
23189
23501
|
var parent = this;
|
|
23190
|
-
|
|
23191
|
-
|
|
23502
|
+
if (!webrtcSIPPhone) {
|
|
23503
|
+
logger.log("stopSpeakerTest: webrtcSIPPhone not provided");
|
|
23504
|
+
return;
|
|
23505
|
+
}
|
|
23506
|
+
speakerTestTone = webrtcSIPPhone.getSpeakerTestTone();
|
|
23192
23507
|
try {
|
|
23193
|
-
|
|
23194
|
-
|
|
23195
|
-
|
|
23508
|
+
if (intervalID) {
|
|
23509
|
+
clearInterval(intervalID);
|
|
23510
|
+
intervalID = 0;
|
|
23511
|
+
}
|
|
23196
23512
|
speakerTestTone.pause();
|
|
23197
23513
|
parent.closeAudioTrack();
|
|
23198
23514
|
parent.addToTrobuleshootReport("INFO", "Speaker device testing is stopped");
|
|
@@ -23259,10 +23575,10 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23259
23575
|
if (deviceInfos[i].deviceId == "default") {
|
|
23260
23576
|
if (deviceInfos[i].kind == "audiooutput") {
|
|
23261
23577
|
var speakerName = deviceInfos[i].label;
|
|
23262
|
-
|
|
23578
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("speakerInfo", deviceInfos[i].label, "speakerInfo");
|
|
23263
23579
|
} else if (deviceInfos[i].kind == "audioinput") {
|
|
23264
23580
|
var micName = deviceInfos[i].label;
|
|
23265
|
-
|
|
23581
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("micInfo", deviceInfos[i].label, "micInfo");
|
|
23266
23582
|
}
|
|
23267
23583
|
}
|
|
23268
23584
|
}
|
|
@@ -23306,7 +23622,7 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23306
23622
|
}
|
|
23307
23623
|
var average = values / length;
|
|
23308
23624
|
//diagnosticsCallback.triggerDiagnosticsMicStatusCallback(average, "mic ok");
|
|
23309
|
-
|
|
23625
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("mic", average, "mic ok");
|
|
23310
23626
|
if (average > 9) {
|
|
23311
23627
|
//fillMicColors(Math.round(average));
|
|
23312
23628
|
}
|
|
@@ -23315,7 +23631,7 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23315
23631
|
logger.log("Media source not available for mic test ..");
|
|
23316
23632
|
average = 0;
|
|
23317
23633
|
//diagnosticsCallback.triggerDiagnosticsMicStatusCallback(average, "mic error");
|
|
23318
|
-
|
|
23634
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("mic", average, "mic error");
|
|
23319
23635
|
}
|
|
23320
23636
|
},
|
|
23321
23637
|
fillStreamSpeaker: function (stream, outDevice) {
|
|
@@ -23338,21 +23654,20 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23338
23654
|
values += array[i];
|
|
23339
23655
|
}
|
|
23340
23656
|
var average = values / length;
|
|
23341
|
-
|
|
23657
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("speaker", average, "speaker ok");
|
|
23342
23658
|
};
|
|
23343
23659
|
} catch (e) {
|
|
23344
23660
|
logger.log("Media source not available for speaker test ..");
|
|
23345
23661
|
average = 0;
|
|
23346
|
-
|
|
23662
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("speaker", average, "speaker error");
|
|
23347
23663
|
}
|
|
23348
23664
|
},
|
|
23349
23665
|
setUserRegTroubleshootData: function (txtUser) {
|
|
23350
23666
|
logger.log("No explicit registration sent during testing...");
|
|
23351
23667
|
},
|
|
23352
|
-
setWSTroubleshootData: function (txtWsStatus) {
|
|
23353
|
-
|
|
23354
|
-
|
|
23355
|
-
_listeners_Callback__WEBPACK_IMPORTED_MODULE_0__.diagnosticsCallback.triggerKeyValueSetCallback("wss", txtWsStatus, txtWSSUrl);
|
|
23668
|
+
setWSTroubleshootData: function (txtWsStatus, webrtcSIPPhone) {
|
|
23669
|
+
let txtWSSUrl = webrtcSIPPhone && webrtcSIPPhone.getWSSUrl ? webrtcSIPPhone.getWSSUrl() : '';
|
|
23670
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("wss", txtWsStatus, txtWSSUrl);
|
|
23356
23671
|
},
|
|
23357
23672
|
startWSAndUserRegistrationTest: function () {
|
|
23358
23673
|
try {
|
|
@@ -23383,7 +23698,7 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23383
23698
|
},
|
|
23384
23699
|
setTroubleshootCandidateData: function (key, status, value) {
|
|
23385
23700
|
logger.log("Candidate Data \n\t key = " + key + " status = " + status + "\n\tValue = " + value + "\n\n");
|
|
23386
|
-
|
|
23701
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback(key, status, value);
|
|
23387
23702
|
},
|
|
23388
23703
|
startCandidatesForTroubleshoot: function () {
|
|
23389
23704
|
var keys = ["udp", "tcp", "ipv6", "host", "srflx"];
|
|
@@ -23530,6 +23845,7 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23530
23845
|
"use strict";
|
|
23531
23846
|
__webpack_require__.r(__webpack_exports__);
|
|
23532
23847
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23848
|
+
/* harmony export */ DiagnosticsListener: () => (/* binding */ DiagnosticsListener),
|
|
23533
23849
|
/* harmony export */ closeDiagnostics: () => (/* binding */ closeDiagnostics),
|
|
23534
23850
|
/* harmony export */ initDiagnostics: () => (/* binding */ initDiagnostics),
|
|
23535
23851
|
/* harmony export */ startMicDiagnosticsTest: () => (/* binding */ startMicDiagnosticsTest),
|
|
@@ -23539,49 +23855,49 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23539
23855
|
/* harmony export */ stopNetworkDiagnostics: () => (/* binding */ stopNetworkDiagnostics),
|
|
23540
23856
|
/* harmony export */ stopSpeakerDiagnosticsTest: () => (/* binding */ stopSpeakerDiagnosticsTest)
|
|
23541
23857
|
/* harmony export */ });
|
|
23542
|
-
/* harmony import */ var
|
|
23543
|
-
/* harmony import */ var
|
|
23544
|
-
/* harmony import */ var
|
|
23858
|
+
/* harmony import */ var _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @exotel-npm-dev/webrtc-core-sdk */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/index.js");
|
|
23859
|
+
/* harmony import */ var _listeners_Callback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../listeners/Callback */ "./src/listeners/Callback.js");
|
|
23860
|
+
/* harmony import */ var _Diagnostics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Diagnostics */ "./src/api/omAPI/Diagnostics.js");
|
|
23545
23861
|
|
|
23546
23862
|
|
|
23547
23863
|
|
|
23548
|
-
|
|
23864
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.getLogger)();
|
|
23549
23865
|
function initDiagnostics(setDiagnosticsReportCallback, keyValueSetCallback) {
|
|
23550
23866
|
if (!keyValueSetCallback || !setDiagnosticsReportCallback) {
|
|
23551
23867
|
logger.log("Callbacks are not set");
|
|
23552
23868
|
return;
|
|
23553
23869
|
}
|
|
23554
|
-
|
|
23555
|
-
|
|
23556
|
-
let version =
|
|
23557
|
-
|
|
23870
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.setKeyValueCallback(keyValueSetCallback);
|
|
23871
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.setDiagnosticsReportCallback(setDiagnosticsReportCallback);
|
|
23872
|
+
let version = _Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.getBrowserData();
|
|
23873
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.keyValueSetCallback('browserVersion', 'ready', version);
|
|
23558
23874
|
return;
|
|
23559
23875
|
}
|
|
23560
23876
|
function closeDiagnostics() {
|
|
23561
|
-
|
|
23562
|
-
|
|
23877
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.setKeyValueCallback(null);
|
|
23878
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.setDiagnosticsReportCallback(null);
|
|
23563
23879
|
return;
|
|
23564
23880
|
}
|
|
23565
|
-
function startSpeakerDiagnosticsTest() {
|
|
23881
|
+
function startSpeakerDiagnosticsTest(webrtcSIPPhone) {
|
|
23566
23882
|
/**
|
|
23567
23883
|
* When user registers the agent phone for the first time, register your callback onto webrtc client
|
|
23568
23884
|
*/
|
|
23569
23885
|
logger.log("Request to startSpeakerTest:\n");
|
|
23570
|
-
|
|
23886
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.startSpeakerTest(webrtcSIPPhone);
|
|
23571
23887
|
return;
|
|
23572
23888
|
}
|
|
23573
|
-
function stopSpeakerDiagnosticsTest(speakerTestResponse) {
|
|
23889
|
+
function stopSpeakerDiagnosticsTest(speakerTestResponse, webrtcSIPPhone) {
|
|
23574
23890
|
/**
|
|
23575
23891
|
* When user registers the agent phone for the first time, register your callback onto webrtc client
|
|
23576
23892
|
*/
|
|
23577
23893
|
|
|
23578
23894
|
logger.log("Request to stopSpeakerTest - Suuccessful Test:\n");
|
|
23579
23895
|
if (speakerTestResponse == 'yes') {
|
|
23580
|
-
|
|
23896
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopSpeakerTesttoneWithSuccess(webrtcSIPPhone);
|
|
23581
23897
|
} else if (speakerTestResponse == 'no') {
|
|
23582
|
-
|
|
23898
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopSpeakerTesttoneWithFailure(webrtcSIPPhone);
|
|
23583
23899
|
} else {
|
|
23584
|
-
|
|
23900
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopSpeakerTest(webrtcSIPPhone);
|
|
23585
23901
|
}
|
|
23586
23902
|
return;
|
|
23587
23903
|
}
|
|
@@ -23590,7 +23906,7 @@ function startMicDiagnosticsTest() {
|
|
|
23590
23906
|
* When user registers the agent phone for the first time, register your callback onto webrtc client
|
|
23591
23907
|
*/
|
|
23592
23908
|
logger.log("Request to startMicTest:\n");
|
|
23593
|
-
|
|
23909
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.startMicTest();
|
|
23594
23910
|
return;
|
|
23595
23911
|
}
|
|
23596
23912
|
function stopMicDiagnosticsTest(micTestResponse) {
|
|
@@ -23599,11 +23915,11 @@ function stopMicDiagnosticsTest(micTestResponse) {
|
|
|
23599
23915
|
*/
|
|
23600
23916
|
logger.log("Request to stopMicTest - Successful Test:\n");
|
|
23601
23917
|
if (micTestResponse == 'yes') {
|
|
23602
|
-
|
|
23918
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopMicTestSuccess();
|
|
23603
23919
|
} else if (micTestResponse == 'no') {
|
|
23604
|
-
|
|
23920
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopMicTestFailure();
|
|
23605
23921
|
} else {
|
|
23606
|
-
|
|
23922
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopMicTest();
|
|
23607
23923
|
}
|
|
23608
23924
|
return;
|
|
23609
23925
|
}
|
|
@@ -23616,7 +23932,7 @@ function startNetworkDiagnostics() {
|
|
|
23616
23932
|
* When user registers the agent phone for the first time, register your callback onto webrtc client
|
|
23617
23933
|
*/
|
|
23618
23934
|
logger.log("Request to start network diagnostics:\n");
|
|
23619
|
-
|
|
23935
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.startWSAndUserRegistrationTest();
|
|
23620
23936
|
return;
|
|
23621
23937
|
}
|
|
23622
23938
|
|
|
@@ -23630,6 +23946,15 @@ function stopNetworkDiagnostics() {
|
|
|
23630
23946
|
logger.log("Request to stop network diagnostics:\n");
|
|
23631
23947
|
return;
|
|
23632
23948
|
}
|
|
23949
|
+
class DiagnosticsListener {
|
|
23950
|
+
constructor(diagnosticsCallback) {
|
|
23951
|
+
this.diagnosticsCallback = diagnosticsCallback;
|
|
23952
|
+
}
|
|
23953
|
+
onDiagnosticsEvent(event) {
|
|
23954
|
+
logger.log("DiagnosticsListener: onDiagnosticsEvent", event);
|
|
23955
|
+
this.diagnosticsCallback.triggerCallback(event);
|
|
23956
|
+
}
|
|
23957
|
+
}
|
|
23633
23958
|
|
|
23634
23959
|
/***/ }),
|
|
23635
23960
|
|
|
@@ -23647,7 +23972,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23647
23972
|
/* harmony export */ });
|
|
23648
23973
|
/* harmony import */ var _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @exotel-npm-dev/webrtc-core-sdk */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/index.js");
|
|
23649
23974
|
|
|
23650
|
-
|
|
23975
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.getLogger)();
|
|
23651
23976
|
|
|
23652
23977
|
/**
|
|
23653
23978
|
* Function to register the phone onto a webRTC client
|
|
@@ -23682,40 +24007,14 @@ function DoRegister(sipAccountInfo, exWebClient, delay = 500) {
|
|
|
23682
24007
|
/**
|
|
23683
24008
|
* Function to UnRegister the phone from a webRTC client
|
|
23684
24009
|
* @param {*} sipAccountInfo
|
|
23685
|
-
* @param {*} exWebClient
|
|
23686
|
-
*/
|
|
23687
|
-
function UnRegister(sipAccountInfo, exWebClient) {
|
|
23688
|
-
try {
|
|
23689
|
-
exWebClient.unregister(sipAccountInfo);
|
|
23690
|
-
} catch (e) {
|
|
23691
|
-
logger.log("Unregister failed ", e);
|
|
23692
|
-
}
|
|
23693
|
-
}
|
|
23694
|
-
|
|
23695
|
-
/***/ }),
|
|
23696
|
-
|
|
23697
|
-
/***/ "./src/constants/common.js":
|
|
23698
|
-
/*!*********************************!*\
|
|
23699
|
-
!*** ./src/constants/common.js ***!
|
|
23700
|
-
\*********************************/
|
|
23701
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
23702
|
-
|
|
23703
|
-
"use strict";
|
|
23704
|
-
__webpack_require__.r(__webpack_exports__);
|
|
23705
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23706
|
-
/* harmony export */ FetchTabInfo: () => (/* binding */ FetchTabInfo)
|
|
23707
|
-
/* harmony export */ });
|
|
23708
|
-
/**
|
|
23709
|
-
* Function to fetch the tab details from tabID
|
|
24010
|
+
* @param {*} exWebClient
|
|
23710
24011
|
*/
|
|
23711
|
-
function
|
|
23712
|
-
|
|
23713
|
-
|
|
23714
|
-
|
|
23715
|
-
|
|
23716
|
-
}
|
|
24012
|
+
function UnRegister(sipAccountInfo, exWebClient) {
|
|
24013
|
+
try {
|
|
24014
|
+
exWebClient.unregister(sipAccountInfo);
|
|
24015
|
+
} catch (e) {
|
|
24016
|
+
logger.log("Unregister failed ", e);
|
|
23717
24017
|
}
|
|
23718
|
-
return null;
|
|
23719
24018
|
}
|
|
23720
24019
|
|
|
23721
24020
|
/***/ }),
|
|
@@ -23753,43 +24052,34 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23753
24052
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23754
24053
|
/* harmony export */ CallListener: () => (/* binding */ CallListener)
|
|
23755
24054
|
/* harmony export */ });
|
|
23756
|
-
/* harmony import */ var
|
|
23757
|
-
/* harmony import */ var _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @exotel-npm-dev/webrtc-core-sdk */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/index.js");
|
|
23758
|
-
|
|
23759
|
-
|
|
23760
|
-
var logger = _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_1__.webrtcSIPPhone.getLogger();
|
|
23761
|
-
function CallListener() {
|
|
23762
|
-
this.onIncomingCall = function (call, phone) {
|
|
23763
|
-
/**
|
|
23764
|
-
* When there is an incoming call, [INVITE is received on SIP] send a call back to the
|
|
23765
|
-
*/
|
|
23766
|
-
logger.log("CallListener:Initialise call");
|
|
23767
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.callbacks.initializeCall(call, phone);
|
|
24055
|
+
/* harmony import */ var _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @exotel-npm-dev/webrtc-core-sdk */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/index.js");
|
|
23768
24056
|
|
|
23769
|
-
|
|
23770
|
-
|
|
23771
|
-
|
|
23772
|
-
|
|
23773
|
-
|
|
23774
|
-
|
|
23775
|
-
|
|
23776
|
-
|
|
23777
|
-
|
|
23778
|
-
|
|
23779
|
-
|
|
23780
|
-
logger.log("CallListener:
|
|
23781
|
-
|
|
23782
|
-
}
|
|
23783
|
-
|
|
23784
|
-
|
|
23785
|
-
|
|
23786
|
-
|
|
23787
|
-
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
|
|
23791
|
-
|
|
23792
|
-
|
|
24057
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.getLogger)();
|
|
24058
|
+
class CallListener {
|
|
24059
|
+
constructor(callCallback) {
|
|
24060
|
+
this.callCallback = callCallback;
|
|
24061
|
+
}
|
|
24062
|
+
onIncomingCall(call, phone) {
|
|
24063
|
+
logger.log("CallListener: onIncomingCall", call, phone);
|
|
24064
|
+
this.callCallback.initializeCall(call, phone);
|
|
24065
|
+
this.callCallback.triggerCallback("call", call, "incoming", phone);
|
|
24066
|
+
}
|
|
24067
|
+
onCallEstablished(call, phone) {
|
|
24068
|
+
logger.log("CallListener: onCallEstablished", call, phone);
|
|
24069
|
+
this.callCallback.triggerCallback("call", call, "connected", phone);
|
|
24070
|
+
}
|
|
24071
|
+
onCallEnded(call, phone) {
|
|
24072
|
+
logger.log("CallListener: onCallEnded", call, phone);
|
|
24073
|
+
this.callCallback.triggerCallback("call", call, "callEnded", phone);
|
|
24074
|
+
}
|
|
24075
|
+
onCallEvent(event) {
|
|
24076
|
+
logger.log("CallListener: onCallEvent", event);
|
|
24077
|
+
this.callCallback.triggerCallback(event);
|
|
24078
|
+
}
|
|
24079
|
+
onRinging(call, phone) {
|
|
24080
|
+
logger.log("CallListener: onRinging", call, phone);
|
|
24081
|
+
this.callCallback.triggerCallback("call", call, "ringing", phone);
|
|
24082
|
+
}
|
|
23793
24083
|
}
|
|
23794
24084
|
|
|
23795
24085
|
/***/ }),
|
|
@@ -23803,17 +24093,17 @@ function CallListener() {
|
|
|
23803
24093
|
"use strict";
|
|
23804
24094
|
__webpack_require__.r(__webpack_exports__);
|
|
23805
24095
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23806
|
-
/* harmony export */
|
|
24096
|
+
/* harmony export */ Callback: () => (/* binding */ Callback),
|
|
24097
|
+
/* harmony export */ RegisterCallback: () => (/* binding */ RegisterCallback),
|
|
24098
|
+
/* harmony export */ SessionCallback: () => (/* binding */ SessionCallback),
|
|
23807
24099
|
/* harmony export */ diagnosticsCallback: () => (/* binding */ diagnosticsCallback),
|
|
23808
24100
|
/* harmony export */ phoneInstance: () => (/* binding */ phoneInstance),
|
|
23809
|
-
/* harmony export */ registerCallback: () => (/* binding */ registerCallback),
|
|
23810
|
-
/* harmony export */ sessionCallback: () => (/* binding */ sessionCallback),
|
|
23811
24101
|
/* harmony export */ timerSession: () => (/* binding */ timerSession),
|
|
23812
24102
|
/* harmony export */ webrtcTroubleshooterEventBus: () => (/* binding */ webrtcTroubleshooterEventBus)
|
|
23813
24103
|
/* harmony export */ });
|
|
23814
24104
|
/* harmony import */ var _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @exotel-npm-dev/webrtc-core-sdk */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/index.js");
|
|
23815
24105
|
|
|
23816
|
-
|
|
24106
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.getLogger)();
|
|
23817
24107
|
|
|
23818
24108
|
/**
|
|
23819
24109
|
* The call backs are called through this function. First initiates the call object and then
|
|
@@ -23823,43 +24113,49 @@ var logger = _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.webrtc
|
|
|
23823
24113
|
/**
|
|
23824
24114
|
* Initializes call event callbacks and also sends to which phone callback was received
|
|
23825
24115
|
*/
|
|
23826
|
-
|
|
23827
|
-
|
|
23828
|
-
|
|
23829
|
-
|
|
23830
|
-
|
|
23831
|
-
|
|
23832
|
-
|
|
23833
|
-
|
|
24116
|
+
class Callback {
|
|
24117
|
+
constructor() {
|
|
24118
|
+
this.callbacks = {};
|
|
24119
|
+
this.call = null;
|
|
24120
|
+
this.phone = '';
|
|
24121
|
+
}
|
|
24122
|
+
registerCallback(event, callback) {
|
|
24123
|
+
this.callbacks[event] = callback;
|
|
24124
|
+
}
|
|
24125
|
+
initializeCall(call, phone) {
|
|
23834
24126
|
this.call = call;
|
|
23835
24127
|
this.phone = phone;
|
|
23836
|
-
},
|
|
23837
|
-
triggerCallback: function (eventType) {
|
|
23838
|
-
const callbackFunc = this.callback;
|
|
23839
|
-
const call = this.call;
|
|
23840
|
-
return callbackFunc(call, eventType, this.phone);
|
|
23841
24128
|
}
|
|
23842
|
-
|
|
24129
|
+
triggerCallback(event, ...args) {
|
|
24130
|
+
if (this.callbacks[event]) {
|
|
24131
|
+
this.callbacks[event](...args);
|
|
24132
|
+
} else {
|
|
24133
|
+
logger.log("No callback registered for event:", event);
|
|
24134
|
+
}
|
|
24135
|
+
}
|
|
24136
|
+
}
|
|
24137
|
+
|
|
23843
24138
|
/**
|
|
23844
24139
|
* Initializes register callback and also sets to which phone registration was renewed
|
|
23845
24140
|
*/
|
|
23846
|
-
|
|
23847
|
-
|
|
23848
|
-
|
|
23849
|
-
|
|
23850
|
-
|
|
23851
|
-
|
|
23852
|
-
|
|
23853
|
-
|
|
23854
|
-
|
|
23855
|
-
|
|
23856
|
-
|
|
23857
|
-
|
|
23858
|
-
|
|
23859
|
-
const
|
|
23860
|
-
|
|
23861
|
-
|
|
23862
|
-
};
|
|
24141
|
+
|
|
24142
|
+
class RegisterCallback {
|
|
24143
|
+
registerCallbackHandler = null;
|
|
24144
|
+
registerState = null;
|
|
24145
|
+
phone = '';
|
|
24146
|
+
initializeRegisterCallback = function (RegisterEventCallBack) {
|
|
24147
|
+
this.registerCallbackHandler = RegisterEventCallBack;
|
|
24148
|
+
};
|
|
24149
|
+
initializeRegister = function (state, phone) {
|
|
24150
|
+
this.registerState = state;
|
|
24151
|
+
this.phone = phone;
|
|
24152
|
+
};
|
|
24153
|
+
triggerRegisterCallback = function () {
|
|
24154
|
+
const callbackFunc = this.registerCallbackHandler;
|
|
24155
|
+
const state = this.registerState;
|
|
24156
|
+
return callbackFunc(state, this.phone);
|
|
24157
|
+
};
|
|
24158
|
+
}
|
|
23863
24159
|
/**
|
|
23864
24160
|
* Sets all the phone instances
|
|
23865
24161
|
*/
|
|
@@ -23892,30 +24188,30 @@ var phoneInstance = {
|
|
|
23892
24188
|
}
|
|
23893
24189
|
}
|
|
23894
24190
|
};
|
|
23895
|
-
|
|
23896
|
-
sessioncallback
|
|
23897
|
-
callState
|
|
23898
|
-
document
|
|
23899
|
-
documentCallback
|
|
23900
|
-
phone
|
|
23901
|
-
initializeSessionCallback
|
|
24191
|
+
class SessionCallback {
|
|
24192
|
+
sessioncallback = null;
|
|
24193
|
+
callState = null;
|
|
24194
|
+
document = null;
|
|
24195
|
+
documentCallback = null;
|
|
24196
|
+
phone = '';
|
|
24197
|
+
initializeSessionCallback = function (SessionCallback) {
|
|
23902
24198
|
this.sessioncallback = SessionCallback;
|
|
23903
|
-
}
|
|
23904
|
-
intializeDocumentCallback
|
|
24199
|
+
};
|
|
24200
|
+
intializeDocumentCallback = function (DocumentCallback) {
|
|
23905
24201
|
this.documentCallback = DocumentCallback;
|
|
23906
|
-
}
|
|
23907
|
-
initializeSession
|
|
24202
|
+
};
|
|
24203
|
+
initializeSession = function (state, phone) {
|
|
23908
24204
|
this.callState = state;
|
|
23909
24205
|
this.phone = phone;
|
|
23910
|
-
}
|
|
23911
|
-
initializeDocument
|
|
24206
|
+
};
|
|
24207
|
+
initializeDocument = function (calldocument) {
|
|
23912
24208
|
this.document = calldocument;
|
|
23913
|
-
}
|
|
23914
|
-
triggerDocumentCallback
|
|
24209
|
+
};
|
|
24210
|
+
triggerDocumentCallback = function () {
|
|
23915
24211
|
const documentCallbackFunc = this.documentCallback;
|
|
23916
24212
|
return documentCallbackFunc(this.document);
|
|
23917
|
-
}
|
|
23918
|
-
triggerSessionCallback
|
|
24213
|
+
};
|
|
24214
|
+
triggerSessionCallback = function () {
|
|
23919
24215
|
const sessionCallBackFunc = this.sessioncallback;
|
|
23920
24216
|
if (sessionCallBackFunc) {
|
|
23921
24217
|
return sessionCallBackFunc(this.callState, this.phone);
|
|
@@ -23923,8 +24219,8 @@ var sessionCallback = {
|
|
|
23923
24219
|
logger.log("Session callback is null");
|
|
23924
24220
|
return;
|
|
23925
24221
|
}
|
|
23926
|
-
}
|
|
23927
|
-
}
|
|
24222
|
+
};
|
|
24223
|
+
}
|
|
23928
24224
|
var diagnosticsCallback = {
|
|
23929
24225
|
saveDiagnosticsCallback: null,
|
|
23930
24226
|
keyValueSetCallback: null,
|
|
@@ -24050,9 +24346,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
24050
24346
|
|
|
24051
24347
|
|
|
24052
24348
|
|
|
24349
|
+
const phonePool = new Map();
|
|
24053
24350
|
var intervalId;
|
|
24054
24351
|
var intervalIDMap = new Map();
|
|
24055
|
-
|
|
24352
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.getLogger)();
|
|
24056
24353
|
function sleep(ms) {
|
|
24057
24354
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
24058
24355
|
}
|
|
@@ -24061,113 +24358,117 @@ function sleep(ms) {
|
|
|
24061
24358
|
* FQDN for fetching IP
|
|
24062
24359
|
*/
|
|
24063
24360
|
function fetchPublicIP(sipAccountInfo) {
|
|
24064
|
-
|
|
24065
|
-
|
|
24066
|
-
|
|
24067
|
-
|
|
24068
|
-
|
|
24069
|
-
|
|
24070
|
-
|
|
24071
|
-
|
|
24072
|
-
|
|
24073
|
-
|
|
24074
|
-
|
|
24075
|
-
|
|
24076
|
-
|
|
24077
|
-
|
|
24078
|
-
|
|
24079
|
-
|
|
24080
|
-
|
|
24081
|
-
|
|
24082
|
-
|
|
24083
|
-
|
|
24084
|
-
|
|
24085
|
-
|
|
24086
|
-
|
|
24087
|
-
|
|
24088
|
-
|
|
24089
|
-
|
|
24090
|
-
|
|
24091
|
-
|
|
24092
|
-
|
|
24093
|
-
|
|
24094
|
-
|
|
24095
|
-
|
|
24096
|
-
|
|
24361
|
+
return new Promise(resolve => {
|
|
24362
|
+
var publicIp = "";
|
|
24363
|
+
const pc = new RTCPeerConnection({
|
|
24364
|
+
iceServers: [{
|
|
24365
|
+
urls: 'stun:stun.l.google.com:19302'
|
|
24366
|
+
}]
|
|
24367
|
+
});
|
|
24368
|
+
pc.createDataChannel('');
|
|
24369
|
+
pc.createOffer().then(offer => pc.setLocalDescription(offer));
|
|
24370
|
+
pc.onicecandidate = ice => {
|
|
24371
|
+
if (!ice || !ice.candidate || !ice.candidate.candidate) {
|
|
24372
|
+
pc.close();
|
|
24373
|
+
resolve();
|
|
24374
|
+
return;
|
|
24375
|
+
}
|
|
24376
|
+
logger.log("iceCandidate =" + ice.candidate.candidate);
|
|
24377
|
+
let split = ice.candidate.candidate.split(" ");
|
|
24378
|
+
if (split[7] === "host") {
|
|
24379
|
+
logger.log(`fetchPublicIP:Local IP : ${split[4]}`);
|
|
24380
|
+
} else {
|
|
24381
|
+
logger.log(`fetchPublicIP:External IP : ${split[4]}`);
|
|
24382
|
+
publicIp = `${split[4]}`;
|
|
24383
|
+
logger.log("fetchPublicIP:Public IP :" + publicIp);
|
|
24384
|
+
localStorage.setItem("contactHost", publicIp);
|
|
24385
|
+
pc.close();
|
|
24386
|
+
resolve();
|
|
24387
|
+
}
|
|
24388
|
+
};
|
|
24389
|
+
setTimeout(() => {
|
|
24390
|
+
logger.log("fetchPublicIP: public ip = ", publicIp);
|
|
24391
|
+
if (publicIp == "") {
|
|
24392
|
+
sipAccountInfo.contactHost = window.localStorage.getItem('contactHost');
|
|
24393
|
+
} else {
|
|
24394
|
+
sipAccountInfo.contactHost = publicIp;
|
|
24395
|
+
}
|
|
24396
|
+
resolve();
|
|
24397
|
+
}, 1000);
|
|
24097
24398
|
});
|
|
24098
|
-
return;
|
|
24099
24399
|
}
|
|
24100
|
-
|
|
24101
|
-
|
|
24102
|
-
|
|
24103
|
-
|
|
24400
|
+
class ExDelegationHandler {
|
|
24401
|
+
constructor(exClient) {
|
|
24402
|
+
this.exClient = exClient;
|
|
24403
|
+
}
|
|
24404
|
+
setTestingMode(mode) {
|
|
24104
24405
|
logger.log("delegationHandler: setTestingMode\n");
|
|
24105
|
-
}
|
|
24106
|
-
|
|
24406
|
+
}
|
|
24407
|
+
onCallStatSipJsSessionEvent(ev) {
|
|
24107
24408
|
logger.log("delegationHandler: onCallStatSipJsSessionEvent", ev);
|
|
24108
|
-
}
|
|
24109
|
-
|
|
24409
|
+
}
|
|
24410
|
+
sendWebRTCEventsToFSM(eventType, sipMethod) {
|
|
24110
24411
|
logger.log("delegationHandler: sendWebRTCEventsToFSM\n");
|
|
24111
24412
|
logger.log("delegationHandler: eventType\n", eventType);
|
|
24112
24413
|
logger.log("delegationHandler: sipMethod\n", sipMethod);
|
|
24113
24414
|
if (sipMethod == "CONNECTION") {
|
|
24114
|
-
exClient.registerEventCallback(eventType, exClient.userName);
|
|
24415
|
+
this.exClient.registerEventCallback(eventType, this.exClient.userName);
|
|
24115
24416
|
} else if (sipMethod == "CALL") {
|
|
24116
|
-
exClient.callEventCallback(eventType, exClient.callFromNumber, exClient.call);
|
|
24417
|
+
this.exClient.callEventCallback(eventType, this.exClient.callFromNumber, this.exClient.call);
|
|
24117
24418
|
}
|
|
24118
|
-
}
|
|
24119
|
-
|
|
24419
|
+
}
|
|
24420
|
+
playBeepTone() {
|
|
24120
24421
|
logger.log("delegationHandler: playBeepTone\n");
|
|
24121
|
-
}
|
|
24122
|
-
|
|
24422
|
+
}
|
|
24423
|
+
onStatPeerConnectionIceGatheringStateChange(iceGatheringState) {
|
|
24123
24424
|
logger.log("delegationHandler: onStatPeerConnectionIceGatheringStateChange\n");
|
|
24124
|
-
}
|
|
24125
|
-
|
|
24425
|
+
}
|
|
24426
|
+
onCallStatIceCandidate(ev, icestate) {
|
|
24126
24427
|
logger.log("delegationHandler: onCallStatIceCandidate\n");
|
|
24127
|
-
}
|
|
24128
|
-
|
|
24428
|
+
}
|
|
24429
|
+
onCallStatNegoNeeded(icestate) {
|
|
24129
24430
|
logger.log("delegationHandler: onCallStatNegoNeeded\n");
|
|
24130
|
-
}
|
|
24131
|
-
|
|
24431
|
+
}
|
|
24432
|
+
onCallStatSignalingStateChange(cstate) {
|
|
24132
24433
|
logger.log("delegationHandler: onCallStatSignalingStateChange\n");
|
|
24133
|
-
}
|
|
24134
|
-
|
|
24434
|
+
}
|
|
24435
|
+
onStatPeerConnectionIceConnectionStateChange() {
|
|
24135
24436
|
logger.log("delegationHandler: onStatPeerConnectionIceConnectionStateChange\n");
|
|
24136
|
-
}
|
|
24137
|
-
|
|
24437
|
+
}
|
|
24438
|
+
onStatPeerConnectionConnectionStateChange() {
|
|
24138
24439
|
logger.log("delegationHandler: onStatPeerConnectionConnectionStateChange\n");
|
|
24139
|
-
}
|
|
24140
|
-
|
|
24440
|
+
}
|
|
24441
|
+
onGetUserMediaSuccessCallstatCallback() {
|
|
24141
24442
|
logger.log("delegationHandler: onGetUserMediaSuccessCallstatCallback\n");
|
|
24142
|
-
}
|
|
24143
|
-
|
|
24443
|
+
}
|
|
24444
|
+
onGetUserMediaErrorCallstatCallback() {
|
|
24144
24445
|
logger.log("delegationHandler: onGetUserMediaErrorCallstatCallback\n");
|
|
24145
|
-
}
|
|
24146
|
-
|
|
24446
|
+
}
|
|
24447
|
+
onCallStatAddStream() {
|
|
24147
24448
|
logger.log("delegationHandler: onCallStatAddStream\n");
|
|
24148
|
-
}
|
|
24149
|
-
|
|
24449
|
+
}
|
|
24450
|
+
onCallStatRemoveStream() {
|
|
24150
24451
|
logger.log("delegationHandler: onCallStatRemoveStream\n");
|
|
24151
|
-
}
|
|
24152
|
-
|
|
24452
|
+
}
|
|
24453
|
+
setWebRTCFSMMapper(stack) {
|
|
24153
24454
|
logger.log("delegationHandler: setWebRTCFSMMapper : Initialisation complete \n");
|
|
24154
|
-
}
|
|
24155
|
-
|
|
24455
|
+
}
|
|
24456
|
+
onCallStatSipJsTransportEvent() {
|
|
24156
24457
|
logger.log("delegationHandler: onCallStatSipJsTransportEvent\n");
|
|
24157
|
-
}
|
|
24158
|
-
|
|
24458
|
+
}
|
|
24459
|
+
onCallStatSipSendCallback() {
|
|
24159
24460
|
logger.log("delegationHandler: onCallStatSipSendCallback\n");
|
|
24160
|
-
}
|
|
24161
|
-
|
|
24461
|
+
}
|
|
24462
|
+
onCallStatSipRecvCallback() {
|
|
24162
24463
|
logger.log("delegationHandler: onCallStatSipRecvCallback\n");
|
|
24163
|
-
}
|
|
24164
|
-
|
|
24464
|
+
}
|
|
24465
|
+
stopCallStat() {
|
|
24165
24466
|
logger.log("delegationHandler: stopCallStat\n");
|
|
24166
|
-
}
|
|
24167
|
-
|
|
24467
|
+
}
|
|
24468
|
+
onRecieveInvite(incomingSession) {
|
|
24168
24469
|
logger.log("delegationHandler: onRecieveInvite\n");
|
|
24169
24470
|
const obj = incomingSession.incomingInviteRequest.message.headers;
|
|
24170
|
-
exClient.callFromNumber = incomingSession.incomingInviteRequest.message.from.displayName;
|
|
24471
|
+
this.exClient.callFromNumber = incomingSession.incomingInviteRequest.message.from.displayName;
|
|
24171
24472
|
if (obj.hasOwnProperty("X-Exotel-Callsid")) {
|
|
24172
24473
|
_api_callAPI_CallDetails__WEBPACK_IMPORTED_MODULE_9__.CallDetails.callSid = obj['X-Exotel-Callsid'][0].raw;
|
|
24173
24474
|
}
|
|
@@ -24188,35 +24489,40 @@ function ExDelegationHandler(exClient_) {
|
|
|
24188
24489
|
}
|
|
24189
24490
|
}
|
|
24190
24491
|
_api_callAPI_CallDetails__WEBPACK_IMPORTED_MODULE_9__.CallDetails.sipHeaders = result;
|
|
24191
|
-
}
|
|
24192
|
-
|
|
24492
|
+
}
|
|
24493
|
+
onPickCall() {
|
|
24193
24494
|
logger.log("delegationHandler: onPickCall\n");
|
|
24194
|
-
}
|
|
24195
|
-
|
|
24495
|
+
}
|
|
24496
|
+
onRejectCall() {
|
|
24196
24497
|
logger.log("delegationHandler: onRejectCall\n");
|
|
24197
|
-
}
|
|
24198
|
-
|
|
24498
|
+
}
|
|
24499
|
+
onCreaterAnswer() {
|
|
24199
24500
|
logger.log("delegationHandler: onCreaterAnswer\n");
|
|
24200
|
-
}
|
|
24201
|
-
|
|
24501
|
+
}
|
|
24502
|
+
onSettingLocalDesc() {
|
|
24202
24503
|
logger.log("delegationHandler: onSettingLocalDesc\n");
|
|
24203
|
-
}
|
|
24204
|
-
|
|
24504
|
+
}
|
|
24505
|
+
initGetStats(pc, callid, username) {
|
|
24205
24506
|
logger.log("delegationHandler: initGetStats\n");
|
|
24206
|
-
}
|
|
24207
|
-
|
|
24507
|
+
}
|
|
24508
|
+
onRegisterWebRTCSIPEngine(engine) {
|
|
24208
24509
|
logger.log("delegationHandler: onRegisterWebRTCSIPEngine, engine=\n", engine);
|
|
24209
|
-
}
|
|
24510
|
+
}
|
|
24210
24511
|
}
|
|
24211
|
-
|
|
24212
|
-
|
|
24512
|
+
class ExSynchronousHandler {
|
|
24513
|
+
onFailure() {
|
|
24213
24514
|
logger.log("synchronousHandler: onFailure, phone is offline.\n");
|
|
24214
|
-
}
|
|
24215
|
-
|
|
24515
|
+
}
|
|
24516
|
+
onResponse() {
|
|
24216
24517
|
logger.log("synchronousHandler: onResponse, phone is connected.\n");
|
|
24217
|
-
}
|
|
24518
|
+
}
|
|
24218
24519
|
}
|
|
24520
|
+
|
|
24219
24521
|
class ExotelWebClient {
|
|
24522
|
+
/**
|
|
24523
|
+
* @param {Object} sipAccntInfo
|
|
24524
|
+
*/
|
|
24525
|
+
|
|
24220
24526
|
ctrlr = null;
|
|
24221
24527
|
call;
|
|
24222
24528
|
eventListener = null;
|
|
@@ -24226,44 +24532,100 @@ class ExotelWebClient {
|
|
|
24226
24532
|
unregisterInitiated = false;
|
|
24227
24533
|
registrationInProgress = false;
|
|
24228
24534
|
isReadyToRegister = true;
|
|
24229
|
-
/* OLD-Way to be revisited for multile phone support */
|
|
24230
|
-
//this.webRTCPhones = {};
|
|
24231
|
-
|
|
24232
24535
|
sipAccountInfo = null;
|
|
24233
24536
|
clientSDKLoggerCallback = null;
|
|
24537
|
+
callbacks = null;
|
|
24538
|
+
registerCallback = null;
|
|
24539
|
+
sessionCallback = null;
|
|
24540
|
+
logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.getLogger)();
|
|
24234
24541
|
constructor() {
|
|
24235
|
-
|
|
24236
|
-
|
|
24237
|
-
|
|
24238
|
-
|
|
24542
|
+
// Initialize properties
|
|
24543
|
+
this.ctrlr = null;
|
|
24544
|
+
this.call = null;
|
|
24545
|
+
this.eventListener = null;
|
|
24546
|
+
this.callListener = null;
|
|
24547
|
+
this.callFromNumber = null;
|
|
24548
|
+
this.shouldAutoRetry = false;
|
|
24549
|
+
this.unregisterInitiated = false;
|
|
24550
|
+
this.registrationInProgress = false;
|
|
24551
|
+
this.currentSIPUserName = "";
|
|
24552
|
+
this.isReadyToRegister = true;
|
|
24553
|
+
this.sipAccountInfo = null;
|
|
24554
|
+
this.clientSDKLoggerCallback = null;
|
|
24555
|
+
this.callbacks = new _listeners_Callback__WEBPACK_IMPORTED_MODULE_7__.Callback();
|
|
24556
|
+
this.registerCallback = new _listeners_Callback__WEBPACK_IMPORTED_MODULE_7__.RegisterCallback();
|
|
24557
|
+
this.sessionCallback = new _listeners_Callback__WEBPACK_IMPORTED_MODULE_7__.SessionCallback();
|
|
24558
|
+
this.logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.getLogger)();
|
|
24559
|
+
|
|
24560
|
+
// Register logger callback
|
|
24561
|
+
this.logger.registerLoggerCallback((type, message, args) => {
|
|
24239
24562
|
_api_LogManager_js__WEBPACK_IMPORTED_MODULE_10__["default"].onLog(type, message, args);
|
|
24240
|
-
if (this.clientSDKLoggerCallback)
|
|
24563
|
+
if (this.clientSDKLoggerCallback) {
|
|
24564
|
+
this.clientSDKLoggerCallback("log", message, args);
|
|
24565
|
+
}
|
|
24241
24566
|
});
|
|
24242
24567
|
}
|
|
24243
|
-
initWebrtc = (sipAccountInfo_, RegisterEventCallBack, CallListenerCallback, SessionCallback) => {
|
|
24568
|
+
initWebrtc = async (sipAccountInfo_, RegisterEventCallBack, CallListenerCallback, SessionCallback) => {
|
|
24569
|
+
const userName = sipAccountInfo_?.userName;
|
|
24570
|
+
if (!userName) return false;
|
|
24571
|
+
|
|
24572
|
+
// --- Duplicate registration guard ---
|
|
24573
|
+
if (phonePool.has(userName)) {
|
|
24574
|
+
if (this.currentSIPUserName == "" || this.currentSIPUserName !== userName) {
|
|
24575
|
+
logger.warn(`ExWebClient: initWebrtc: [Dup‑Reg] ${userName} already in use – init rejected`);
|
|
24576
|
+
return false;
|
|
24577
|
+
}
|
|
24578
|
+
}
|
|
24579
|
+
this.currentSIPUserName = userName;
|
|
24580
|
+
phonePool.set(userName, null);
|
|
24244
24581
|
if (!this.eventListener) {
|
|
24245
|
-
this.eventListener = new _listeners_ExotelVoiceClientListener__WEBPACK_IMPORTED_MODULE_3__.ExotelVoiceClientListener();
|
|
24582
|
+
this.eventListener = new _listeners_ExotelVoiceClientListener__WEBPACK_IMPORTED_MODULE_3__.ExotelVoiceClientListener(this.registerCallback);
|
|
24246
24583
|
}
|
|
24247
24584
|
if (!this.callListener) {
|
|
24248
|
-
this.callListener = new _listeners_CallListener__WEBPACK_IMPORTED_MODULE_2__.CallListener();
|
|
24585
|
+
this.callListener = new _listeners_CallListener__WEBPACK_IMPORTED_MODULE_2__.CallListener(this.callbacks);
|
|
24586
|
+
}
|
|
24587
|
+
if (!this.sessionListener) {
|
|
24588
|
+
this.sessionListener = new _listeners_SessionListeners__WEBPACK_IMPORTED_MODULE_4__.SessionListener(this.sessionCallback);
|
|
24249
24589
|
}
|
|
24250
24590
|
if (!this.ctrlr) {
|
|
24251
24591
|
this.ctrlr = new _CallCtrlerDummy__WEBPACK_IMPORTED_MODULE_5__.CallController();
|
|
24252
24592
|
}
|
|
24253
|
-
if (!this.call) {
|
|
24254
|
-
this.call = new _api_callAPI_Call__WEBPACK_IMPORTED_MODULE_0__.Call();
|
|
24255
|
-
}
|
|
24256
24593
|
logger.log("ExWebClient: initWebrtc: Exotel Client Initialised with " + JSON.stringify(sipAccountInfo_));
|
|
24257
24594
|
this.sipAccountInfo = sipAccountInfo_;
|
|
24258
24595
|
if (!this.sipAccountInfo["userName"] || !this.sipAccountInfo["sipdomain"] || !this.sipAccountInfo["port"]) {
|
|
24259
24596
|
return false;
|
|
24260
24597
|
}
|
|
24261
24598
|
this.sipAccountInfo["sipUri"] = "wss://" + this.sipAccountInfo["userName"] + "@" + this.sipAccountInfo["sipdomain"] + ":" + this.sipAccountInfo["port"];
|
|
24262
|
-
|
|
24263
|
-
|
|
24599
|
+
|
|
24600
|
+
// Register callbacks using the correct methods
|
|
24601
|
+
this.callbacks.registerCallback('call', CallListenerCallback);
|
|
24602
|
+
this.registerCallback.initializeRegisterCallback(RegisterEventCallBack);
|
|
24264
24603
|
logger.log("ExWebClient: initWebrtc: Initializing session callback");
|
|
24265
|
-
|
|
24604
|
+
this.sessionCallback.initializeSessionCallback(SessionCallback);
|
|
24266
24605
|
this.setEventListener(this.eventListener);
|
|
24606
|
+
|
|
24607
|
+
// Wait for public IP before registering
|
|
24608
|
+
await fetchPublicIP(this.sipAccountInfo);
|
|
24609
|
+
|
|
24610
|
+
// Create phone instance if it wasn't created in constructor
|
|
24611
|
+
if (!this.phone) {
|
|
24612
|
+
this.userName = this.sipAccountInfo.userName;
|
|
24613
|
+
let phone = phonePool.get(this.userName);
|
|
24614
|
+
if (!phone) {
|
|
24615
|
+
phone = new _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.WebrtcSIPPhone(this.userName);
|
|
24616
|
+
phonePool.set(this.userName, phone);
|
|
24617
|
+
}
|
|
24618
|
+
this.phone = phone;
|
|
24619
|
+
this.webrtcSIPPhone = this.phone;
|
|
24620
|
+
}
|
|
24621
|
+
|
|
24622
|
+
// Initialize the phone with SIP engine
|
|
24623
|
+
this.webrtcSIPPhone.registerPhone("sipjs", new ExDelegationHandler(this));
|
|
24624
|
+
|
|
24625
|
+
// Create call instance after phone is initialized
|
|
24626
|
+
if (!this.call) {
|
|
24627
|
+
this.call = new _api_callAPI_Call__WEBPACK_IMPORTED_MODULE_0__.Call(this.webrtcSIPPhone);
|
|
24628
|
+
}
|
|
24267
24629
|
return true;
|
|
24268
24630
|
};
|
|
24269
24631
|
DoRegister = () => {
|
|
@@ -24286,10 +24648,10 @@ class ExotelWebClient {
|
|
|
24286
24648
|
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.closeDiagnostics)();
|
|
24287
24649
|
};
|
|
24288
24650
|
startSpeakerDiagnosticsTest = () => {
|
|
24289
|
-
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.startSpeakerDiagnosticsTest)();
|
|
24651
|
+
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.startSpeakerDiagnosticsTest)(this.webrtcSIPPhone);
|
|
24290
24652
|
};
|
|
24291
24653
|
stopSpeakerDiagnosticsTest = (speakerTestResponse = 'none') => {
|
|
24292
|
-
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.stopSpeakerDiagnosticsTest)(speakerTestResponse);
|
|
24654
|
+
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.stopSpeakerDiagnosticsTest)(speakerTestResponse, this.webrtcSIPPhone);
|
|
24293
24655
|
};
|
|
24294
24656
|
startMicDiagnosticsTest = () => {
|
|
24295
24657
|
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.startMicDiagnosticsTest)();
|
|
@@ -24304,27 +24666,16 @@ class ExotelWebClient {
|
|
|
24304
24666
|
stopNetworkDiagnostics = () => {
|
|
24305
24667
|
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.stopNetworkDiagnostics)();
|
|
24306
24668
|
};
|
|
24307
|
-
|
|
24308
|
-
(0,_listeners_SessionListeners__WEBPACK_IMPORTED_MODULE_4__.SessionListener)();
|
|
24309
|
-
};
|
|
24310
|
-
|
|
24311
|
-
/**
|
|
24312
|
-
* function that returns the instance of the call controller object object
|
|
24313
|
-
*/
|
|
24314
|
-
|
|
24669
|
+
SessionListenerMethod = () => {};
|
|
24315
24670
|
getCallController = () => {
|
|
24316
24671
|
return this.ctrlr;
|
|
24317
24672
|
};
|
|
24318
24673
|
getCall = () => {
|
|
24319
24674
|
if (!this.call) {
|
|
24320
|
-
this.call =
|
|
24675
|
+
this.call = new _api_callAPI_Call__WEBPACK_IMPORTED_MODULE_0__.Call(this.webrtcSIPPhone);
|
|
24321
24676
|
}
|
|
24322
24677
|
return this.call;
|
|
24323
24678
|
};
|
|
24324
|
-
|
|
24325
|
-
/**
|
|
24326
|
-
* Dummy function to set the event listener object
|
|
24327
|
-
*/
|
|
24328
24679
|
setEventListener = eventListener => {
|
|
24329
24680
|
this.eventListener = eventListener;
|
|
24330
24681
|
};
|
|
@@ -24337,37 +24688,18 @@ class ExotelWebClient {
|
|
|
24337
24688
|
*/
|
|
24338
24689
|
|
|
24339
24690
|
registerEventCallback = (event, phone, param) => {
|
|
24340
|
-
logger.log("ExWebClient: registerEventCallback: Received ---> " + event
|
|
24341
|
-
|
|
24342
|
-
|
|
24343
|
-
* When registration is successful then send the phone number of the same to UI
|
|
24344
|
-
*/
|
|
24345
|
-
this.eventListener.onInitializationSuccess(phone);
|
|
24691
|
+
logger.log("ExWebClient: registerEventCallback: Received ---> " + event, [phone, param]);
|
|
24692
|
+
const lowerCaseEvent = event.toLowerCase();
|
|
24693
|
+
if (lowerCaseEvent === "registered") {
|
|
24346
24694
|
this.registrationInProgress = false;
|
|
24347
|
-
|
|
24348
|
-
|
|
24349
|
-
|
|
24350
|
-
|
|
24351
|
-
|
|
24352
|
-
|
|
24353
|
-
|
|
24354
|
-
|
|
24355
|
-
*/
|
|
24356
|
-
this.eventListener.onInitializationFailure(phone);
|
|
24357
|
-
if (this.unregisterInitiated) {
|
|
24358
|
-
this.shouldAutoRetry = false;
|
|
24359
|
-
this.unregisterInitiated = false;
|
|
24360
|
-
this.isReadyToRegister = true;
|
|
24361
|
-
}
|
|
24362
|
-
if (this.shouldAutoRetry) {
|
|
24363
|
-
logger.log("ExWebClient: registerEventCallback: Autoretrying");
|
|
24364
|
-
(0,_api_registerAPI_RegisterListener__WEBPACK_IMPORTED_MODULE_1__.DoRegister)(this.sipAccountInfo, this, 5000);
|
|
24365
|
-
}
|
|
24366
|
-
} else if (event === "sent_request") {
|
|
24367
|
-
/**
|
|
24368
|
-
* If registration request waiting...
|
|
24369
|
-
*/
|
|
24370
|
-
this.eventListener.onInitializationWaiting(phone);
|
|
24695
|
+
this.unregisterInitiated = false;
|
|
24696
|
+
this.isReadyToRegister = false;
|
|
24697
|
+
this.eventListener.onRegistrationStateChanged("registered", phone);
|
|
24698
|
+
} else if (lowerCaseEvent === "unregistered" || lowerCaseEvent === "terminated") {
|
|
24699
|
+
this.registrationInProgress = false;
|
|
24700
|
+
this.unregisterInitiated = false;
|
|
24701
|
+
this.isReadyToRegister = true;
|
|
24702
|
+
this.eventListener.onRegistrationStateChanged("unregistered", phone);
|
|
24371
24703
|
}
|
|
24372
24704
|
};
|
|
24373
24705
|
/**
|
|
@@ -24379,7 +24711,13 @@ class ExotelWebClient {
|
|
|
24379
24711
|
callEventCallback = (event, phone, param) => {
|
|
24380
24712
|
logger.log("ExWebClient: callEventCallback: Received ---> " + event + 'param sent....' + param + 'for phone....' + phone);
|
|
24381
24713
|
if (event === "i_new_call") {
|
|
24714
|
+
if (!this.call) {
|
|
24715
|
+
this.call = new _api_callAPI_Call__WEBPACK_IMPORTED_MODULE_0__.Call(param); // param is the session
|
|
24716
|
+
}
|
|
24717
|
+
|
|
24382
24718
|
this.callListener.onIncomingCall(param, phone);
|
|
24719
|
+
} else if (event === "ringing" || event === "accept_reject") {
|
|
24720
|
+
this.callListener.onRinging(param, phone);
|
|
24383
24721
|
} else if (event === "connected") {
|
|
24384
24722
|
this.callListener.onCallEstablished(param, phone);
|
|
24385
24723
|
} else if (event === "terminated") {
|
|
@@ -24406,18 +24744,18 @@ class ExotelWebClient {
|
|
|
24406
24744
|
this.shouldAutoRetry = false;
|
|
24407
24745
|
this.unregisterInitiated = true;
|
|
24408
24746
|
if (!this.registrationInProgress) {
|
|
24409
|
-
setTimeout(
|
|
24410
|
-
|
|
24747
|
+
setTimeout(() => {
|
|
24748
|
+
const phone = phonePool[this.userName] || this.webrtcSIPPhone;
|
|
24749
|
+
if (phone) {
|
|
24750
|
+
phone.sipUnRegisterWebRTC();
|
|
24751
|
+
phone.disconnect?.();
|
|
24752
|
+
}
|
|
24411
24753
|
}, 500);
|
|
24412
24754
|
}
|
|
24413
24755
|
};
|
|
24414
24756
|
webRTCStatusCallbackHandler = (msg1, arg1) => {
|
|
24415
24757
|
logger.log("ExWebClient: webRTCStatusCallbackHandler: " + msg1 + " " + arg1);
|
|
24416
24758
|
};
|
|
24417
|
-
|
|
24418
|
-
/**
|
|
24419
|
-
* initialize function called when user wants to register client
|
|
24420
|
-
*/
|
|
24421
24759
|
initialize = (uiContext, hostName, subscriberName, displayName, accountSid, subscriberToken, sipAccountInfo) => {
|
|
24422
24760
|
let wssPort = sipAccountInfo.port;
|
|
24423
24761
|
let wsPort = 4442;
|
|
@@ -24440,8 +24778,6 @@ class ExotelWebClient {
|
|
|
24440
24778
|
};
|
|
24441
24779
|
logger.log('ExWebClient: initialize: Sending register for the number..', subscriberName);
|
|
24442
24780
|
fetchPublicIP(sipAccountInfo);
|
|
24443
|
-
|
|
24444
|
-
/* Temporary till we figure out the arguments - Start */
|
|
24445
24781
|
this.domain = hostName = sipAccountInfo.domain;
|
|
24446
24782
|
this.sipdomain = sipAccountInfo.sipdomain;
|
|
24447
24783
|
this.accountName = this.userName = sipAccountInfo.userName;
|
|
@@ -24457,9 +24793,6 @@ class ExotelWebClient {
|
|
|
24457
24793
|
this.sipWsPort = 5061;
|
|
24458
24794
|
this.sipPort = 5061;
|
|
24459
24795
|
this.sipSecurePort = 5062;
|
|
24460
|
-
/* Temporary till we figure out the arguments - End */
|
|
24461
|
-
|
|
24462
|
-
/* This is permanent -Start */
|
|
24463
24796
|
let webrtcPort = wssPort;
|
|
24464
24797
|
if (this.security === 'ws') {
|
|
24465
24798
|
webrtcPort = wsPort;
|
|
@@ -24476,37 +24809,21 @@ class ExotelWebClient {
|
|
|
24476
24809
|
this.sipAccntInfo['port'] = webrtcPort;
|
|
24477
24810
|
this.sipAccntInfo['contactHost'] = this.contactHost;
|
|
24478
24811
|
localStorage.setItem('contactHost', this.contactHost);
|
|
24479
|
-
|
|
24480
|
-
|
|
24481
|
-
/**
|
|
24482
|
-
* Call the webclient function inside this and pass register and call callbacks as arg
|
|
24483
|
-
*/
|
|
24484
|
-
var synchronousHandler = new ExSynchronousHandler(this);
|
|
24812
|
+
var synchronousHandler = new ExSynchronousHandler();
|
|
24485
24813
|
var delegationHandler = new ExDelegationHandler(this);
|
|
24486
24814
|
var userName = this.userName;
|
|
24487
|
-
|
|
24488
|
-
|
|
24489
|
-
|
|
24490
|
-
/* New-Way */
|
|
24491
|
-
_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.webrtcSIPPhone.registerPhone("sipjs", delegationHandler);
|
|
24492
|
-
_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.webrtcSIPPhone.registerWebRTCClient(this.sipAccntInfo, synchronousHandler);
|
|
24493
|
-
|
|
24494
|
-
/**
|
|
24495
|
-
* Store the intervalID against a map
|
|
24496
|
-
*/
|
|
24815
|
+
this.webrtcSIPPhone.registerPhone("sipjs", delegationHandler);
|
|
24816
|
+
this.webrtcSIPPhone.registerWebRTCClient(this.sipAccntInfo, synchronousHandler);
|
|
24817
|
+
phonePool[this.userName] = this.webrtcSIPPhone;
|
|
24497
24818
|
intervalIDMap.set(userName, intervalId);
|
|
24498
24819
|
};
|
|
24499
24820
|
checkClientStatus = callback => {
|
|
24500
|
-
// using this function , first it will check mic permission is given or not
|
|
24501
|
-
// then it will check if transport is intialize or not
|
|
24502
|
-
// then it will check if user is registered or not
|
|
24503
|
-
// based on this we can evaludate SDK is ready for call
|
|
24504
24821
|
var constraints = {
|
|
24505
24822
|
audio: true,
|
|
24506
24823
|
video: false
|
|
24507
24824
|
};
|
|
24508
24825
|
navigator.mediaDevices.getUserMedia(constraints).then(function (mediaStream) {
|
|
24509
|
-
var transportState =
|
|
24826
|
+
var transportState = this.webrtcSIPPhone.getTransportState();
|
|
24510
24827
|
transportState = transportState.toLowerCase();
|
|
24511
24828
|
switch (transportState) {
|
|
24512
24829
|
case "":
|
|
@@ -24517,7 +24834,7 @@ class ExotelWebClient {
|
|
|
24517
24834
|
callback(transportState);
|
|
24518
24835
|
break;
|
|
24519
24836
|
default:
|
|
24520
|
-
var registerationState =
|
|
24837
|
+
var registerationState = this.webrtcSIPPhone.getRegistrationState();
|
|
24521
24838
|
registerationState = registerationState.toLowerCase();
|
|
24522
24839
|
switch (registerationState) {
|
|
24523
24840
|
case "":
|
|
@@ -24541,11 +24858,11 @@ class ExotelWebClient {
|
|
|
24541
24858
|
};
|
|
24542
24859
|
changeAudioInputDevice(deviceId, onSuccess, onError) {
|
|
24543
24860
|
logger.log(`ExWebClient: changeAudioInputDevice: Entry`);
|
|
24544
|
-
|
|
24861
|
+
this.webrtcSIPPhone.changeAudioInputDevice(deviceId, onSuccess, onError);
|
|
24545
24862
|
}
|
|
24546
24863
|
changeAudioOutputDevice(deviceId, onSuccess, onError) {
|
|
24547
24864
|
logger.log(`ExWebClient: changeAudioOutputDevice: Entry`);
|
|
24548
|
-
|
|
24865
|
+
this.webrtcSIPPhone.changeAudioOutputDevice(deviceId, onSuccess, onError);
|
|
24549
24866
|
}
|
|
24550
24867
|
downloadLogs() {
|
|
24551
24868
|
logger.log(`ExWebClient: downloadLogs: Entry`);
|
|
@@ -24553,13 +24870,22 @@ class ExotelWebClient {
|
|
|
24553
24870
|
}
|
|
24554
24871
|
setPreferredCodec(codecName) {
|
|
24555
24872
|
logger.log("ExWebClient: setPreferredCodec: Entry");
|
|
24556
|
-
|
|
24873
|
+
if (!this.webrtcSIPPhone || !this.webrtcSIPPhone.phone) {
|
|
24874
|
+
logger.warn("ExWebClient: setPreferredCodec: Phone not initialized");
|
|
24875
|
+
return;
|
|
24876
|
+
}
|
|
24877
|
+
this.webrtcSIPPhone.setPreferredCodec(codecName);
|
|
24557
24878
|
}
|
|
24558
24879
|
registerLoggerCallback(callback) {
|
|
24559
24880
|
this.clientSDKLoggerCallback = callback;
|
|
24560
24881
|
}
|
|
24561
24882
|
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback) {
|
|
24562
|
-
|
|
24883
|
+
logger.log("ExWebClient: registerAudioDeviceChangeCallback: Entry");
|
|
24884
|
+
if (!this.webrtcSIPPhone) {
|
|
24885
|
+
logger.warn("ExWebClient: registerAudioDeviceChangeCallback: webrtcSIPPhone not initialized");
|
|
24886
|
+
return;
|
|
24887
|
+
}
|
|
24888
|
+
this.webrtcSIPPhone.registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback);
|
|
24563
24889
|
}
|
|
24564
24890
|
}
|
|
24565
24891
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ExotelWebClient);
|
|
@@ -24579,35 +24905,43 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
24579
24905
|
/* harmony export */ });
|
|
24580
24906
|
/* harmony import */ var _Callback__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Callback */ "./src/listeners/Callback.js");
|
|
24581
24907
|
|
|
24582
|
-
|
|
24583
24908
|
class ExotelVoiceClientListener {
|
|
24909
|
+
registerCallback = null;
|
|
24910
|
+
constructor(registerCallback) {
|
|
24911
|
+
this.registerCallback = registerCallback;
|
|
24912
|
+
}
|
|
24584
24913
|
onInitializationSuccess(phone) {
|
|
24585
24914
|
/**
|
|
24586
24915
|
* Abstract class for Initialization Success
|
|
24587
24916
|
*/
|
|
24588
|
-
|
|
24917
|
+
this.registerCallback.initializeRegister("registered", phone);
|
|
24589
24918
|
/**
|
|
24590
24919
|
* Triggers UI callback to indicate the status of the registered phone
|
|
24591
24920
|
*/
|
|
24592
|
-
|
|
24921
|
+
this.registerCallback.triggerRegisterCallback();
|
|
24593
24922
|
_Callback__WEBPACK_IMPORTED_MODULE_0__.diagnosticsCallback.triggerKeyValueSetCallback("userReg", "registered", phone);
|
|
24594
24923
|
}
|
|
24595
24924
|
onInitializationFailure(phone) {
|
|
24596
24925
|
/**
|
|
24597
24926
|
* If register fails send error message to Callback function
|
|
24598
24927
|
*/
|
|
24599
|
-
|
|
24600
|
-
|
|
24928
|
+
this.registerCallback.initializeRegister("unregistered", phone);
|
|
24929
|
+
this.registerCallback.triggerRegisterCallback();
|
|
24601
24930
|
_Callback__WEBPACK_IMPORTED_MODULE_0__.diagnosticsCallback.triggerKeyValueSetCallback("userReg", "unregistered", phone);
|
|
24602
24931
|
}
|
|
24603
24932
|
onInitializationWaiting(phone) {
|
|
24604
24933
|
/**
|
|
24605
24934
|
* If register fails send error message to Callback function
|
|
24606
24935
|
*/
|
|
24607
|
-
|
|
24608
|
-
|
|
24936
|
+
this.registerCallback.initializeRegister("sent_request", phone);
|
|
24937
|
+
this.registerCallback.triggerRegisterCallback();
|
|
24609
24938
|
_Callback__WEBPACK_IMPORTED_MODULE_0__.diagnosticsCallback.triggerKeyValueSetCallback("userReg", "sent_request", phone);
|
|
24610
24939
|
}
|
|
24940
|
+
onRegistrationStateChanged(state, phone) {
|
|
24941
|
+
this.registerCallback.initializeRegister(state, phone);
|
|
24942
|
+
this.registerCallback.triggerRegisterCallback();
|
|
24943
|
+
_Callback__WEBPACK_IMPORTED_MODULE_0__.diagnosticsCallback.triggerKeyValueSetCallback("userReg", state, phone);
|
|
24944
|
+
}
|
|
24611
24945
|
onLog(LogLevel, tag, message) {
|
|
24612
24946
|
/**
|
|
24613
24947
|
* To get SDK logs
|
|
@@ -24633,126 +24967,138 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
24633
24967
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
24634
24968
|
/* harmony export */ SessionListener: () => (/* binding */ SessionListener)
|
|
24635
24969
|
/* harmony export */ });
|
|
24636
|
-
/* harmony import */ var
|
|
24637
|
-
/* harmony import */ var
|
|
24638
|
-
/* harmony import */ var _constants_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../constants/common */ "./src/constants/common.js");
|
|
24639
|
-
/* harmony import */ var _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @exotel-npm-dev/webrtc-core-sdk */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/index.js");
|
|
24640
|
-
|
|
24641
|
-
|
|
24970
|
+
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-browser/v4.js");
|
|
24971
|
+
/* harmony import */ var _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @exotel-npm-dev/webrtc-core-sdk */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/index.js");
|
|
24642
24972
|
|
|
24643
24973
|
|
|
24644
|
-
|
|
24974
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.getLogger)();
|
|
24645
24975
|
/**
|
|
24646
24976
|
* Session listeners is invoked when user opens two tabs, the data in tab 1 is
|
|
24647
24977
|
* copied into tab 2
|
|
24648
24978
|
*/
|
|
24649
|
-
|
|
24650
|
-
|
|
24651
|
-
|
|
24652
|
-
|
|
24653
|
-
|
|
24654
|
-
|
|
24655
|
-
|
|
24656
|
-
|
|
24657
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.initializeSession('logout', '');
|
|
24658
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.triggerSessionCallback();
|
|
24659
|
-
} else if (event.data.message == 'login-successful') {
|
|
24660
|
-
const loginObj = {
|
|
24661
|
-
phone: window.localStorage.getItem('currentUser'),
|
|
24662
|
-
tabHash: event.data.tabHash
|
|
24663
|
-
};
|
|
24664
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.initializeSession('login-successful', JSON.stringify(loginObj));
|
|
24665
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.triggerSessionCallback();
|
|
24666
|
-
} else if (window.sessionStorage.getItem("activeSessionTab") !== null) {
|
|
24667
|
-
if (event.data.callState !== null && event.data.callState !== undefined) {
|
|
24668
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.initializeSession(event.data.callState, event.data.callNumber);
|
|
24669
|
-
}
|
|
24670
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.triggerSessionCallback();
|
|
24671
|
-
}
|
|
24672
|
-
});
|
|
24673
|
-
/**
|
|
24674
|
-
* Add listeners for all storage events
|
|
24675
|
-
*/
|
|
24676
|
-
window.localStorage.setItem('REQUESTING_SHARED_CREDENTIALS', Date.now().toString());
|
|
24677
|
-
window.localStorage.removeItem('REQUESTING_SHARED_CREDENTIALS');
|
|
24678
|
-
const credentials = {
|
|
24679
|
-
user: window.sessionStorage.getItem('user'),
|
|
24680
|
-
selectedPhone: window.localStorage.getItem('selectedPhone')
|
|
24979
|
+
class SessionListener {
|
|
24980
|
+
sessionCallback = null;
|
|
24981
|
+
constructor(sessionCallback) {
|
|
24982
|
+
this.sessionCallback = sessionCallback;
|
|
24983
|
+
}
|
|
24984
|
+
onSessionEstablished = function (session) {
|
|
24985
|
+
logger.log("SessionListener: onSessionEstablished");
|
|
24986
|
+
this.sessionCallback.triggerCallback("established", session);
|
|
24681
24987
|
};
|
|
24682
|
-
|
|
24988
|
+
onSessionTerminated = function (session) {
|
|
24989
|
+
logger.log("SessionListener: onSessionTerminated");
|
|
24990
|
+
this.sessionCallback.triggerCallback("terminated", session);
|
|
24991
|
+
};
|
|
24992
|
+
onSessionEvent(event) {
|
|
24993
|
+
this.sessionCallback.triggerSessionCallback(event);
|
|
24994
|
+
}
|
|
24995
|
+
onTBD() {
|
|
24996
|
+
const channel = new BroadcastChannel('app-data');
|
|
24997
|
+
channel.addEventListener('message', event => {
|
|
24998
|
+
if (event.data.message == "re-register-needed") {
|
|
24999
|
+
/** Send the hash to app seeking for reregistration */
|
|
25000
|
+
this.sessionCallback.initializeSession('re-register', event.data.hashMsg);
|
|
25001
|
+
this.sessionCallback.triggerSessionCallback();
|
|
25002
|
+
} else if (event.data.message == 'logout') {
|
|
25003
|
+
this.sessionCallback.initializeSession('logout', '');
|
|
25004
|
+
this.sessionCallback.triggerSessionCallback();
|
|
25005
|
+
} else if (event.data.message == 'login-successful') {
|
|
25006
|
+
const loginObj = {
|
|
25007
|
+
phone: window.localStorage.getItem('currentUser'),
|
|
25008
|
+
tabHash: event.data.tabHash
|
|
25009
|
+
};
|
|
25010
|
+
this.sessionCallback.initializeSession('login-successful', JSON.stringify(loginObj));
|
|
25011
|
+
this.sessionCallback.triggerSessionCallback();
|
|
25012
|
+
} else if (window.sessionStorage.getItem("activeSessionTab") !== null) {
|
|
25013
|
+
if (event.data.callState !== null && event.data.callState !== undefined) {
|
|
25014
|
+
this.sessionCallback.initializeSession(event.data.callState, event.data.callNumber);
|
|
25015
|
+
}
|
|
25016
|
+
this.sessionCallback.triggerSessionCallback();
|
|
25017
|
+
}
|
|
25018
|
+
});
|
|
24683
25019
|
/**
|
|
24684
|
-
|
|
24685
|
-
|
|
24686
|
-
|
|
24687
|
-
|
|
24688
|
-
|
|
25020
|
+
* Add listeners for all storage events
|
|
25021
|
+
*/
|
|
25022
|
+
window.localStorage.setItem('REQUESTING_SHARED_CREDENTIALS', Date.now().toString());
|
|
25023
|
+
window.localStorage.removeItem('REQUESTING_SHARED_CREDENTIALS');
|
|
25024
|
+
const credentials = {
|
|
25025
|
+
user: window.sessionStorage.getItem('user'),
|
|
25026
|
+
selectedPhone: window.localStorage.getItem('selectedPhone')
|
|
25027
|
+
};
|
|
25028
|
+
window.addEventListener('storage', event => {
|
|
24689
25029
|
/**
|
|
24690
|
-
|
|
24691
|
-
|
|
24692
|
-
|
|
24693
|
-
|
|
24694
|
-
|
|
24695
|
-
|
|
24696
|
-
|
|
24697
|
-
|
|
24698
|
-
|
|
24699
|
-
window.sessionStorage.setItem('isAuthenticated', true);
|
|
25030
|
+
* When user tries to duplicate tab, this gets called in Tab1
|
|
25031
|
+
*/
|
|
25032
|
+
if (event.key === 'REQUESTING_SHARED_CREDENTIALS' && credentials) {
|
|
25033
|
+
window.localStorage.setItem('CREDENTIALS_SHARING', JSON.stringify(credentials));
|
|
25034
|
+
window.localStorage.removeItem('CREDENTIALS_SHARING');
|
|
25035
|
+
/**
|
|
25036
|
+
* When the data is to be shared between two tabs then add the current state onto that session storage
|
|
25037
|
+
*/
|
|
25038
|
+
//sessionCallback.triggerSessionCallback();
|
|
24700
25039
|
}
|
|
24701
|
-
/**
|
|
24702
|
-
* Fetch the array of tabs and add the tab, put it on session also
|
|
24703
|
-
*/
|
|
24704
|
-
const currentTab = {
|
|
24705
|
-
tabID: (0,uuid__WEBPACK_IMPORTED_MODULE_3__["default"])(),
|
|
24706
|
-
tabType: 'child',
|
|
24707
|
-
tabStatus: 'active'
|
|
24708
|
-
};
|
|
24709
|
-
const tabArr = JSON.parse(window.localStorage.getItem('tabs'));
|
|
24710
|
-
/** Based on activeSessionTab id fetch the type */
|
|
24711
25040
|
|
|
24712
|
-
if (
|
|
24713
|
-
|
|
24714
|
-
|
|
25041
|
+
if (event.key === 'CREDENTIALS_SHARING' && credentials !== null) {
|
|
25042
|
+
const newData = JSON.parse(event.newValue);
|
|
25043
|
+
if (event.newValue !== null) {
|
|
25044
|
+
window.sessionStorage.setItem('user', newData.user);
|
|
25045
|
+
window.sessionStorage.setItem('isAuthenticated', true);
|
|
25046
|
+
}
|
|
25047
|
+
/**
|
|
25048
|
+
* Fetch the array of tabs and add the tab, put it on session also
|
|
25049
|
+
*/
|
|
25050
|
+
const currentTab = {
|
|
25051
|
+
tabID: (0,uuid__WEBPACK_IMPORTED_MODULE_1__["default"])(),
|
|
25052
|
+
tabType: 'child',
|
|
25053
|
+
tabStatus: 'active'
|
|
25054
|
+
};
|
|
25055
|
+
const tabArr = JSON.parse(window.localStorage.getItem('tabs'));
|
|
25056
|
+
/** Based on activeSessionTab id fetch the type */
|
|
25057
|
+
|
|
25058
|
+
if (window.sessionStorage.getItem('activeSessionTab') !== null && window.sessionStorage.getItem('activeSessionTab') == "parent0") {
|
|
25059
|
+
logger.log('Adding a child tab spawned from parent....');
|
|
25060
|
+
/** In order to keep tabID same for all the child ones, we are using below IF to distinguish */
|
|
24715
25061
|
|
|
24716
|
-
|
|
24717
|
-
|
|
25062
|
+
if (tabArr.length > 1 && window.sessionStorage.getItem('activeSessionTab') == "parent0") {
|
|
25063
|
+
if (!document.hidden) {
|
|
25064
|
+
const lastIndex = tabArr.length - 1;
|
|
25065
|
+
window.sessionStorage.setItem('activeSessionTab', tabArr[lastIndex].tabID);
|
|
25066
|
+
}
|
|
25067
|
+
} else {
|
|
25068
|
+
tabArr.push(currentTab);
|
|
25069
|
+
window.localStorage.removeItem('tabs');
|
|
25070
|
+
window.localStorage.setItem('tabs', JSON.stringify(tabArr));
|
|
24718
25071
|
const lastIndex = tabArr.length - 1;
|
|
24719
25072
|
window.sessionStorage.setItem('activeSessionTab', tabArr[lastIndex].tabID);
|
|
24720
25073
|
}
|
|
24721
25074
|
} else {
|
|
24722
|
-
|
|
24723
|
-
|
|
24724
|
-
window.localStorage.setItem('tabs', JSON.stringify(tabArr));
|
|
25075
|
+
/** pull from the tabarray and then add it to the session storage */
|
|
25076
|
+
|
|
24725
25077
|
const lastIndex = tabArr.length - 1;
|
|
24726
25078
|
window.sessionStorage.setItem('activeSessionTab', tabArr[lastIndex].tabID);
|
|
24727
25079
|
}
|
|
24728
|
-
|
|
24729
|
-
|
|
24730
|
-
|
|
24731
|
-
const lastIndex = tabArr.length - 1;
|
|
24732
|
-
window.sessionStorage.setItem('activeSessionTab', tabArr[lastIndex].tabID);
|
|
25080
|
+
//window.localStorage.setItem('selectedPhone', newData.selectedPhone);
|
|
25081
|
+
return;
|
|
25082
|
+
//}
|
|
24733
25083
|
}
|
|
24734
|
-
|
|
24735
|
-
|
|
24736
|
-
|
|
24737
|
-
|
|
24738
|
-
|
|
24739
|
-
|
|
24740
|
-
|
|
24741
|
-
|
|
24742
|
-
|
|
24743
|
-
|
|
24744
|
-
|
|
24745
|
-
|
|
24746
|
-
|
|
24747
|
-
|
|
24748
|
-
|
|
24749
|
-
|
|
24750
|
-
|
|
24751
|
-
window.sessionStorage.removeItem('activeSession');
|
|
24752
|
-
}
|
|
24753
|
-
});
|
|
25084
|
+
/**
|
|
25085
|
+
* When a tab is closed
|
|
25086
|
+
*/
|
|
25087
|
+
if (event.key === 'CREDENTIALS_FLUSH' && credentials) {
|
|
25088
|
+
window.sessionStorage.removeItem('user');
|
|
25089
|
+
window.sessionStorage.removeItem('selectedPhone');
|
|
25090
|
+
window.sessionStorage.removeItem('isAuthenticated');
|
|
25091
|
+
window.sessionStorage.removeItem('activeSession');
|
|
25092
|
+
}
|
|
25093
|
+
/**
|
|
25094
|
+
* When any tab is closed, active call gets terminated
|
|
25095
|
+
*/
|
|
25096
|
+
if (event.key === 'CALL_FLUSH') {
|
|
25097
|
+
window.sessionStorage.removeItem('activeSession');
|
|
25098
|
+
}
|
|
25099
|
+
});
|
|
25100
|
+
}
|
|
24754
25101
|
}
|
|
24755
|
-
;
|
|
24756
25102
|
|
|
24757
25103
|
/***/ }),
|
|
24758
25104
|
|
|
@@ -25082,12 +25428,11 @@ var __webpack_exports__ = {};
|
|
|
25082
25428
|
\******************/
|
|
25083
25429
|
__webpack_require__.r(__webpack_exports__);
|
|
25084
25430
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
25085
|
-
/* harmony export */ ExDelegationHandler: () => (/* reexport safe */ _src_listeners_ExWebClient__WEBPACK_IMPORTED_MODULE_0__.ExDelegationHandler),
|
|
25086
|
-
/* harmony export */ ExSynchronousHandler: () => (/* reexport safe */ _src_listeners_ExWebClient__WEBPACK_IMPORTED_MODULE_0__.ExSynchronousHandler),
|
|
25087
25431
|
/* harmony export */ ExotelWebClient: () => (/* reexport safe */ _src_listeners_ExWebClient__WEBPACK_IMPORTED_MODULE_0__.ExotelWebClient)
|
|
25088
25432
|
/* harmony export */ });
|
|
25089
25433
|
/* harmony import */ var _src_listeners_ExWebClient__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/listeners/ExWebClient */ "./src/listeners/ExWebClient.js");
|
|
25090
25434
|
|
|
25435
|
+
|
|
25091
25436
|
})();
|
|
25092
25437
|
|
|
25093
25438
|
/******/ return __webpack_exports__;
|