@exotel-npm-dev/webrtc-client-sdk 1.0.24 → 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 +15 -0
- package/Makefile +0 -9
- package/dist/exotelsdk.js +2013 -1563
- package/dist/exotelsdk.js.map +1 -1
- package/index.js +2 -1
- package/package.json +3 -3
- package/src/api/LogManager.js +40 -0
- package/src/api/callAPI/Call.js +25 -14
- 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 +241 -204
- 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,29 +20855,14 @@ 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
|
-
logger.log("No userAgent.getLogger
|
|
20865
|
+
logger.log("sipjsphone: getLogger: No userAgent.getLogger, Using console log")
|
|
20889
20866
|
return console;
|
|
20890
20867
|
}
|
|
20891
20868
|
|
|
@@ -20893,22 +20870,138 @@ function getLogger() {
|
|
|
20893
20870
|
return uaLogger;
|
|
20894
20871
|
}
|
|
20895
20872
|
else {
|
|
20896
|
-
logger.log("No Logger
|
|
20873
|
+
logger.log("sipjsphone: getLogger: No Logger, Using console log")
|
|
20897
20874
|
return logger;
|
|
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("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("startRingTone: Exception:", e);
|
|
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("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
|
-
|
|
20956
|
-
} catch (e) { logger.log("stopRingTone: Exception:", e); }
|
|
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)
|
|
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
|
-
|
|
20971
|
-
|
|
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
|
+
});
|
|
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,59 +21106,60 @@ 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
|
-
logger.log("something went wrong while initing getstats");
|
|
21114
|
+
logger.log("sipjsphone: newSession: something went wrong while initing getstats");
|
|
21024
21115
|
logger.log(e);
|
|
21025
21116
|
}
|
|
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,52 +21245,56 @@ function postInit(onInitDoneCallback) {
|
|
|
21153
21245
|
}
|
|
21154
21246
|
},
|
|
21155
21247
|
|
|
21156
|
-
|
|
21157
|
-
|
|
21248
|
+
setError: (err, title, msg, closable) => { },
|
|
21158
21249
|
|
|
21159
21250
|
|
|
21160
21251
|
|
|
21161
|
-
phoneMuteButtonPressed: function (sessionid) {
|
|
21162
21252
|
|
|
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
|
-
|
|
21178
|
-
logger.log("phoneMute: bMute", bMute)
|
|
21179
|
-
|
|
21180
|
-
|
|
21269
|
+
var s = this.ctxSip.Sessions[sessionid];
|
|
21270
|
+
logger.log(" sipjsphone: phoneMute: bMute", bMute)
|
|
21271
|
+
this.toggleMute(s, bMute);
|
|
21272
|
+
this.bMicEnable = !bMute;
|
|
21273
|
+
}
|
|
21274
|
+
else{
|
|
21275
|
+
logger.log(" sipjsphone: phoneMute: doing nothing as sessionid not found")
|
|
21276
|
+
|
|
21181
21277
|
}
|
|
21182
21278
|
},
|
|
21183
21279
|
|
|
21184
|
-
|
|
21280
|
+
phoneHold: (sessionid, bHold) => {
|
|
21185
21281
|
if (sessionid) {
|
|
21186
|
-
|
|
21187
|
-
logger.log("phoneHold: bHold", bHold)
|
|
21188
|
-
|
|
21189
|
-
|
|
21282
|
+
var s = this.ctxSip.Sessions[sessionid];
|
|
21283
|
+
logger.log("sipjsphone: phoneHold: bHold", bHold)
|
|
21284
|
+
this.toggleHold(s, bHold);
|
|
21285
|
+
this.bHoldEnable = bHold;
|
|
21190
21286
|
}
|
|
21191
21287
|
},
|
|
21192
21288
|
|
|
21193
|
-
|
|
21289
|
+
phoneHoldButtonPressed: (sessionid) => {
|
|
21194
21290
|
if (sessionid) {
|
|
21195
|
-
|
|
21196
|
-
|
|
21197
|
-
|
|
21198
|
-
|
|
21291
|
+
var s = this.ctxSip.Sessions[sessionid];
|
|
21292
|
+
if (this.bHoldEnable) {
|
|
21293
|
+
this.toggleHold(s, false);
|
|
21294
|
+
this.bHoldEnable = false;
|
|
21199
21295
|
} else {
|
|
21200
|
-
|
|
21201
|
-
|
|
21296
|
+
this.toggleHold(s, true);
|
|
21297
|
+
this.bHoldEnable = true;
|
|
21202
21298
|
}
|
|
21203
21299
|
}
|
|
21204
21300
|
},
|
|
@@ -21208,7 +21304,7 @@ function postInit(onInitDoneCallback) {
|
|
|
21208
21304
|
* Tests for a capable browser, return bool, and shows an error modal on
|
|
21209
21305
|
* fail.
|
|
21210
21306
|
*/
|
|
21211
|
-
|
|
21307
|
+
hasWebRTC: () => {
|
|
21212
21308
|
|
|
21213
21309
|
if (navigator.webkitGetUserMedia) {
|
|
21214
21310
|
return true;
|
|
@@ -21217,7 +21313,7 @@ function postInit(onInitDoneCallback) {
|
|
|
21217
21313
|
} else if (navigator.getUserMedia) {
|
|
21218
21314
|
return true;
|
|
21219
21315
|
} else {
|
|
21220
|
-
|
|
21316
|
+
this.ctxSip.setError(true, 'Unsupported Browser.', 'Your browser does not support the features required for this phone.');
|
|
21221
21317
|
logger.error("WebRTC support not found");
|
|
21222
21318
|
return false;
|
|
21223
21319
|
}
|
|
@@ -21226,124 +21322,151 @@ function postInit(onInitDoneCallback) {
|
|
|
21226
21322
|
};
|
|
21227
21323
|
|
|
21228
21324
|
|
|
21229
|
-
|
|
21325
|
+
if (!this.ctxSip.hasWebRTC()) {
|
|
21230
21326
|
alert('Your browser don\'t support WebRTC.\naudio/video calls will be disabled.');
|
|
21231
21327
|
}
|
|
21232
|
-
|
|
21233
|
-
|
|
21234
|
-
|
|
21328
|
+
|
|
21329
|
+
// Use the correct delegate property
|
|
21330
|
+
if (this.webrtcSIPPhoneEventDelegate?.setWebRTCFSMMapper) {
|
|
21331
|
+
this.webrtcSIPPhoneEventDelegate.setWebRTCFSMMapper("sipjs");
|
|
21332
|
+
}
|
|
21333
|
+
|
|
21334
|
+
logger.log("sipjsphone: init: Initialization complete...")
|
|
21335
|
+
this.initializeComplete = true;
|
|
21336
|
+
if (onInitDoneCallback) {
|
|
21235
21337
|
onInitDoneCallback();
|
|
21338
|
+
}
|
|
21236
21339
|
}
|
|
21237
21340
|
|
|
21238
|
-
|
|
21239
|
-
|
|
21240
|
-
|
|
21241
|
-
|
|
21242
|
-
|
|
21243
|
-
|
|
21244
|
-
|
|
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
|
+
}
|
|
21245
21348
|
|
|
21246
|
-
|
|
21247
|
-
|
|
21248
|
-
|
|
21349
|
+
const { payloadType, rtpMap, fmtp } = this.preferredCodec;
|
|
21350
|
+
const codecRtpMap = `a=rtpmap:${payloadType} ${rtpMap}`;
|
|
21351
|
+
const codecFmtp = fmtp ? `a=fmtp:${payloadType} ${fmtp}` : "";
|
|
21249
21352
|
|
|
21250
|
-
|
|
21353
|
+
logger.log("sipjsphone:addPreferredCodec: Original SDP:", description.sdp);
|
|
21251
21354
|
|
|
21252
|
-
|
|
21253
|
-
|
|
21355
|
+
// Parse SDP into lines
|
|
21356
|
+
let sdpLines = description.sdp.split("\r\n");
|
|
21254
21357
|
|
|
21255
|
-
|
|
21256
|
-
|
|
21257
|
-
|
|
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"));
|
|
21258
21361
|
|
|
21259
|
-
|
|
21260
|
-
|
|
21362
|
+
if (existingOpusIndex !== -1 && audioMLineIndex !== -1) {
|
|
21363
|
+
logger.log("sipjsphone:addPreferredCodec: Opus codec already exists. Prioritizing it.");
|
|
21261
21364
|
|
|
21262
|
-
|
|
21263
|
-
|
|
21264
|
-
|
|
21365
|
+
// Extract and modify the audio m-line
|
|
21366
|
+
let audioMLine = sdpLines[audioMLineIndex];
|
|
21367
|
+
audioMLine = audioMLine.replace("RTP/SAVP", "RTP/AVP");
|
|
21265
21368
|
|
|
21266
|
-
|
|
21267
|
-
|
|
21268
|
-
|
|
21369
|
+
const codecs = audioMLine.split(" ");
|
|
21370
|
+
const mLineStart = codecs.slice(0, 3); // "m=audio <port> <protocol>"
|
|
21371
|
+
const mLineCodecs = codecs.slice(3);
|
|
21269
21372
|
|
|
21270
|
-
|
|
21271
|
-
|
|
21272
|
-
|
|
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);
|
|
21273
21376
|
|
|
21274
|
-
|
|
21275
|
-
|
|
21276
|
-
|
|
21277
|
-
|
|
21278
|
-
|
|
21279
|
-
|
|
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);
|
|
21280
21383
|
|
|
21281
|
-
|
|
21282
|
-
|
|
21283
|
-
|
|
21284
|
-
|
|
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.");
|
|
21285
21388
|
|
|
21286
|
-
|
|
21287
|
-
|
|
21288
|
-
|
|
21389
|
+
// Extract and modify the audio m-line
|
|
21390
|
+
let audioMLine = sdpLines[audioMLineIndex];
|
|
21391
|
+
audioMLine = audioMLine.replace("RTP/SAVP", "RTP/AVP");
|
|
21289
21392
|
|
|
21290
|
-
|
|
21291
|
-
|
|
21292
|
-
|
|
21393
|
+
const codecs = audioMLine.split(" ");
|
|
21394
|
+
const mLineStart = codecs.slice(0, 3); // "m=audio <port> <protocol>"
|
|
21395
|
+
const mLineCodecs = codecs.slice(3);
|
|
21293
21396
|
|
|
21294
|
-
|
|
21295
|
-
|
|
21397
|
+
// Add Opus payload type to the top
|
|
21398
|
+
mLineCodecs.unshift(payloadType.toString());
|
|
21296
21399
|
|
|
21297
|
-
|
|
21298
|
-
|
|
21400
|
+
// Update the audio m-line
|
|
21401
|
+
sdpLines[audioMLineIndex] = `${mLineStart.join(" ")} ${mLineCodecs.join(" ")}`;
|
|
21299
21402
|
|
|
21300
|
-
|
|
21301
|
-
|
|
21302
|
-
|
|
21303
|
-
|
|
21304
|
-
|
|
21305
|
-
|
|
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);
|
|
21306
21413
|
}
|
|
21307
|
-
} else {
|
|
21308
|
-
logger.error("sipjsphone:addPreferredCodec: No audio m-line found in SDP. Cannot modify.");
|
|
21309
|
-
return Promise.resolve(description);
|
|
21310
|
-
}
|
|
21311
21414
|
|
|
21312
|
-
|
|
21313
|
-
|
|
21415
|
+
// Remove any duplicate lines
|
|
21416
|
+
sdpLines = [...new Set(sdpLines)];
|
|
21314
21417
|
|
|
21315
|
-
|
|
21316
|
-
|
|
21317
|
-
|
|
21418
|
+
// Combine back into SDP
|
|
21419
|
+
description.sdp = sdpLines.join("\r\n");
|
|
21420
|
+
logger.log("sipjsphone:addPreferredCodec: Modified SDP:", description.sdp);
|
|
21318
21421
|
|
|
21319
|
-
|
|
21320
|
-
}
|
|
21422
|
+
return Promise.resolve(description);
|
|
21423
|
+
}
|
|
21321
21424
|
|
|
21322
|
-
|
|
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
|
+
}]);
|
|
21323
21433
|
|
|
21324
|
-
|
|
21434
|
+
try {
|
|
21435
|
+
if (!this.txtRealm || !this.txtPrivateIdentity || !this.txtPublicIdentity) {
|
|
21436
|
+
logger.error("sipjsphone: sipRegister: Missing required credentials");
|
|
21437
|
+
return;
|
|
21438
|
+
}
|
|
21325
21439
|
|
|
21326
|
-
|
|
21440
|
+
const uri = SIP.UserAgent.makeURI(this.txtPublicIdentity);
|
|
21441
|
+
if (!uri) {
|
|
21442
|
+
logger.error("sipjsphone: sipRegister: Failed to create SIP URI");
|
|
21443
|
+
return;
|
|
21444
|
+
}
|
|
21327
21445
|
|
|
21328
|
-
|
|
21329
|
-
|
|
21330
|
-
authorizationPassword: txtPassword,
|
|
21331
|
-
authorizationUsername: txtDisplayName,
|
|
21332
|
-
displayName: txtDisplayName,
|
|
21333
|
-
uri: SIP.UserAgent.makeURI(txtPublicIdentity),
|
|
21334
|
-
hackWssInTransport: true,
|
|
21335
|
-
allowLegacyNotifications: true,
|
|
21336
|
-
contactParams: {
|
|
21337
|
-
transport: "wss"
|
|
21338
|
-
},
|
|
21446
|
+
const userAgentConfig = {
|
|
21447
|
+
uri: uri,
|
|
21339
21448
|
transportOptions: {
|
|
21340
|
-
|
|
21449
|
+
server: this.txtWebsocketURL,
|
|
21341
21450
|
traceSip: true,
|
|
21342
21451
|
reconnectionAttempts: 0
|
|
21343
|
-
|
|
21344
21452
|
},
|
|
21345
21453
|
logBuiltinEnabled: true,
|
|
21346
|
-
|
|
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),
|
|
21347
21470
|
logLevel: "log",
|
|
21348
21471
|
sessionDescriptionHandlerFactoryOptions: {
|
|
21349
21472
|
constraints: {
|
|
@@ -21351,337 +21474,245 @@ function sipRegister() {
|
|
|
21351
21474
|
video: false
|
|
21352
21475
|
}
|
|
21353
21476
|
},
|
|
21354
|
-
|
|
21355
|
-
|
|
21356
|
-
|
|
21357
|
-
|
|
21358
|
-
|
|
21359
|
-
|
|
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
|
+
};
|
|
21360
21492
|
|
|
21361
|
-
|
|
21362
|
-
|
|
21363
|
-
|
|
21364
|
-
|
|
21365
|
-
|
|
21366
|
-
|
|
21367
|
-
|
|
21368
|
-
|
|
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
|
+
};
|
|
21369
21503
|
|
|
21370
|
-
|
|
21371
|
-
|
|
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;
|
|
21372
21509
|
|
|
21373
|
-
|
|
21374
|
-
|
|
21375
|
-
|
|
21376
|
-
|
|
21377
|
-
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
|
+
}
|
|
21378
21514
|
}
|
|
21379
|
-
register_flag = false;
|
|
21380
|
-
}
|
|
21381
21515
|
|
|
21382
|
-
|
|
21516
|
+
registererStateEventListner(newState) {
|
|
21517
|
+
logger.log("sipjsphone: registererStateEventListner: Registration state changed to:", [newState]);
|
|
21383
21518
|
|
|
21384
|
-
|
|
21385
|
-
|
|
21386
|
-
|
|
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
|
+
}
|
|
21387
21529
|
|
|
21388
|
-
|
|
21389
|
-
|
|
21390
|
-
|
|
21391
|
-
case SIP.RegistererState.Unregistered:
|
|
21392
|
-
onUserAgentRegistrationFailed();
|
|
21530
|
+
if (this.webrtcSIPPhoneEventDelegate && typeof this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM === 'function') {
|
|
21531
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("registered", "CONNECTION");
|
|
21532
|
+
}
|
|
21393
21533
|
break;
|
|
21394
|
-
case
|
|
21395
|
-
|
|
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
|
+
}
|
|
21396
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
|
+
}
|
|
21397
21557
|
|
|
21398
|
-
|
|
21558
|
+
if (this.webrtcSIPPhoneEventDelegate && typeof this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM === 'function') {
|
|
21559
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("terminated", "CONNECTION");
|
|
21560
|
+
}
|
|
21399
21561
|
break;
|
|
21400
21562
|
}
|
|
21563
|
+
this.lastRegistererState = newState;
|
|
21401
21564
|
}
|
|
21402
21565
|
|
|
21403
21566
|
|
|
21404
|
-
};
|
|
21405
|
-
|
|
21406
|
-
|
|
21407
|
-
|
|
21408
|
-
let registererWaitingChangeListener = (b) => {
|
|
21409
|
-
if (registerer && registerer.state == SIP.RegistererState.Registered) {
|
|
21410
|
-
onUserAgentRegistered();
|
|
21411
|
-
}
|
|
21412
|
-
|
|
21413
|
-
};
|
|
21414
|
-
|
|
21415
|
-
let transportStateChangeListener = (newState) => {
|
|
21416
|
-
lastTransportState = newState;
|
|
21417
|
-
sipPhoneLogger("debug", "", "", "sipjslog transport new state " + newState);
|
|
21418
|
-
|
|
21419
|
-
switch (newState) {
|
|
21420
|
-
|
|
21421
|
-
case SIP.TransportState.Connecting:
|
|
21422
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].onCallStatSipJsTransportEvent('connecting');
|
|
21423
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("starting", "CONNECTION");
|
|
21424
|
-
break;
|
|
21425
|
-
case SIP.TransportState.Connected:
|
|
21426
|
-
onUserAgentTransportConnected();
|
|
21427
|
-
break;
|
|
21428
|
-
case SIP.TransportState.Disconnected:
|
|
21429
|
-
onUserAgentTransportDisconnected();
|
|
21430
|
-
break;
|
|
21431
|
-
default:
|
|
21432
|
-
break;
|
|
21433
21567
|
|
|
21568
|
+
registererWaitingChangeListener(b) {
|
|
21569
|
+
if (this.registerer && this.registerer.state == SIP.RegistererState.Registered) {
|
|
21570
|
+
this.registererStateEventListner("Registered");
|
|
21571
|
+
}
|
|
21434
21572
|
|
|
21435
21573
|
}
|
|
21436
|
-
};
|
|
21437
|
-
|
|
21438
|
-
function registerPhoneEventListeners() {
|
|
21439
|
-
|
|
21440
|
-
ctxSip.phone.delegate = {};
|
|
21441
|
-
|
|
21442
|
-
|
|
21443
|
-
|
|
21444
|
-
|
|
21445
|
-
ctxSip.phone.transport.stateChange.addListener(transportStateChangeListener);
|
|
21446
21574
|
|
|
21447
|
-
|
|
21575
|
+
transportStateChangeListener(newState) {
|
|
21576
|
+
logger.log("sipjsphone: transportStateChangeListener: Transport state changed to:", [newState]);
|
|
21577
|
+
this.lastTransportState = newState;
|
|
21448
21578
|
|
|
21449
|
-
|
|
21450
|
-
|
|
21451
|
-
|
|
21452
|
-
var s = incomingSession;
|
|
21453
|
-
s.direction = 'incoming';
|
|
21454
|
-
ctxSip.newSession(s);
|
|
21455
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].onRecieveInvite(incomingSession);
|
|
21456
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("i_new_call", "CALL");
|
|
21457
|
-
} else {
|
|
21458
|
-
incomingSession.reject({
|
|
21459
|
-
statusCode: 480,
|
|
21460
|
-
reasonPhrase: "4001"
|
|
21461
|
-
});
|
|
21579
|
+
if (newState === "Connected") {
|
|
21580
|
+
logger.log("sipjsphone: transportStateChangeListener: WebSocket connected");
|
|
21581
|
+
this.onUserAgentTransportConnected();
|
|
21462
21582
|
}
|
|
21463
|
-
};
|
|
21464
21583
|
|
|
21584
|
+
if (newState === "Disconnected") {
|
|
21585
|
+
logger.log("sipjsphone: transportStateChangeListener: WebSocket disconnected");
|
|
21465
21586
|
|
|
21587
|
+
if (this.webrtcSIPPhoneEventDelegate && typeof this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent === 'function') {
|
|
21588
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent("disconnected");
|
|
21589
|
+
}
|
|
21466
21590
|
|
|
21467
|
-
|
|
21468
|
-
|
|
21469
|
-
}
|
|
21470
|
-
|
|
21471
|
-
|
|
21591
|
+
// PATCH: Surface this as an 'unregistered' terminal state
|
|
21592
|
+
this.registererStateEventListner("Unregistered");
|
|
21472
21593
|
|
|
21473
|
-
|
|
21474
|
-
|
|
21475
|
-
// connected,
|
|
21476
|
-
// terminating,
|
|
21477
|
-
// terminated
|
|
21478
|
-
if (b_connected || b_connecting) {
|
|
21479
|
-
register_flag = true;
|
|
21480
|
-
webRTCStatus = "ready";
|
|
21481
|
-
} else {
|
|
21482
|
-
register_flag = false;
|
|
21483
|
-
destroySocketConnection();
|
|
21594
|
+
this.onUserAgentTransportDisconnected();
|
|
21595
|
+
}
|
|
21484
21596
|
|
|
21597
|
+
if (this.webrtcSIPPhoneEventDelegate && this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent) {
|
|
21598
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent(newState);
|
|
21599
|
+
}
|
|
21485
21600
|
}
|
|
21486
21601
|
|
|
21487
|
-
|
|
21488
|
-
|
|
21489
|
-
|
|
21490
|
-
|
|
21491
|
-
|
|
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() {
|
|
21492
21608
|
try {
|
|
21493
|
-
|
|
21494
|
-
|
|
21495
|
-
|
|
21496
|
-
|
|
21497
|
-
|
|
21498
|
-
|
|
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);
|
|
21499
21627
|
}
|
|
21500
|
-
}
|
|
21501
|
-
|
|
21502
|
-
|
|
21503
|
-
function uiCallTerminated(s_description) {
|
|
21504
|
-
if (window.btnBFCP)
|
|
21505
|
-
window.btnBFCP.disabled = true;
|
|
21506
|
-
|
|
21507
|
-
ctxSip.stopRingTone();
|
|
21508
|
-
ctxSip.stopRingbackTone();
|
|
21509
|
-
|
|
21510
|
-
if (callBackHandler != null)
|
|
21511
|
-
if (callBackHandler.onResponse)
|
|
21512
|
-
callBackHandler.onResponse("disconnected");
|
|
21513
|
-
|
|
21514
|
-
|
|
21515
|
-
}
|
|
21516
|
-
|
|
21517
|
-
|
|
21518
|
-
function sipCall() {
|
|
21519
|
-
logger.log("testing emit accept_reject");
|
|
21520
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("accept_reject", "CALL");
|
|
21521
|
-
}
|
|
21628
|
+
}
|
|
21522
21629
|
|
|
21523
21630
|
|
|
21631
|
+
uiOnConnectionEvent(b_connected, b_connecting) {
|
|
21632
|
+
logger.log("sipjsphone: uiOnConnectionEvent: Connection state changed:", [b_connected, b_connecting]);
|
|
21524
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
|
+
}
|
|
21525
21641
|
|
|
21526
|
-
|
|
21527
|
-
|
|
21528
|
-
|
|
21529
|
-
if (
|
|
21530
|
-
|
|
21531
|
-
} else
|
|
21532
|
-
|
|
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");
|
|
21533
21649
|
}
|
|
21534
|
-
logger.log(level + " sipjslog: " + category + ": " + content);
|
|
21535
21650
|
}
|
|
21536
|
-
} catch (e) {
|
|
21537
|
-
logger.error("sipjsphone:sipPhoneLogger ERROR", e);
|
|
21538
|
-
}
|
|
21539
|
-
|
|
21540
|
-
}
|
|
21541
|
-
|
|
21542
|
-
|
|
21543
|
-
function onInvitationSessionAccepted(newSess) {
|
|
21544
|
-
ctxSip.Stream = newSess.sessionDescriptionHandler.localMediaStream;
|
|
21545
|
-
assignStream(newSess.sessionDescriptionHandler.remoteMediaStream, audioRemote);
|
|
21546
|
-
|
|
21547
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].onCallStatSipJsSessionEvent('accepted');
|
|
21548
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("connected", "CALL");
|
|
21549
|
-
|
|
21550
|
-
// If there is another active call, hold it
|
|
21551
|
-
if (ctxSip.callActiveID && ctxSip.callActiveID !== newSess.ctxid) {
|
|
21552
|
-
ctxSip.phoneHoldButtonPressed(ctxSip.callActiveID);
|
|
21553
|
-
}
|
|
21554
|
-
|
|
21555
|
-
ctxSip.stopRingbackTone();
|
|
21556
|
-
ctxSip.stopRingTone();
|
|
21557
|
-
ctxSip.setCallSessionStatus('Answered');
|
|
21558
|
-
ctxSip.logCall(newSess, 'answered');
|
|
21559
|
-
ctxSip.callActiveID = newSess.ctxid;
|
|
21560
|
-
|
|
21561
|
-
webRTCStatus = "busy";
|
|
21562
|
-
if (callBackHandler != null)
|
|
21563
|
-
if (callBackHandler.onResponse)
|
|
21564
|
-
callBackHandler.onResponse("connected");
|
|
21565
|
-
}
|
|
21566
|
-
|
|
21567
|
-
function onInvitationSessionTerminated() {
|
|
21568
|
-
SIPJSPhone.stopStreamTracks(ctxSip.Stream);
|
|
21569
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].stopCallStat();
|
|
21570
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].onCallStatSipJsSessionEvent('terminated');
|
|
21571
|
-
ctxSip.stopRingTone();
|
|
21572
|
-
ctxSip.stopRingbackTone();
|
|
21573
|
-
ctxSip.setCallSessionStatus("");
|
|
21574
|
-
ctxSip.callActiveID = null;
|
|
21575
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].playBeepTone();
|
|
21576
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("terminated", "CALL");
|
|
21577
|
-
|
|
21578
|
-
uiCallTerminated();
|
|
21579
|
-
if (register_flag == true) {
|
|
21580
|
-
webRTCStatus = "ready";
|
|
21581
|
-
} else {
|
|
21582
|
-
destroySocketConnection();
|
|
21583
21651
|
}
|
|
21584
|
-
if (callBackHandler != null)
|
|
21585
|
-
if (callBackHandler.onResponse)
|
|
21586
|
-
callBackHandler.onResponse("disconnected");
|
|
21587
|
-
}
|
|
21588
|
-
|
|
21589
|
-
|
|
21590
|
-
function onUserAgentRegistered() {
|
|
21591
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].sendWebRTCEventsToFSM("connected", "CONNECTION");
|
|
21592
|
-
var bConnected = true;
|
|
21593
|
-
uiOnConnectionEvent(bConnected, !bConnected);
|
|
21594
|
-
register_flag = true;
|
|
21595
|
-
webRTCStatus = "ready";
|
|
21596
|
-
if (callBackHandler != null)
|
|
21597
|
-
if (callBackHandler.onResponse)
|
|
21598
|
-
callBackHandler.onResponse("ready");
|
|
21599
|
-
|
|
21600
|
-
|
|
21601
|
-
var closePhone = function () {
|
|
21602
|
-
// stop the phone on unload
|
|
21603
|
-
localStorage.removeItem('ctxPhone');
|
|
21604
|
-
ctxSip.phone.stop();
|
|
21605
|
-
};
|
|
21606
21652
|
|
|
21607
|
-
|
|
21608
|
-
|
|
21609
|
-
}
|
|
21610
|
-
|
|
21611
|
-
function onUserAgentRegistrationTerminated() {
|
|
21612
|
-
uiOnConnectionEvent(false, false);
|
|
21613
|
-
}
|
|
21653
|
+
onUserAgentTransportConnected() {
|
|
21654
|
+
logger.log("sipjsphone: onUserAgentTransportConnected: Transport connected");
|
|
21614
21655
|
|
|
21615
|
-
|
|
21656
|
+
if (this.webrtcSIPPhoneEventDelegate && typeof this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent === 'function') {
|
|
21657
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsTransportEvent('connected');
|
|
21658
|
+
}
|
|
21616
21659
|
|
|
21660
|
+
this.webRTCStatus = "ready";
|
|
21617
21661
|
|
|
21618
|
-
|
|
21619
|
-
|
|
21620
|
-
register_flag = false;
|
|
21621
|
-
if (callBackHandler != null) {
|
|
21622
|
-
if (callBackHandler.onResponse) {
|
|
21623
|
-
callBackHandler.onResponse("error");
|
|
21662
|
+
if (this.webrtcSIPPhoneEventDelegate && typeof this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM === 'function') {
|
|
21663
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("started", "CONNECTION");
|
|
21624
21664
|
}
|
|
21625
|
-
}
|
|
21626
|
-
}
|
|
21627
21665
|
|
|
21666
|
+
// Update UI state to show connected
|
|
21667
|
+
this.uiOnConnectionEvent(true, false);
|
|
21628
21668
|
|
|
21629
|
-
|
|
21630
|
-
|
|
21631
|
-
|
|
21632
|
-
|
|
21633
|
-
if (callBackHandler != null) {
|
|
21634
|
-
if (callBackHandler.onResponse) {
|
|
21635
|
-
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();
|
|
21636
21673
|
}
|
|
21637
21674
|
}
|
|
21638
21675
|
|
|
21639
|
-
|
|
21640
|
-
|
|
21641
|
-
registerer.register();
|
|
21642
|
-
|
|
21643
|
-
}
|
|
21644
|
-
|
|
21645
|
-
|
|
21646
|
-
function cleanupRegistererTimer() {
|
|
21647
|
-
if (registerer) {
|
|
21676
|
+
cleanupRegistererTimer() {
|
|
21677
|
+
if (this.registerer) {
|
|
21648
21678
|
|
|
21649
|
-
|
|
21650
|
-
|
|
21651
|
-
|
|
21652
|
-
|
|
21679
|
+
try {
|
|
21680
|
+
this.registerer.clearTimers();
|
|
21681
|
+
this.registerer.stateChange.removeListener(this.registererStateEventListner);
|
|
21682
|
+
this.registerer.waitingChange.removeListener(this.registererWaitingChangeListener);
|
|
21653
21683
|
|
|
21654
21684
|
|
|
21655
21685
|
} catch (e) {
|
|
21656
|
-
logger.log("ERROR", e);
|
|
21686
|
+
logger.log("sipjsphone: cleanupRegistererTimer: ERROR", e);
|
|
21687
|
+
|
|
21688
|
+
}
|
|
21689
|
+
this.registerer = null;
|
|
21657
21690
|
|
|
21658
21691
|
}
|
|
21659
|
-
registerer = null;
|
|
21660
21692
|
}
|
|
21661
|
-
}
|
|
21662
21693
|
|
|
21663
|
-
|
|
21694
|
+
onUserAgentTransportDisconnected() {
|
|
21664
21695
|
|
|
21665
|
-
|
|
21666
|
-
|
|
21696
|
+
this.webRTCStatus = "offline";
|
|
21697
|
+
this.setRegisterFlag(false);
|
|
21667
21698
|
|
|
21668
|
-
|
|
21699
|
+
this.cleanupRegistererTimer();
|
|
21669
21700
|
|
|
21670
|
-
|
|
21671
|
-
|
|
21672
|
-
|
|
21673
|
-
|
|
21674
|
-
|
|
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
|
+
}
|
|
21675
21707
|
}
|
|
21676
|
-
}
|
|
21677
21708
|
|
|
21678
21709
|
|
|
21679
21710
|
|
|
21680
21711
|
|
|
21681
|
-
}
|
|
21712
|
+
}
|
|
21682
21713
|
|
|
21683
21714
|
|
|
21684
|
-
|
|
21715
|
+
parseSipMessage(message) {
|
|
21685
21716
|
var lines = message.split("\n");
|
|
21686
21717
|
var firstLine = lines[0];
|
|
21687
21718
|
lines.slice(0, 1);
|
|
@@ -21709,26 +21740,26 @@ function parseSipMessage(message) {
|
|
|
21709
21740
|
return sipob;
|
|
21710
21741
|
}
|
|
21711
21742
|
|
|
21712
|
-
|
|
21743
|
+
handleWebSocketMessageContent(content, direction) {
|
|
21713
21744
|
var lines = content.split('\n');
|
|
21714
21745
|
lines.splice(0, 2);
|
|
21715
21746
|
var newtext = lines.join('\n');
|
|
21716
21747
|
|
|
21717
21748
|
|
|
21718
|
-
|
|
21749
|
+
var sipMessage = this.parseSipMessage(newtext);
|
|
21719
21750
|
|
|
21720
21751
|
switch (direction) {
|
|
21721
21752
|
case "sent":
|
|
21722
21753
|
|
|
21723
21754
|
if (sipMessage.method == "CONNECTION")
|
|
21724
|
-
|
|
21755
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("sent_request", sipMessage.method);
|
|
21725
21756
|
|
|
21726
|
-
|
|
21757
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipSendCallback(newtext, "sipjs");
|
|
21727
21758
|
|
|
21728
21759
|
|
|
21729
21760
|
break;
|
|
21730
21761
|
case "recv":
|
|
21731
|
-
|
|
21762
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipRecvCallback(newtext, "sipjs");
|
|
21732
21763
|
break;
|
|
21733
21764
|
default:
|
|
21734
21765
|
break;
|
|
@@ -21740,68 +21771,74 @@ function handleWebSocketMessageContent(content, direction) {
|
|
|
21740
21771
|
|
|
21741
21772
|
|
|
21742
21773
|
|
|
21743
|
-
|
|
21744
|
-
|
|
21774
|
+
setRegisterFlag(b) {
|
|
21775
|
+
this.register_flag = b;
|
|
21745
21776
|
}
|
|
21746
21777
|
|
|
21747
|
-
|
|
21778
|
+
toggleMute(s, mute) {
|
|
21748
21779
|
let pc = s.sessionDescriptionHandler.peerConnection;
|
|
21749
21780
|
if (pc.getSenders) {
|
|
21750
|
-
|
|
21781
|
+
pc.getSenders().forEach((sender) => {
|
|
21751
21782
|
if (sender.track) {
|
|
21752
21783
|
sender.track.enabled = !mute;
|
|
21753
21784
|
}
|
|
21754
21785
|
});
|
|
21755
21786
|
} else {
|
|
21756
|
-
|
|
21757
|
-
|
|
21787
|
+
pc.getLocalStreams().forEach((stream) => {
|
|
21788
|
+
stream.getAudioTracks().forEach((track) => {
|
|
21758
21789
|
track.enabled = !mute;
|
|
21759
21790
|
});
|
|
21760
|
-
|
|
21791
|
+
stream.getVideoTracks().forEach((track) => {
|
|
21761
21792
|
track.enabled = !mute;
|
|
21762
21793
|
});
|
|
21763
21794
|
});
|
|
21764
21795
|
}
|
|
21765
21796
|
if (mute) {
|
|
21766
|
-
|
|
21797
|
+
this.onMuted(s);
|
|
21767
21798
|
} else {
|
|
21768
|
-
|
|
21799
|
+
this.onUnmuted(s);
|
|
21769
21800
|
}
|
|
21770
21801
|
}
|
|
21771
21802
|
|
|
21772
21803
|
|
|
21773
|
-
|
|
21774
|
-
|
|
21775
|
-
|
|
21776
|
-
|
|
21777
|
-
|
|
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
|
+
}
|
|
21778
21812
|
|
|
21779
|
-
|
|
21780
|
-
|
|
21781
|
-
|
|
21782
|
-
|
|
21783
|
-
|
|
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
|
+
}
|
|
21784
21821
|
|
|
21785
|
-
|
|
21822
|
+
onHold(s) {
|
|
21786
21823
|
//webrtcSIPPhoneEventDelegate.onCallStatSipJsSessionEvent('hold');
|
|
21787
21824
|
logger.warn(`[${s.id}] re-invite request was accepted`);
|
|
21788
21825
|
s.held = true;
|
|
21789
|
-
|
|
21790
|
-
|
|
21791
|
-
|
|
21792
|
-
}
|
|
21826
|
+
this.enableSenderTracks(s, !s.held && !s.isMuted);
|
|
21827
|
+
this.enableReceiverTracks(s, !s.held);
|
|
21828
|
+
//this.ctxSip.setCallSessionStatus("Hold");
|
|
21829
|
+
}
|
|
21793
21830
|
|
|
21794
|
-
|
|
21831
|
+
onUnhold(s) {
|
|
21795
21832
|
//webrtcSIPPhoneEventDelegate.onCallStatSipJsSessionEvent('unhold');
|
|
21796
21833
|
logger.warn(`[${s.id}] re-invite request was rejected`);
|
|
21797
21834
|
s.held = false;
|
|
21798
|
-
|
|
21799
|
-
|
|
21800
|
-
|
|
21835
|
+
this.enableSenderTracks(s, !s.held && !s.isMuted);
|
|
21836
|
+
this.enableReceiverTracks(s, !s.held);
|
|
21837
|
+
//this.ctxSip.setCallSessionStatus("Unhold");
|
|
21801
21838
|
}
|
|
21802
21839
|
|
|
21803
21840
|
/** Helper function to enable/disable media tracks. */
|
|
21804
|
-
|
|
21841
|
+
enableReceiverTracks(s, enable) {
|
|
21805
21842
|
try {
|
|
21806
21843
|
const sessionDescriptionHandler = s.sessionDescriptionHandler;
|
|
21807
21844
|
const peerConnection = sessionDescriptionHandler.peerConnection;
|
|
@@ -21809,19 +21846,19 @@ function enableReceiverTracks(s, enable) {
|
|
|
21809
21846
|
throw new Error("Peer connection closed.");
|
|
21810
21847
|
}
|
|
21811
21848
|
peerConnection.getReceivers().forEach((receiver) => {
|
|
21812
|
-
logger.log("Receiver ", receiver)
|
|
21849
|
+
logger.log("sipjsphone: enableReceiverTracks: Receiver ", receiver)
|
|
21813
21850
|
if (receiver.track) {
|
|
21814
21851
|
receiver.track.enabled = enable;
|
|
21815
21852
|
}
|
|
21816
21853
|
});
|
|
21817
21854
|
} catch (e) {
|
|
21818
|
-
logger.log("enableReceiverTracks: Error in updating receiver tracks ", e)
|
|
21855
|
+
logger.log("sipjsphone: enableReceiverTracks: Error in updating receiver tracks ", e)
|
|
21819
21856
|
|
|
21820
21857
|
}
|
|
21821
21858
|
}
|
|
21822
21859
|
|
|
21823
21860
|
/** Helper function to enable/disable media tracks. */
|
|
21824
|
-
|
|
21861
|
+
enableSenderTracks(s, enable) {
|
|
21825
21862
|
try {
|
|
21826
21863
|
const sessionDescriptionHandler = s.sessionDescriptionHandler;
|
|
21827
21864
|
const peerConnection = sessionDescriptionHandler.peerConnection;
|
|
@@ -21834,18 +21871,18 @@ function enableSenderTracks(s, enable) {
|
|
|
21834
21871
|
}
|
|
21835
21872
|
});
|
|
21836
21873
|
} catch (e) {
|
|
21837
|
-
logger.log("enableSenderTracks: Error in updating sender tracks ", e)
|
|
21874
|
+
logger.log("sipjsphone: enableSenderTracks: Error in updating sender tracks ", e)
|
|
21838
21875
|
}
|
|
21839
21876
|
}
|
|
21840
21877
|
|
|
21841
|
-
|
|
21878
|
+
toggleHold(s, hold) {
|
|
21842
21879
|
const options = {
|
|
21843
21880
|
requestDelegate: {
|
|
21844
21881
|
onAccept: () => {
|
|
21845
|
-
|
|
21882
|
+
this.onHold(s)
|
|
21846
21883
|
},
|
|
21847
21884
|
onReject: () => {
|
|
21848
|
-
|
|
21885
|
+
this.onUnhold(s)
|
|
21849
21886
|
}
|
|
21850
21887
|
},
|
|
21851
21888
|
sessionDescriptionHandlerOptions: {
|
|
@@ -21854,14 +21891,14 @@ function toggleHold(s, hold) {
|
|
|
21854
21891
|
};
|
|
21855
21892
|
s.invite(options).then(() => {
|
|
21856
21893
|
// preemptively enable/disable tracks
|
|
21857
|
-
|
|
21858
|
-
|
|
21894
|
+
this.enableReceiverTracks(s, !hold);
|
|
21895
|
+
this.enableSenderTracks(s, !hold && !s.isMuted);
|
|
21859
21896
|
}).catch((error) => {
|
|
21860
21897
|
logger.error(`Error in hold request [${s.id}]`);
|
|
21861
21898
|
});
|
|
21862
21899
|
}
|
|
21863
21900
|
|
|
21864
|
-
|
|
21901
|
+
assignStream(stream, element) {
|
|
21865
21902
|
if (_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioOutputDeviceId != "default")
|
|
21866
21903
|
element.setSinkId(_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioOutputDeviceId);
|
|
21867
21904
|
// Set element source.
|
|
@@ -21894,296 +21931,326 @@ function assignStream(stream, element) {
|
|
|
21894
21931
|
};
|
|
21895
21932
|
}
|
|
21896
21933
|
|
|
21897
|
-
|
|
21934
|
+
onUserSessionAcceptFailed(e) {
|
|
21898
21935
|
if (e.name == "NotAllowedError" || e.name == "NotFoundError") {
|
|
21899
|
-
|
|
21900
|
-
|
|
21901
|
-
|
|
21936
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("m_permission_refused", "CALL");
|
|
21937
|
+
this.webrtcSIPPhoneEventDelegate.onCallStatSipJsSessionEvent('userMediaFailed');
|
|
21938
|
+
this.webrtcSIPPhoneEventDelegate.onGetUserMediaErrorCallstatCallback();
|
|
21902
21939
|
} else {
|
|
21903
|
-
logger.log("user media failed due to error ", e);
|
|
21940
|
+
logger.log("sipjsphone: onUserSessionAcceptFailed: user media failed due to error ", e);
|
|
21941
|
+
}
|
|
21942
|
+
this.uiCallTerminated('Media stream permission denied');
|
|
21904
21943
|
}
|
|
21905
|
-
uiCallTerminated('Media stream permission denied');
|
|
21906
|
-
}
|
|
21907
|
-
|
|
21908
|
-
const SIPJSPhone = {
|
|
21909
21944
|
|
|
21910
|
-
|
|
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'];
|
|
21911
21952
|
|
|
21912
|
-
|
|
21913
|
-
|
|
21914
|
-
|
|
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;
|
|
21915
21960
|
}
|
|
21916
|
-
var oReadyStateTimer = setInterval(function () {
|
|
21917
|
-
if (document.readyState === "complete") {
|
|
21918
|
-
clearInterval(oReadyStateTimer);
|
|
21919
|
-
logger.log("init:readyState, calling preinit")
|
|
21920
|
-
preInit();
|
|
21921
|
-
}
|
|
21922
|
-
}, 100);
|
|
21923
|
-
|
|
21924
|
-
},
|
|
21925
21961
|
|
|
21926
|
-
|
|
21927
|
-
|
|
21928
|
-
|
|
21929
|
-
|
|
21930
|
-
|
|
21931
|
-
txtHostName = txtHostNameWithPort.split(":")[0];
|
|
21932
|
-
txtWebSocketPort = txtHostNameWithPort.split(":")[1];
|
|
21933
|
-
txtAccountName = sipAccountInfo['accountName'];
|
|
21934
|
-
txtPublicIdentity = "sip:" + txtPrivateIdentity + "@" + txtHostNameWithPort;
|
|
21935
|
-
txtPassword = sipAccountInfo["secret"];
|
|
21936
|
-
txtRealm = txtHostName;
|
|
21937
|
-
txtTurnServer = "drishti@" + txtRealm + ":3478";
|
|
21938
|
-
txtCredential = "jrp931";
|
|
21939
|
-
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'";
|
|
21940
21967
|
|
|
21941
21968
|
|
|
21942
21969
|
var default_values = {
|
|
21943
21970
|
'security': window.location.protocol == "http:" ? 'ws' : 'wss',
|
|
21944
|
-
'sipdomain': txtHostName,
|
|
21945
|
-
'contactHost': txtHostName,
|
|
21971
|
+
'sipdomain': this.txtHostName,
|
|
21972
|
+
'contactHost': this.txtHostName,
|
|
21946
21973
|
'wsPort': window.location.protocol == "http:" ? 8088 : 8089,
|
|
21947
21974
|
'sipPort': window.location.protocol == "http:" ? 5060 : 5061,
|
|
21948
21975
|
'endpoint': 'ws'
|
|
21949
21976
|
}
|
|
21950
21977
|
|
|
21951
|
-
txtSecurity = sipAccountInfo['security'] ? sipAccountInfo['security'] : default_values['security'];
|
|
21952
|
-
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'];
|
|
21953
21980
|
|
|
21954
21981
|
if (sipAccountInfo['sipdomain']) {
|
|
21955
|
-
txtSipDomain = sipAccountInfo["sipdomain"];
|
|
21956
|
-
txtPublicIdentity = "sip:" + txtPrivateIdentity + "@" + txtSipDomain;
|
|
21982
|
+
this.txtSipDomain = sipAccountInfo["sipdomain"];
|
|
21983
|
+
this.txtPublicIdentity = "sip:" + this.txtPrivateIdentity + "@" + this.txtSipDomain;
|
|
21957
21984
|
} else {
|
|
21958
|
-
txtSipDomain = default_values["sipdomain"];
|
|
21985
|
+
this.txtSipDomain = default_values["sipdomain"];
|
|
21959
21986
|
}
|
|
21960
21987
|
|
|
21961
21988
|
if (sipAccountInfo['contactHost']) {
|
|
21962
|
-
txtContactHost = sipAccountInfo["contactHost"];
|
|
21989
|
+
this.txtContactHost = sipAccountInfo["contactHost"];
|
|
21963
21990
|
} else {
|
|
21964
|
-
txtContactHost = default_values["contactHost"];
|
|
21991
|
+
this.txtContactHost = default_values["contactHost"];
|
|
21965
21992
|
}
|
|
21966
21993
|
|
|
21967
|
-
txtSipPort = sipAccountInfo['sipPort'] ? sipAccountInfo["sipPort"] : default_values["sipPort"];
|
|
21968
|
-
|
|
21994
|
+
this.txtSipPort = sipAccountInfo['sipPort'] ? sipAccountInfo["sipPort"] : default_values["sipPort"];
|
|
21995
|
+
|
|
21996
|
+
// Fix: Handle endpoint value to avoid double 'wss' path
|
|
21997
|
+
this.endpoint = sipAccountInfo['endpoint'] ? sipAccountInfo['endpoint'] : default_values['endpoint'];
|
|
21969
21998
|
|
|
21970
|
-
|
|
21971
|
-
|
|
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;
|
|
21972
22006
|
|
|
21973
22007
|
|
|
21974
|
-
var oInitializeCompleteTimer =
|
|
21975
|
-
if (initializeComplete
|
|
21976
|
-
sipRegister()
|
|
22008
|
+
var oInitializeCompleteTimer = setTimeout(() => {
|
|
22009
|
+
if (this.initializeComplete) {
|
|
22010
|
+
this.sipRegister()
|
|
21977
22011
|
}
|
|
21978
22012
|
}, 500);
|
|
21979
|
-
}
|
|
22013
|
+
}
|
|
21980
22014
|
|
|
21981
|
-
getStatus
|
|
21982
|
-
return webRTCStatus;
|
|
21983
|
-
}
|
|
22015
|
+
getStatus() {
|
|
22016
|
+
return this.webRTCStatus;
|
|
22017
|
+
}
|
|
21984
22018
|
|
|
21985
|
-
registerCallBacks
|
|
21986
|
-
callBackHandler = handler;
|
|
21987
|
-
}
|
|
22019
|
+
registerCallBacks(handler) {
|
|
22020
|
+
this.callBackHandler = handler;
|
|
22021
|
+
}
|
|
21988
22022
|
|
|
21989
|
-
sipSendDTMF
|
|
21990
|
-
ctxSip.sipSendDTMF(c);
|
|
21991
|
-
}
|
|
22023
|
+
sipSendDTMF(c) {
|
|
22024
|
+
this.ctxSip.sipSendDTMF(c);
|
|
22025
|
+
}
|
|
21992
22026
|
|
|
21993
|
-
sipToggleRegister
|
|
21994
|
-
if (register_flag == false) {
|
|
21995
|
-
register_flag = true;
|
|
21996
|
-
sipRegister();
|
|
22027
|
+
sipToggleRegister() {
|
|
22028
|
+
if (this.register_flag == false) {
|
|
22029
|
+
this.register_flag = true;
|
|
22030
|
+
this.sipRegister();
|
|
21997
22031
|
|
|
21998
|
-
} else if (register_flag == true) {
|
|
21999
|
-
registerer.unregister({});
|
|
22000
|
-
register_flag = false;
|
|
22001
|
-
webRTCStatus = "offline";
|
|
22002
|
-
if (callBackHandler != null)
|
|
22003
|
-
if (callBackHandler.onResponse)
|
|
22004
|
-
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");
|
|
22005
22039
|
|
|
22006
22040
|
}
|
|
22007
|
-
}
|
|
22041
|
+
}
|
|
22008
22042
|
|
|
22009
|
-
reRegister
|
|
22010
|
-
logger.log("
|
|
22011
|
-
if (ctxSip.phone && registerer) {
|
|
22012
|
-
registerer.register({});
|
|
22043
|
+
reRegister() {
|
|
22044
|
+
logger.log("sipjsphone: reRegister: registering in case of relogin");
|
|
22045
|
+
if (this.ctxSip.phone && this.registerer) {
|
|
22046
|
+
this.registerer.register({});
|
|
22013
22047
|
} else {
|
|
22014
|
-
logger.log("
|
|
22048
|
+
logger.log("sipjsphone: reRegister: SIP Session does not exist for re registration");
|
|
22015
22049
|
}
|
|
22016
22050
|
|
|
22017
|
-
}
|
|
22051
|
+
}
|
|
22018
22052
|
|
|
22019
|
-
sipToggleMic
|
|
22020
|
-
ctxSip.phoneMuteButtonPressed(ctxSip.callActiveID);
|
|
22021
|
-
}
|
|
22053
|
+
sipToggleMic() {
|
|
22054
|
+
this.ctxSip.phoneMuteButtonPressed(this.ctxSip.callActiveID);
|
|
22055
|
+
}
|
|
22022
22056
|
|
|
22023
|
-
sipMute
|
|
22024
|
-
ctxSip.phoneMute(ctxSip.callActiveID, bMute);
|
|
22025
|
-
}
|
|
22057
|
+
sipMute(bMute) {
|
|
22058
|
+
this.ctxSip.phoneMute(this.ctxSip.callActiveID, bMute);
|
|
22059
|
+
}
|
|
22026
22060
|
|
|
22027
|
-
holdCall
|
|
22028
|
-
if (ctxSip.callActiveID) {
|
|
22029
|
-
ctxSip.phoneHoldButtonPressed(ctxSip.callActiveID);
|
|
22061
|
+
holdCall() {
|
|
22062
|
+
if (this.ctxSip.callActiveID) {
|
|
22063
|
+
this.ctxSip.phoneHoldButtonPressed(this.ctxSip.callActiveID);
|
|
22030
22064
|
}
|
|
22031
|
-
}
|
|
22065
|
+
}
|
|
22032
22066
|
|
|
22033
|
-
sipHold
|
|
22034
|
-
if (ctxSip.callActiveID) {
|
|
22035
|
-
ctxSip.phoneHold(ctxSip.callActiveID, bHold);
|
|
22067
|
+
sipHold(bHold) {
|
|
22068
|
+
if (this.ctxSip.callActiveID) {
|
|
22069
|
+
this.ctxSip.phoneHold(this.ctxSip.callActiveID, bHold);
|
|
22036
22070
|
}
|
|
22037
|
-
}
|
|
22071
|
+
}
|
|
22038
22072
|
|
|
22039
|
-
getMicMuteStatus
|
|
22040
|
-
|
|
22041
|
-
|
|
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
|
+
}
|
|
22042
22084
|
|
|
22043
|
-
setPreferredCodec
|
|
22085
|
+
setPreferredCodec(codecName) {
|
|
22044
22086
|
logger.log("sipjsphone:setPreferredCodec entry");
|
|
22045
22087
|
const codecPayloadTypes = {
|
|
22046
22088
|
opus: { payloadType: 111, rtpMap: "opus/48000/2", fmtp: "minptime=10;useinbandfec=1" },
|
|
22047
22089
|
};
|
|
22048
22090
|
|
|
22049
|
-
|
|
22050
|
-
if (
|
|
22051
|
-
|
|
22052
|
-
|
|
22053
|
-
|
|
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.");
|
|
22054
22096
|
}
|
|
22055
22097
|
|
|
22056
|
-
|
|
22057
|
-
logger.log("sipjsphone:setPreferredCodec: Preferred codec set to " + codecName);
|
|
22058
|
-
},
|
|
22098
|
+
this.preferredCodec = codecPayloadTypes[codec];
|
|
22059
22099
|
|
|
22060
|
-
|
|
22061
|
-
|
|
22062
|
-
|
|
22100
|
+
logger.log("sipjsphone:setPreferredCodec: Preferred codec set to " + codec);
|
|
22101
|
+
}
|
|
22102
|
+
|
|
22103
|
+
pickPhoneCall() {
|
|
22104
|
+
var newSess = this.ctxSip.Sessions[this.ctxSip.callActiveID];
|
|
22105
|
+
logger.log("sipjsphone: pickphonecall: ", this.ctxSip.callActiveID);
|
|
22063
22106
|
if (newSess) {
|
|
22064
22107
|
if (_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId != "default") {
|
|
22065
22108
|
newSess.accept({
|
|
22066
22109
|
sessionDescriptionHandlerOptions: {
|
|
22067
22110
|
constraints: { audio: { deviceId: _audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId }, video: false }
|
|
22068
22111
|
},
|
|
22069
|
-
sessionDescriptionHandlerModifiers: [addPreferredCodec]
|
|
22112
|
+
sessionDescriptionHandlerModifiers: [this.addPreferredCodec]
|
|
22070
22113
|
}).catch((e) => {
|
|
22071
|
-
onUserSessionAcceptFailed(e);
|
|
22114
|
+
this.onUserSessionAcceptFailed(e);
|
|
22072
22115
|
});
|
|
22073
22116
|
} else {
|
|
22074
22117
|
|
|
22075
22118
|
newSess.accept({
|
|
22076
|
-
sessionDescriptionHandlerModifiers: [addPreferredCodec]
|
|
22119
|
+
sessionDescriptionHandlerModifiers: [this.addPreferredCodec]
|
|
22077
22120
|
}).catch((e) => {
|
|
22078
|
-
onUserSessionAcceptFailed(e);
|
|
22121
|
+
this.onUserSessionAcceptFailed(e);
|
|
22079
22122
|
});
|
|
22080
22123
|
}
|
|
22081
22124
|
}
|
|
22082
22125
|
|
|
22083
|
-
}
|
|
22126
|
+
}
|
|
22084
22127
|
|
|
22085
22128
|
|
|
22086
|
-
sipHangUp
|
|
22087
|
-
ctxSip.sipHangUp(ctxSip.callActiveID);
|
|
22088
|
-
}
|
|
22129
|
+
sipHangUp() {
|
|
22130
|
+
this.ctxSip.sipHangUp(this.ctxSip.callActiveID);
|
|
22131
|
+
}
|
|
22089
22132
|
|
|
22090
22133
|
|
|
22091
|
-
playBeep
|
|
22134
|
+
playBeep() {
|
|
22092
22135
|
try {
|
|
22093
|
-
ctxSip.beeptone.play();
|
|
22136
|
+
this.ctxSip.beeptone.play();
|
|
22094
22137
|
} catch (e) {
|
|
22095
|
-
logger.log("playBeep: Exception:", e);
|
|
22138
|
+
logger.log("sipjsphone: playBeep: Exception:", e);
|
|
22096
22139
|
}
|
|
22097
|
-
}
|
|
22140
|
+
}
|
|
22098
22141
|
|
|
22099
|
-
sipUnRegister
|
|
22100
|
-
if (ctxSip.phone && registerer) {
|
|
22101
|
-
registerer.unregister({}).then(
|
|
22102
|
-
destroySocketConnection();
|
|
22142
|
+
sipUnRegister() {
|
|
22143
|
+
if (this.ctxSip.phone && this.registerer) {
|
|
22144
|
+
this.registerer.unregister({}).then(() => {
|
|
22145
|
+
this.destroySocketConnection();
|
|
22103
22146
|
});
|
|
22104
22147
|
} else {
|
|
22105
|
-
if (ctxSip.phone) {
|
|
22106
|
-
destroySocketConnection();
|
|
22148
|
+
if (this.ctxSip.phone) {
|
|
22149
|
+
this.destroySocketConnection();
|
|
22107
22150
|
}
|
|
22108
22151
|
}
|
|
22109
|
-
}
|
|
22152
|
+
}
|
|
22110
22153
|
|
|
22111
|
-
connect
|
|
22154
|
+
connect() {
|
|
22112
22155
|
try {
|
|
22113
|
-
sipRegister();
|
|
22156
|
+
this.sipRegister();
|
|
22114
22157
|
} catch (e) {
|
|
22115
22158
|
}
|
|
22116
|
-
}
|
|
22159
|
+
}
|
|
22117
22160
|
|
|
22118
|
-
disconnect
|
|
22119
|
-
if (registerer) {
|
|
22120
|
-
cleanupRegistererTimer();
|
|
22161
|
+
disconnect() {
|
|
22162
|
+
if (this.registerer) {
|
|
22163
|
+
this.cleanupRegistererTimer();
|
|
22121
22164
|
}
|
|
22122
|
-
if (ctxSip.phone && ctxSip.phone.transport) {
|
|
22123
|
-
ctxSip.phone.transport.stateChange.removeListener(transportStateChangeListener);
|
|
22124
|
-
if (ctxSip.phone && ctxSip.phone.transport.isConnected()) {
|
|
22125
|
-
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();
|
|
22126
22169
|
}
|
|
22127
22170
|
}
|
|
22128
|
-
}
|
|
22171
|
+
}
|
|
22129
22172
|
/* NL Additions - Start */
|
|
22130
|
-
getSpeakerTestTone
|
|
22131
|
-
logger.log("Returning speaker test tone:", ringtone);
|
|
22132
|
-
return ringtone;
|
|
22133
|
-
}
|
|
22173
|
+
getSpeakerTestTone() {
|
|
22174
|
+
logger.log("sipjsphone: getSpeakerTestTone: Returning speaker test tone:", this.ringtone);
|
|
22175
|
+
return this.ringtone;
|
|
22176
|
+
}
|
|
22134
22177
|
|
|
22135
22178
|
|
|
22136
|
-
getWSSUrl
|
|
22137
|
-
logger.log("Returning txtWebsocketURL:", txtWebsocketURL);
|
|
22138
|
-
return txtWebsocketURL;
|
|
22139
|
-
}
|
|
22179
|
+
getWSSUrl() {
|
|
22180
|
+
logger.log("sipjsphone: getWSSUrl: Returning txtWebsocketURL:", this.txtWebsocketURL);
|
|
22181
|
+
return this.txtWebsocketURL;
|
|
22182
|
+
}
|
|
22140
22183
|
/* NL Additions - End */
|
|
22141
|
-
getTransportState
|
|
22142
|
-
logger.log("Returning Transport State : ", lastTransportState);
|
|
22143
|
-
return lastTransportState;
|
|
22144
|
-
}
|
|
22145
|
-
getRegistrationState
|
|
22146
|
-
logger.log("Returning Registration State : ", lastRegistererState);
|
|
22147
|
-
return lastRegistererState;
|
|
22148
|
-
}
|
|
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
|
+
}
|
|
22149
22192
|
|
|
22150
22193
|
changeAudioInputDevice(deviceId, onSuccess, onError) {
|
|
22151
|
-
|
|
22152
|
-
|
|
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);
|
|
22153
22197
|
if (trackChanged) {
|
|
22154
22198
|
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId = deviceId;
|
|
22155
|
-
logger.log(`
|
|
22156
|
-
|
|
22157
|
-
onSuccess();
|
|
22199
|
+
logger.log(`sipjsphone: changeAudioInputDevice: Input device changed to: ${deviceId}`);
|
|
22200
|
+
if (onSuccess) onSuccess();
|
|
22158
22201
|
} else {
|
|
22159
|
-
logger.error("
|
|
22160
|
-
onError("replaceSenderTrack failed for webrtc");
|
|
22202
|
+
logger.error("sipjsphone: changeAudioInputDevice: failed");
|
|
22203
|
+
if (onError) onError("replaceSenderTrack failed for webrtc");
|
|
22161
22204
|
}
|
|
22162
|
-
},
|
|
22163
|
-
|
|
22164
|
-
|
|
22165
|
-
|
|
22166
|
-
|
|
22167
|
-
|
|
22205
|
+
}, (err) => {
|
|
22206
|
+
logger.error("sipjsphone: changeAudioInputDevice error:", err);
|
|
22207
|
+
if (onError) onError(err);
|
|
22208
|
+
});
|
|
22209
|
+
}
|
|
22210
|
+
|
|
22211
|
+
async changeAudioOutputDevice(deviceId, onSuccess, onError) {
|
|
22168
22212
|
try {
|
|
22169
|
-
|
|
22170
|
-
|
|
22171
|
-
|
|
22172
|
-
|
|
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;
|
|
22173
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;
|
|
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
|
+
});
|
|
22174
22234
|
} catch (e) {
|
|
22175
|
-
logger.error(
|
|
22235
|
+
logger.error('SIPJSPhone:changeAudioOutputDevice unexpected error:', e);
|
|
22236
|
+
if (onError) onError(e);
|
|
22176
22237
|
}
|
|
22177
|
-
}
|
|
22178
|
-
|
|
22179
|
-
|
|
22180
|
-
|
|
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);
|
|
22181
22252
|
}
|
|
22182
|
-
|
|
22183
|
-
SIPJSPhone.changeAudioOutputDeviceForAdditionalAudioElement(deviceId);
|
|
22184
|
-
onSuccess();
|
|
22185
|
-
}, onError);
|
|
22186
|
-
},
|
|
22253
|
+
}
|
|
22187
22254
|
|
|
22188
22255
|
stopStreamTracks(stream) {
|
|
22189
22256
|
try {
|
|
@@ -22196,17 +22263,17 @@ const SIPJSPhone = {
|
|
|
22196
22263
|
} catch (e) {
|
|
22197
22264
|
logger.error("sipjsphone:stopStreamTracks failed to stop tracks");
|
|
22198
22265
|
}
|
|
22199
|
-
}
|
|
22266
|
+
}
|
|
22200
22267
|
replaceSenderTrack(stream, deviceId) {
|
|
22201
22268
|
try {
|
|
22202
22269
|
|
|
22203
22270
|
if (_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId == deviceId) {
|
|
22204
|
-
|
|
22271
|
+
this.stopStreamTracks(stream);
|
|
22205
22272
|
return false;
|
|
22206
22273
|
}
|
|
22207
|
-
if (ctxSip.callActiveID) {
|
|
22208
|
-
ctxSip.Stream = stream;
|
|
22209
|
-
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];
|
|
22210
22277
|
const pc = s.sessionDescriptionHandler.peerConnection;
|
|
22211
22278
|
if (pc.getSenders) {
|
|
22212
22279
|
try {
|
|
@@ -22219,64 +22286,199 @@ const SIPJSPhone = {
|
|
|
22219
22286
|
}
|
|
22220
22287
|
}
|
|
22221
22288
|
} else {
|
|
22222
|
-
|
|
22289
|
+
this.stopStreamTracks(stream);
|
|
22223
22290
|
}
|
|
22224
22291
|
return true;
|
|
22225
22292
|
} catch (e) {
|
|
22226
22293
|
return false;
|
|
22227
22294
|
}
|
|
22228
22295
|
|
|
22229
|
-
}
|
|
22296
|
+
}
|
|
22230
22297
|
registerLogger(customLogger) {
|
|
22231
22298
|
logger = customLogger;
|
|
22232
|
-
}
|
|
22233
|
-
audioInputDeviceChangeCallback: null,
|
|
22234
|
-
audioOutputDeviceChangeCallback: null,
|
|
22235
|
-
onDeviceChangeCallback: null,
|
|
22299
|
+
}
|
|
22236
22300
|
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback) {
|
|
22237
|
-
logger.log(`
|
|
22238
|
-
|
|
22239
|
-
|
|
22240
|
-
|
|
22301
|
+
logger.log(`sipjsphone: registerAudioDeviceChangeCallback: entry`);
|
|
22302
|
+
this.audioInputDeviceChangeCallback = audioInputDeviceChangeCallback;
|
|
22303
|
+
this.audioOutputDeviceChangeCallback = audioOutputDeviceChangeCallback;
|
|
22304
|
+
this.onDeviceChangeCallback = onDeviceChangeCallback;
|
|
22241
22305
|
}
|
|
22242
22306
|
|
|
22243
|
-
|
|
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
|
+
}
|
|
22244
22315
|
|
|
22316
|
+
sipCall() {
|
|
22317
|
+
logger.log("sipjsphone: sipCall: testing emit accept_reject");
|
|
22318
|
+
if (this.webrtcSIPPhoneEventDelegate)
|
|
22319
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM("accept_reject", "CALL");
|
|
22320
|
+
}
|
|
22245
22321
|
|
|
22246
|
-
|
|
22247
|
-
|
|
22248
|
-
|
|
22249
|
-
|
|
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");
|
|
22337
|
+
}
|
|
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
|
+
}
|
|
22351
|
+
|
|
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");
|
|
22250
22375
|
}
|
|
22251
|
-
|
|
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
|
+
}
|
|
22252
22387
|
|
|
22253
|
-
|
|
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) {
|
|
22254
22422
|
logger.info("SIPJSPhone:ondevicechange relaying event to callback");
|
|
22255
|
-
|
|
22423
|
+
this.onDeviceChangeCallback(event);
|
|
22256
22424
|
return;
|
|
22257
22425
|
}
|
|
22258
|
-
|
|
22259
|
-
|
|
22260
|
-
|
|
22426
|
+
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.onAudioDeviceChange(
|
|
22427
|
+
this.audioRemote,
|
|
22428
|
+
(stream, deviceId) => {
|
|
22429
|
+
const trackChanged = this.replaceSenderTrack(stream, deviceId);
|
|
22261
22430
|
if (trackChanged) {
|
|
22262
22431
|
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioInputDeviceId = deviceId;
|
|
22263
|
-
|
|
22264
|
-
|
|
22432
|
+
if (this.audioInputDeviceChangeCallback) {
|
|
22433
|
+
this.audioInputDeviceChangeCallback(deviceId);
|
|
22265
22434
|
}
|
|
22266
22435
|
}
|
|
22267
|
-
|
|
22268
|
-
|
|
22436
|
+
},
|
|
22437
|
+
(deviceId) => {
|
|
22438
|
+
this.changeAudioOutputDeviceForAdditionalAudioElement(deviceId);
|
|
22269
22439
|
_audioDeviceManager_js__WEBPACK_IMPORTED_MODULE_0__.audioDeviceManager.currentAudioOutputDeviceId = deviceId;
|
|
22270
|
-
|
|
22271
|
-
|
|
22440
|
+
if (this.audioOutputDeviceChangeCallback) {
|
|
22441
|
+
this.audioOutputDeviceChangeCallback(deviceId);
|
|
22442
|
+
}
|
|
22272
22443
|
}
|
|
22444
|
+
);
|
|
22273
22445
|
});
|
|
22274
|
-
});
|
|
22275
|
-
|
|
22276
22446
|
} catch (e) {
|
|
22277
22447
|
logger.error("SIPJSPhone:ondevicechange something went wrong during device change", e);
|
|
22278
22448
|
}
|
|
22279
|
-
}
|
|
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
|
+
}
|
|
22280
22482
|
|
|
22281
22483
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SIPJSPhone);
|
|
22282
22484
|
|
|
@@ -22293,51 +22495,101 @@ navigator.mediaDevices.addEventListener('devicechange', function (event) {
|
|
|
22293
22495
|
__webpack_require__.r(__webpack_exports__);
|
|
22294
22496
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
22295
22497
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
|
|
22296
|
-
/* harmony export */
|
|
22498
|
+
/* harmony export */ getLogger: () => (/* binding */ getLogger)
|
|
22297
22499
|
/* harmony export */ });
|
|
22298
22500
|
/* harmony import */ var _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./coreSDKLogger */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/coreSDKLogger.js");
|
|
22299
22501
|
/* harmony import */ var _sipjsphone__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sipjsphone */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/sipjsphone.js");
|
|
22300
22502
|
/* harmony import */ var _webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webrtcSIPPhoneEventDelegate */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/src/webrtcSIPPhoneEventDelegate.js");
|
|
22301
|
-
/**
|
|
22302
|
-
* Communication from Webrtc flows and feature handling for web RTC as WebRTC Phone Interface
|
|
22303
|
-
*
|
|
22304
|
-
*/
|
|
22305
|
-
|
|
22306
22503
|
|
|
22307
22504
|
|
|
22308
22505
|
|
|
22309
22506
|
|
|
22310
|
-
var phone = null;
|
|
22311
|
-
let webrtcSIPEngine = null;
|
|
22312
22507
|
const logger = _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
22313
22508
|
|
|
22509
|
+
function getLogger() {
|
|
22510
|
+
return _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
22511
|
+
}
|
|
22512
|
+
|
|
22314
22513
|
function sendWebRTCEventsToFSM(eventType, sipMethod) {
|
|
22315
|
-
|
|
22514
|
+
logger.log("webrtcSIPPhone: sendWebRTCEventsToFSM : ",eventType,sipMethod);
|
|
22515
|
+
this.webrtcSIPPhoneEventDelegate = new _webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"]();
|
|
22516
|
+
this.webrtcSIPPhoneEventDelegate.sendWebRTCEventsToFSM(eventType, sipMethod);
|
|
22316
22517
|
}
|
|
22317
22518
|
|
|
22318
|
-
|
|
22519
|
+
class WebrtcSIPPhone {
|
|
22319
22520
|
|
|
22320
|
-
|
|
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
|
+
}
|
|
22321
22530
|
|
|
22531
|
+
static getLogger() {
|
|
22532
|
+
return _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
22533
|
+
}
|
|
22322
22534
|
|
|
22323
|
-
|
|
22324
|
-
|
|
22325
|
-
|
|
22326
|
-
|
|
22327
|
-
|
|
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
|
+
}
|
|
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
|
+
}
|
|
22570
|
+
|
|
22571
|
+
isConnected() {
|
|
22572
|
+
logger.log("webrtcSIPPhone: isConnected entry");
|
|
22573
|
+
if (!this.phone) {
|
|
22574
|
+
logger.log("webrtcSIPPhone: isConnected: phone not initialized");
|
|
22328
22575
|
return false;
|
|
22329
22576
|
}
|
|
22330
|
-
|
|
22577
|
+
const status = this.phone.getStatus();
|
|
22578
|
+
logger.log("webrtcSIPPhone: isConnected: current status:", status);
|
|
22579
|
+
return status !== "offline";
|
|
22580
|
+
}
|
|
22331
22581
|
|
|
22332
|
-
sendDTMFWebRTC
|
|
22333
|
-
|
|
22334
|
-
|
|
22582
|
+
sendDTMFWebRTC (dtmfValue){
|
|
22583
|
+
logger.log("webrtcSIPPhone: sendDTMFWebRTC : ",dtmfValue);
|
|
22584
|
+
this.phone.sipSendDTMF(dtmfValue);
|
|
22585
|
+
}
|
|
22335
22586
|
|
|
22336
|
-
registerWebRTCClient
|
|
22337
|
-
|
|
22338
|
-
|
|
22339
|
-
|
|
22340
|
-
|
|
22587
|
+
registerWebRTCClient (sipAccountInfo, handler){
|
|
22588
|
+
logger.log("webrtcSIPPhone: registerWebRTCClient : ",sipAccountInfo,handler);
|
|
22589
|
+
this.sipAccountInfoData = sipAccountInfo;
|
|
22590
|
+
this.phone.init(() => {
|
|
22591
|
+
this.phone.loadCredentials(sipAccountInfo);
|
|
22592
|
+
if (this.getWebRTCStatus() == "offline") {
|
|
22341
22593
|
if (handler != null)
|
|
22342
22594
|
if (handler.onFailure)
|
|
22343
22595
|
handler.onFailure();
|
|
@@ -22347,179 +22599,171 @@ const webrtcSIPPhone = {
|
|
|
22347
22599
|
handler.onResponse();
|
|
22348
22600
|
}
|
|
22349
22601
|
});
|
|
22602
|
+
}
|
|
22350
22603
|
|
|
22351
|
-
|
|
22352
|
-
|
|
22353
|
-
|
|
22354
|
-
|
|
22355
|
-
phone.registerCallBacks(handler);
|
|
22356
|
-
},
|
|
22604
|
+
configureWebRTCClientDevice (handler){
|
|
22605
|
+
logger.log("webrtcSIPPhone: configureWebRTCClientDevice : ",handler);
|
|
22606
|
+
this.phone.registerCallBacks(handler);
|
|
22607
|
+
}
|
|
22357
22608
|
|
|
22358
22609
|
setAuthenticatorServerURL(serverURL) {
|
|
22359
|
-
|
|
22360
|
-
}
|
|
22361
|
-
|
|
22362
|
-
toggleSipRegister: () => {
|
|
22363
|
-
phone.resetRegisterAttempts();
|
|
22364
|
-
phone.sipToggleRegister();
|
|
22365
|
-
},
|
|
22366
|
-
|
|
22367
|
-
webRTCMuteUnmute: (isMuted) => {
|
|
22368
|
-
phone.sipToggleMic();
|
|
22369
|
-
},
|
|
22370
|
-
|
|
22371
|
-
getMuteStatus: () => {
|
|
22372
|
-
return phone.getMicMuteStatus();
|
|
22373
|
-
},
|
|
22374
|
-
|
|
22375
|
-
muteAction: (bMute) => {
|
|
22376
|
-
phone.sipMute(bMute);
|
|
22377
|
-
},
|
|
22378
|
-
|
|
22379
|
-
holdAction: (bHold) => {
|
|
22380
|
-
phone.sipHold(bHold);
|
|
22381
|
-
},
|
|
22382
|
-
|
|
22383
|
-
holdCall: () => {
|
|
22384
|
-
phone.holdCall();
|
|
22385
|
-
},
|
|
22386
|
-
|
|
22387
|
-
pickCall: () => {
|
|
22388
|
-
phone.pickPhoneCall();
|
|
22389
|
-
|
|
22390
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].onPickCall();
|
|
22391
|
-
},
|
|
22610
|
+
logger.log("webrtcSIPPhone: setAuthenticatorServerURL : ",serverURL);
|
|
22611
|
+
}
|
|
22392
22612
|
|
|
22393
|
-
|
|
22394
|
-
|
|
22613
|
+
toggleSipRegister (){
|
|
22614
|
+
logger.log("webrtcSIPPhone: toggleSipRegister entry");
|
|
22615
|
+
this.phone.resetRegisterAttempts();
|
|
22616
|
+
this.phone.sipToggleRegister();
|
|
22617
|
+
}
|
|
22395
22618
|
|
|
22396
|
-
|
|
22397
|
-
|
|
22619
|
+
webRTCMuteUnmute (){
|
|
22620
|
+
logger.log("webrtcSIPPhone: webRTCMuteUnmute");
|
|
22621
|
+
this.phone.sipToggleMic();
|
|
22622
|
+
}
|
|
22398
22623
|
|
|
22399
|
-
|
|
22400
|
-
|
|
22401
|
-
|
|
22624
|
+
getMuteStatus (){
|
|
22625
|
+
logger.log("webrtcSIPPhone: getMuteStatus entry");
|
|
22626
|
+
return this.phone.getMicMuteStatus();
|
|
22627
|
+
}
|
|
22402
22628
|
|
|
22629
|
+
muteAction (bMute){
|
|
22630
|
+
logger.log("webrtcSIPPhone: muteAction: ",bMute);
|
|
22631
|
+
this.phone.sipMute(bMute);
|
|
22632
|
+
}
|
|
22403
22633
|
|
|
22404
|
-
|
|
22405
|
-
|
|
22634
|
+
holdAction (bHold){
|
|
22635
|
+
logger.log("webrtcSIPPhone: holdAction: ",bHold);
|
|
22636
|
+
this.phone.sipHold(bHold);
|
|
22637
|
+
}
|
|
22406
22638
|
|
|
22407
|
-
|
|
22639
|
+
holdCall (){
|
|
22640
|
+
logger.log("webrtcSIPPhone: holdCall entry");
|
|
22641
|
+
this.phone.holdCall();
|
|
22642
|
+
}
|
|
22408
22643
|
|
|
22409
|
-
|
|
22410
|
-
|
|
22411
|
-
|
|
22644
|
+
pickCall (){
|
|
22645
|
+
logger.log("webrtcSIPPhone: pickCall entry");
|
|
22646
|
+
this.phone.pickPhoneCall();
|
|
22412
22647
|
|
|
22413
|
-
|
|
22414
|
-
|
|
22415
|
-
phone.sipRegister();
|
|
22416
|
-
},
|
|
22648
|
+
this.webrtcSIPPhoneEventDelegate.onPickCall();
|
|
22649
|
+
}
|
|
22417
22650
|
|
|
22418
|
-
|
|
22419
|
-
|
|
22420
|
-
|
|
22651
|
+
rejectCall (){
|
|
22652
|
+
logger.log("webrtcSIPPhone: rejectCall entry");
|
|
22653
|
+
this.phone.sipHangUp();
|
|
22421
22654
|
|
|
22655
|
+
this.webrtcSIPPhoneEventDelegate.onRejectCall();
|
|
22656
|
+
}
|
|
22422
22657
|
|
|
22658
|
+
reRegisterWebRTCPhone (){
|
|
22659
|
+
logger.log("webrtcSIPPhone: reRegisterWebRTCPhone entry");
|
|
22660
|
+
this.phone.reRegister();
|
|
22661
|
+
}
|
|
22423
22662
|
|
|
22424
|
-
|
|
22425
|
-
|
|
22426
|
-
|
|
22427
|
-
|
|
22428
|
-
phone = _sipjsphone__WEBPACK_IMPORTED_MODULE_1__["default"];
|
|
22429
|
-
break;
|
|
22430
|
-
default:
|
|
22431
|
-
break;
|
|
22432
|
-
}
|
|
22433
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].registerDelegate(delegate);
|
|
22434
|
-
_webrtcSIPPhoneEventDelegate__WEBPACK_IMPORTED_MODULE_2__["default"].onRegisterWebRTCSIPEngine(engine);
|
|
22663
|
+
playBeepTone (){
|
|
22664
|
+
logger.log("webrtcSIPPhone: playBeepTone entry");
|
|
22665
|
+
this.phone.playBeep();
|
|
22666
|
+
}
|
|
22435
22667
|
|
|
22668
|
+
sipUnRegisterWebRTC (){
|
|
22669
|
+
logger.log("webrtcSIPPhone: sipUnRegisterWebRTC entry");
|
|
22670
|
+
this.phone.sipUnRegister();
|
|
22671
|
+
}
|
|
22436
22672
|
|
|
22437
|
-
|
|
22673
|
+
startWSNetworkTest (){
|
|
22674
|
+
logger.log("webrtcSIPPhone: startWSNetworkTest entry");
|
|
22675
|
+
this.testingMode = true;
|
|
22676
|
+
this.phone.sipRegister();
|
|
22677
|
+
}
|
|
22438
22678
|
|
|
22439
|
-
|
|
22440
|
-
|
|
22441
|
-
|
|
22442
|
-
}
|
|
22679
|
+
stopWSNetworkTest (){
|
|
22680
|
+
logger.log("webrtcSIPPhone stopWSNetworkTest entry");
|
|
22681
|
+
this.phone.sipUnRegister();
|
|
22682
|
+
}
|
|
22443
22683
|
|
|
22444
|
-
disconnect
|
|
22445
|
-
|
|
22446
|
-
|
|
22684
|
+
disconnect (){
|
|
22685
|
+
logger.log("webrtcSIPPhone: disconnect entry");
|
|
22686
|
+
if (this.phone) {
|
|
22687
|
+
this.phone.disconnect();
|
|
22447
22688
|
}
|
|
22448
|
-
}
|
|
22689
|
+
}
|
|
22449
22690
|
|
|
22450
|
-
connect
|
|
22451
|
-
|
|
22452
|
-
|
|
22691
|
+
connect (){
|
|
22692
|
+
logger.log("webrtcSIPPhone: connect entry");
|
|
22693
|
+
this.phone.connect();
|
|
22694
|
+
}
|
|
22453
22695
|
|
|
22454
22696
|
getSIPAccountInfo() {
|
|
22455
|
-
|
|
22456
|
-
|
|
22697
|
+
logger.log("webrtcSIPPhone: getSIPAccountInfo entry");
|
|
22698
|
+
return this.sipAccountInfoData;
|
|
22699
|
+
}
|
|
22700
|
+
|
|
22457
22701
|
getWebRTCSIPEngine() {
|
|
22458
|
-
|
|
22459
|
-
|
|
22702
|
+
logger.log("webrtcSIPPhone: getWebRTCSIPEngine entry");
|
|
22703
|
+
return this.webrtcSIPEngine;
|
|
22704
|
+
}
|
|
22460
22705
|
|
|
22461
22706
|
/* NL Addition - Start */
|
|
22462
22707
|
getSpeakerTestTone() {
|
|
22708
|
+
logger.log("webrtcSIPPhone: getSpeakerTestTone entry");
|
|
22463
22709
|
try {
|
|
22464
|
-
return
|
|
22710
|
+
return this.phone.getSpeakerTestTone()
|
|
22465
22711
|
} catch (e) {
|
|
22466
22712
|
logger.log("getSpeakerTestTone: Exception ", e)
|
|
22467
22713
|
}
|
|
22468
|
-
}
|
|
22714
|
+
}
|
|
22469
22715
|
|
|
22470
22716
|
getWSSUrl() {
|
|
22717
|
+
logger.log("webrtcSIPPhone: getWSSUrl entry");
|
|
22471
22718
|
try {
|
|
22472
|
-
return
|
|
22719
|
+
return this.phone.getWSSUrl()
|
|
22473
22720
|
} catch (e) {
|
|
22474
22721
|
logger.log("getWSSUrl: Exception ", e)
|
|
22475
22722
|
}
|
|
22476
|
-
}
|
|
22477
|
-
/* NL Addition - End */
|
|
22723
|
+
}
|
|
22478
22724
|
|
|
22479
22725
|
getTransportState() {
|
|
22726
|
+
logger.log("webrtcSIPPhone: getTransportState entry");
|
|
22480
22727
|
try {
|
|
22481
|
-
return
|
|
22728
|
+
return this.phone.getTransportState();
|
|
22482
22729
|
} catch (e) {
|
|
22483
22730
|
logger.log("getTransportState: Exception ", e);
|
|
22484
22731
|
return "unknown";
|
|
22485
22732
|
}
|
|
22486
|
-
}
|
|
22733
|
+
}
|
|
22487
22734
|
|
|
22488
22735
|
getRegistrationState() {
|
|
22736
|
+
logger.log("webrtcSIPPhone: getRegistrationState entry");
|
|
22489
22737
|
try {
|
|
22490
|
-
return
|
|
22738
|
+
return this.phone.getRegistrationState();
|
|
22491
22739
|
} catch (e) {
|
|
22492
22740
|
logger.log("getTransportState: Exception ", e);
|
|
22493
22741
|
return "unknown";
|
|
22494
22742
|
}
|
|
22495
|
-
}
|
|
22743
|
+
}
|
|
22496
22744
|
|
|
22497
22745
|
changeAudioInputDevice(deviceId, onSuccess, onError) {
|
|
22498
|
-
logger.log(
|
|
22499
|
-
|
|
22500
|
-
}
|
|
22746
|
+
logger.log("webrtcSIPPhone: changeAudioInputDevice : ", deviceId, onSuccess, onError);
|
|
22747
|
+
this.phone.changeAudioInputDevice(deviceId, onSuccess, onError);
|
|
22748
|
+
}
|
|
22501
22749
|
|
|
22502
22750
|
changeAudioOutputDevice(deviceId, onSuccess, onError) {
|
|
22503
|
-
logger.log(
|
|
22504
|
-
|
|
22505
|
-
},
|
|
22506
|
-
setPreferredCodec(codecName) {
|
|
22507
|
-
logger.log("webrtcSIPPhone:setPreferredCodec entry");
|
|
22508
|
-
_sipjsphone__WEBPACK_IMPORTED_MODULE_1__["default"].setPreferredCodec(codecName);
|
|
22509
|
-
},
|
|
22510
|
-
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback) {
|
|
22511
|
-
logger.log(`webrtcSIPPhone:registerAudioDeviceChangeCallback entry`);
|
|
22512
|
-
_sipjsphone__WEBPACK_IMPORTED_MODULE_1__["default"].registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback);
|
|
22513
|
-
},
|
|
22514
|
-
getLogger() {
|
|
22515
|
-
return _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
22751
|
+
logger.log("webrtcSIPPhone: changeAudioOutputDevice : ", deviceId, onSuccess, onError);
|
|
22752
|
+
this.phone.changeAudioOutputDevice(deviceId, onSuccess, onError);
|
|
22516
22753
|
}
|
|
22517
22754
|
|
|
22518
|
-
|
|
22519
|
-
|
|
22755
|
+
setPreferredCodec(codecName) {
|
|
22756
|
+
logger.log("webrtcSIPPhone: setPreferredCodec : ", codecName);
|
|
22757
|
+
this.phone.setPreferredCodec(codecName);
|
|
22758
|
+
}
|
|
22520
22759
|
|
|
22521
|
-
|
|
22760
|
+
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback) {
|
|
22761
|
+
logger.log("webrtcSIPPhone: registerAudioDeviceChangeCallback entry");
|
|
22762
|
+
this.phone.registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback);
|
|
22763
|
+
}
|
|
22764
|
+
}
|
|
22522
22765
|
|
|
22766
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (WebrtcSIPPhone);
|
|
22523
22767
|
|
|
22524
22768
|
/***/ }),
|
|
22525
22769
|
|
|
@@ -22534,183 +22778,306 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
22534
22778
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
22535
22779
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
22536
22780
|
/* harmony export */ });
|
|
22537
|
-
/*
|
|
22538
|
-
* delegate listener , webrtc sip phone could invoke events to delegate and it will further send event to registered delegator
|
|
22539
|
-
*/
|
|
22540
|
-
let testingMode = false;
|
|
22541
|
-
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");
|
|
22542
22782
|
|
|
22543
22783
|
|
|
22544
|
-
const
|
|
22545
|
-
|
|
22546
|
-
registerDelegate : (webrtcDelegate) => {
|
|
22547
|
-
delegate = webrtcDelegate;
|
|
22548
|
-
},
|
|
22784
|
+
const logger = _coreSDKLogger__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
22549
22785
|
|
|
22550
|
-
|
|
22551
|
-
if(delegate) {
|
|
22552
|
-
delegate.setTestingMode(mode);
|
|
22553
|
-
}
|
|
22554
|
-
},
|
|
22555
|
-
|
|
22556
|
-
onCallStatSipJsSessionEvent : (ev) => {
|
|
22557
|
-
if(delegate) {
|
|
22558
|
-
delegate.onCallStatSipJsSessionEvent(ev);
|
|
22559
|
-
}
|
|
22560
|
-
},
|
|
22561
|
-
|
|
22562
|
-
sendWebRTCEventsToFSM : (eventType, sipMethod) => {
|
|
22563
|
-
if(delegate) {
|
|
22564
|
-
delegate.sendWebRTCEventsToFSM(eventType, sipMethod);
|
|
22565
|
-
}
|
|
22566
|
-
},
|
|
22567
|
-
|
|
22568
|
-
playBeepTone : () => {
|
|
22569
|
-
if(delegate) {
|
|
22570
|
-
delegate.playBeepTone();
|
|
22571
|
-
}
|
|
22572
|
-
},
|
|
22573
|
-
|
|
22574
|
-
onStatPeerConnectionIceGatheringStateChange: (iceGatheringState) => {
|
|
22575
|
-
if(delegate) {
|
|
22576
|
-
delegate.onStatPeerConnectionIceGatheringStateChange(iceGatheringState);
|
|
22577
|
-
}
|
|
22578
|
-
},
|
|
22579
|
-
|
|
22580
|
-
onCallStatIceCandidate: (ev, icestate) => {
|
|
22581
|
-
if(delegate) {
|
|
22582
|
-
delegate.onCallStatIceCandidate(ev,icestate);
|
|
22583
|
-
}
|
|
22584
|
-
},
|
|
22585
|
-
|
|
22586
|
-
|
|
22587
|
-
onCallStatNegoNeeded: (icestate) => {
|
|
22588
|
-
if(delegate) {
|
|
22589
|
-
delegate.onCallStatNegoNeeded(icestate);
|
|
22590
|
-
}
|
|
22591
|
-
},
|
|
22786
|
+
class WebrtcSIPPhoneEventDelegate {
|
|
22592
22787
|
|
|
22593
|
-
|
|
22594
|
-
|
|
22595
|
-
|
|
22596
|
-
|
|
22597
|
-
}
|
|
22788
|
+
constructor(username) {
|
|
22789
|
+
this.username = username;
|
|
22790
|
+
this._listeners = new Map();
|
|
22791
|
+
this.delegates = new Set();
|
|
22792
|
+
}
|
|
22598
22793
|
|
|
22599
|
-
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
|
|
22604
|
-
},
|
|
22605
|
-
|
|
22606
|
-
|
|
22607
|
-
onStatPeerConnectionConnectionStateChange: () => {
|
|
22608
|
-
if(delegate) {
|
|
22609
|
-
delegate.onStatPeerConnectionConnectionStateChange();
|
|
22610
|
-
}
|
|
22611
|
-
},
|
|
22612
|
-
|
|
22613
|
-
onGetUserMediaSuccessCallstatCallback: () => {
|
|
22614
|
-
if(delegate) {
|
|
22615
|
-
delegate.onGetUserMediaSuccessCallstatCallback();
|
|
22616
|
-
}
|
|
22617
|
-
},
|
|
22794
|
+
/**
|
|
22795
|
+
* @param {string} event
|
|
22796
|
+
* @param {Function} handler
|
|
22797
|
+
* @returns {Function}
|
|
22798
|
+
*/
|
|
22618
22799
|
|
|
22619
|
-
|
|
22620
|
-
if(
|
|
22621
|
-
|
|
22800
|
+
attach(event, handler) {
|
|
22801
|
+
if (!this._listeners.has(event)) {
|
|
22802
|
+
this._listeners.set(event, new Set());
|
|
22622
22803
|
}
|
|
22623
|
-
|
|
22624
|
-
|
|
22625
|
-
|
|
22626
|
-
onCallStatAddStream: () => {
|
|
22627
|
-
if(delegate) {
|
|
22628
|
-
delegate.onCallStatAddStream();
|
|
22629
|
-
}
|
|
22630
|
-
},
|
|
22804
|
+
this._listeners.get(event).add(handler);
|
|
22631
22805
|
|
|
22632
|
-
|
|
22633
|
-
|
|
22634
|
-
delegate.onCallStatRemoveStream();
|
|
22635
|
-
}
|
|
22636
|
-
},
|
|
22637
|
-
|
|
22638
|
-
setWebRTCFSMMapper : () => {
|
|
22639
|
-
if(delegate) {
|
|
22640
|
-
delegate.setWebRTCFSMMapper();
|
|
22641
|
-
}
|
|
22642
|
-
},
|
|
22643
|
-
|
|
22644
|
-
onCallStatSipJsTransportEvent : () => {
|
|
22645
|
-
if(delegate) {
|
|
22646
|
-
delegate.onCallStatSipJsTransportEvent();
|
|
22647
|
-
}
|
|
22648
|
-
},
|
|
22649
|
-
|
|
22650
|
-
onCallStatSipSendCallback: (tsipData, sipStack) => {
|
|
22651
|
-
if(delegate) {
|
|
22652
|
-
delegate.onCallStatSipSendCallback();
|
|
22653
|
-
}
|
|
22654
|
-
},
|
|
22806
|
+
return () => this._listeners.get(event)?.delete(handler);
|
|
22807
|
+
}
|
|
22655
22808
|
|
|
22656
|
-
|
|
22657
|
-
|
|
22658
|
-
|
|
22659
|
-
|
|
22660
|
-
|
|
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
|
+
}
|
|
22661
22818
|
|
|
22662
|
-
|
|
22663
|
-
|
|
22664
|
-
|
|
22665
|
-
}
|
|
22666
|
-
},
|
|
22667
|
-
|
|
22668
|
-
onRecieveInvite: (incomingSession) => {
|
|
22669
|
-
if(delegate) {
|
|
22670
|
-
delegate.onRecieveInvite(incomingSession);
|
|
22671
|
-
}
|
|
22672
|
-
},
|
|
22673
|
-
|
|
22674
|
-
onPickCall: () => {
|
|
22675
|
-
if(delegate) {
|
|
22676
|
-
delegate.onPickCall();
|
|
22677
|
-
}
|
|
22678
|
-
},
|
|
22819
|
+
registerDelegate(webrtcDelegate) {
|
|
22820
|
+
this.delegates.add(webrtcDelegate);
|
|
22821
|
+
}
|
|
22679
22822
|
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
}
|
|
22684
|
-
},
|
|
22685
|
-
|
|
22686
|
-
onCreaterAnswer: () => {
|
|
22687
|
-
if(delegate) {
|
|
22688
|
-
delegate.onCreaterAnswer();
|
|
22689
|
-
}
|
|
22690
|
-
},
|
|
22823
|
+
unregisterDelegate(webrtcDelegate) {
|
|
22824
|
+
this.delegates.delete(webrtcDelegate);
|
|
22825
|
+
}
|
|
22691
22826
|
|
|
22692
|
-
|
|
22693
|
-
|
|
22694
|
-
delegate.
|
|
22695
|
-
|
|
22696
|
-
|
|
22827
|
+
setTestingMode(mode) {
|
|
22828
|
+
this.delegates.forEach(delegate => {
|
|
22829
|
+
if (delegate && typeof delegate.setTestingMode === 'function') {
|
|
22830
|
+
delegate.setTestingMode(mode);
|
|
22831
|
+
}
|
|
22832
|
+
});
|
|
22833
|
+
}
|
|
22697
22834
|
|
|
22698
|
-
|
|
22699
|
-
|
|
22700
|
-
delegate.
|
|
22701
|
-
|
|
22702
|
-
|
|
22703
|
-
|
|
22704
|
-
|
|
22705
|
-
|
|
22706
|
-
|
|
22707
|
-
|
|
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);
|
|
22708
23028
|
}
|
|
22709
|
-
|
|
22710
|
-
|
|
22711
23029
|
}
|
|
22712
23030
|
|
|
22713
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (
|
|
23031
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (WebrtcSIPPhoneEventDelegate);
|
|
23032
|
+
|
|
23033
|
+
/***/ }),
|
|
23034
|
+
|
|
23035
|
+
/***/ "./src/api/LogManager.js":
|
|
23036
|
+
/*!*******************************!*\
|
|
23037
|
+
!*** ./src/api/LogManager.js ***!
|
|
23038
|
+
\*******************************/
|
|
23039
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
23040
|
+
|
|
23041
|
+
"use strict";
|
|
23042
|
+
__webpack_require__.r(__webpack_exports__);
|
|
23043
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23044
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
23045
|
+
/* harmony export */ });
|
|
23046
|
+
const MAX_LOG_LINES = 1000;
|
|
23047
|
+
const LOG_STORAGE_KEY = 'webrtc_sdk_logs';
|
|
23048
|
+
const LogManager = {
|
|
23049
|
+
onLog(level, msg, args = []) {
|
|
23050
|
+
const timestamp = new Date().toISOString();
|
|
23051
|
+
const line = `[${timestamp}] [${level.toUpperCase()}] ${msg} ${args.map(arg => JSON.stringify(arg)).join(" ")}`.trim();
|
|
23052
|
+
let logs = JSON.parse(localStorage.getItem(LOG_STORAGE_KEY)) || [];
|
|
23053
|
+
logs.push(line);
|
|
23054
|
+
if (logs.length > MAX_LOG_LINES) {
|
|
23055
|
+
logs = logs.slice(-MAX_LOG_LINES); // rotate
|
|
23056
|
+
}
|
|
23057
|
+
|
|
23058
|
+
localStorage.setItem(LOG_STORAGE_KEY, JSON.stringify(logs));
|
|
23059
|
+
},
|
|
23060
|
+
getLogs() {
|
|
23061
|
+
return JSON.parse(localStorage.getItem(LOG_STORAGE_KEY)) || [];
|
|
23062
|
+
},
|
|
23063
|
+
downloadLogs(filename) {
|
|
23064
|
+
if (!filename) {
|
|
23065
|
+
const now = new Date();
|
|
23066
|
+
const formattedDate = now.toISOString().split('T')[0]; // Gets YYYY-MM-DD
|
|
23067
|
+
filename = `webrtc_sdk_logs_${formattedDate}.txt`;
|
|
23068
|
+
}
|
|
23069
|
+
const blob = new Blob([LogManager.getLogs().join('\n')], {
|
|
23070
|
+
type: 'text/plain'
|
|
23071
|
+
});
|
|
23072
|
+
const url = URL.createObjectURL(blob);
|
|
23073
|
+
const a = document.createElement('a');
|
|
23074
|
+
a.href = url;
|
|
23075
|
+
a.download = filename;
|
|
23076
|
+
a.click();
|
|
23077
|
+
URL.revokeObjectURL(url);
|
|
23078
|
+
}
|
|
23079
|
+
};
|
|
23080
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (LogManager);
|
|
22714
23081
|
|
|
22715
23082
|
/***/ }),
|
|
22716
23083
|
|
|
@@ -22729,52 +23096,62 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
22729
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");
|
|
22730
23097
|
|
|
22731
23098
|
|
|
22732
|
-
|
|
22733
|
-
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
|
+
}
|
|
22734
23104
|
this.Answer = function () {
|
|
22735
23105
|
/**
|
|
22736
23106
|
* When agent accepts phone, add appropriate msg to be sent to webclient
|
|
22737
23107
|
*/
|
|
22738
23108
|
logger.log('Call answered');
|
|
22739
|
-
|
|
23109
|
+
webrtcSIPPhone.pickCall();
|
|
22740
23110
|
};
|
|
22741
23111
|
this.Hangup = function () {
|
|
22742
23112
|
/**
|
|
22743
23113
|
* When call is terminated
|
|
22744
23114
|
*/
|
|
22745
23115
|
logger.log('call ended');
|
|
22746
|
-
|
|
23116
|
+
webrtcSIPPhone.rejectCall();
|
|
22747
23117
|
};
|
|
22748
23118
|
this.MuteToggle = function () {
|
|
22749
23119
|
/**
|
|
22750
23120
|
* When agent clicks on mute
|
|
22751
23121
|
*/
|
|
22752
|
-
logger.log('
|
|
22753
|
-
|
|
22754
|
-
_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_1__.webrtcSIPPhone.webRTCMuteUnmute(null);
|
|
23122
|
+
logger.log('Call: MuteToggle');
|
|
23123
|
+
webrtcSIPPhone.webRTCMuteUnmute();
|
|
22755
23124
|
};
|
|
22756
23125
|
this.Mute = function () {
|
|
22757
23126
|
/**
|
|
22758
23127
|
* When agent clicks on mute
|
|
22759
23128
|
*/
|
|
22760
|
-
|
|
22761
|
-
|
|
22762
|
-
|
|
23129
|
+
var isMuted = webrtcSIPPhone.getMuteStatus();
|
|
23130
|
+
logger.log('Call: Mute: isMuted: ', isMuted);
|
|
23131
|
+
if (!isMuted) {
|
|
23132
|
+
webrtcSIPPhone.muteAction(true);
|
|
23133
|
+
} else {
|
|
23134
|
+
logger.log('Call: Mute: Already muted');
|
|
23135
|
+
}
|
|
22763
23136
|
};
|
|
22764
23137
|
this.UnMute = function () {
|
|
22765
23138
|
/**
|
|
22766
|
-
* When agent clicks on
|
|
23139
|
+
* When agent clicks on unmute
|
|
22767
23140
|
*/
|
|
22768
|
-
|
|
22769
|
-
|
|
22770
|
-
|
|
23141
|
+
var isMuted = webrtcSIPPhone.getMuteStatus();
|
|
23142
|
+
logger.log('Call: UnMute: isMuted: ', isMuted);
|
|
23143
|
+
if (isMuted) {
|
|
23144
|
+
webrtcSIPPhone.muteAction(false);
|
|
23145
|
+
} else {
|
|
23146
|
+
logger.log('Call: UnMute: Already unmuted');
|
|
23147
|
+
}
|
|
22771
23148
|
};
|
|
22772
23149
|
this.HoldToggle = function () {
|
|
22773
23150
|
/**
|
|
22774
23151
|
* When user clicks on hold
|
|
22775
23152
|
*/
|
|
22776
23153
|
logger.log('Hold toggle clicked');
|
|
22777
|
-
|
|
23154
|
+
webrtcSIPPhone.holdCall();
|
|
22778
23155
|
};
|
|
22779
23156
|
this.Hold = function () {
|
|
22780
23157
|
/**
|
|
@@ -22782,7 +23159,7 @@ function Call() {
|
|
|
22782
23159
|
*/
|
|
22783
23160
|
logger.log('hold clicked');
|
|
22784
23161
|
let dummyFlag = true;
|
|
22785
|
-
|
|
23162
|
+
webrtcSIPPhone.holdCall();
|
|
22786
23163
|
};
|
|
22787
23164
|
this.UnHold = function () {
|
|
22788
23165
|
/**
|
|
@@ -22790,7 +23167,7 @@ function Call() {
|
|
|
22790
23167
|
*/
|
|
22791
23168
|
logger.log('unhold clicked');
|
|
22792
23169
|
let dummyFlag = true;
|
|
22793
|
-
|
|
23170
|
+
webrtcSIPPhone.holdCall();
|
|
22794
23171
|
};
|
|
22795
23172
|
this.callDetails = function () {
|
|
22796
23173
|
/**
|
|
@@ -22803,7 +23180,7 @@ function Call() {
|
|
|
22803
23180
|
* sends dtmf digit as SIP info over websocket
|
|
22804
23181
|
*/
|
|
22805
23182
|
logger.log("trying to send dtmf " + digit);
|
|
22806
|
-
|
|
23183
|
+
webrtcSIPPhone.sendDTMFWebRTC(digit);
|
|
22807
23184
|
};
|
|
22808
23185
|
}
|
|
22809
23186
|
|
|
@@ -22908,13 +23285,14 @@ var CallDetails = {
|
|
|
22908
23285
|
"use strict";
|
|
22909
23286
|
__webpack_require__.r(__webpack_exports__);
|
|
22910
23287
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23288
|
+
/* harmony export */ Diagnostics: () => (/* binding */ Diagnostics),
|
|
22911
23289
|
/* harmony export */ ameyoWebRTCTroubleshooter: () => (/* binding */ ameyoWebRTCTroubleshooter)
|
|
22912
23290
|
/* harmony export */ });
|
|
22913
|
-
/* harmony import */ var
|
|
22914
|
-
/* 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");
|
|
22915
23293
|
|
|
22916
23294
|
|
|
22917
|
-
|
|
23295
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.getLogger)();
|
|
22918
23296
|
var speakerNode;
|
|
22919
23297
|
var micNode;
|
|
22920
23298
|
var audioTrack;
|
|
@@ -22936,6 +23314,18 @@ eventMapper.sipml5.transport_error = "WS_TEST_FAIL";
|
|
|
22936
23314
|
eventMapper.sipml5.connected_REGISTER = "USER_REG_TEST_PASS";
|
|
22937
23315
|
eventMapper.sipml5.terminated_REGISTER = "USER_REG_TEST_FAIL";
|
|
22938
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
|
+
}
|
|
22939
23329
|
var ameyoWebRTCTroubleshooter = {
|
|
22940
23330
|
js_yyyy_mm_dd_hh_mm_ss: function () {
|
|
22941
23331
|
var now = new Date();
|
|
@@ -22974,7 +23364,7 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
22974
23364
|
msg = oldMsg + msg;
|
|
22975
23365
|
}
|
|
22976
23366
|
window.localStorage.setItem('troubleShootReport', msg);
|
|
22977
|
-
|
|
23367
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerDiagnosticsSaveCallback('troubleShootReport', msg);
|
|
22978
23368
|
//}
|
|
22979
23369
|
},
|
|
22980
23370
|
|
|
@@ -23027,29 +23417,40 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23027
23417
|
}
|
|
23028
23418
|
return browserName + "/" + version;
|
|
23029
23419
|
},
|
|
23030
|
-
stopSpeakerTesttone: function () {
|
|
23031
|
-
|
|
23420
|
+
stopSpeakerTesttone: function (webrtcSIPPhone) {
|
|
23421
|
+
if (!webrtcSIPPhone) {
|
|
23422
|
+
logger.log("stopSpeakerTesttone: webrtcSIPPhone not provided");
|
|
23423
|
+
return;
|
|
23424
|
+
}
|
|
23425
|
+
speakerTestTone = webrtcSIPPhone.getSpeakerTestTone();
|
|
23032
23426
|
speakerTestTone.pause();
|
|
23033
23427
|
},
|
|
23034
|
-
stopSpeakerTesttoneWithSuccess: function () {
|
|
23035
|
-
this.stopSpeakerTest();
|
|
23428
|
+
stopSpeakerTesttoneWithSuccess: function (webrtcSIPPhone) {
|
|
23429
|
+
this.stopSpeakerTest(webrtcSIPPhone);
|
|
23036
23430
|
this.sendDeviceTestingEvent("SPEAKER_TEST_PASS");
|
|
23037
23431
|
this.addToTrobuleshootReport("INFO", "Speaker device testing is successfull");
|
|
23038
23432
|
this.addToTrobuleshootReport("INFO", "Speaker device testing is completed");
|
|
23039
23433
|
},
|
|
23040
|
-
stopSpeakerTesttoneWithFailure: function () {
|
|
23041
|
-
this.stopSpeakerTest();
|
|
23434
|
+
stopSpeakerTesttoneWithFailure: function (webrtcSIPPhone) {
|
|
23435
|
+
this.stopSpeakerTest(webrtcSIPPhone);
|
|
23042
23436
|
this.sendDeviceTestingEvent("SPEAKER_TEST_FAIL");
|
|
23043
23437
|
this.addToTrobuleshootReport("INFO", "Speaker device testing is failed");
|
|
23044
23438
|
this.addToTrobuleshootReport("INFO", "Speaker device testing is completed");
|
|
23045
23439
|
},
|
|
23046
|
-
startSpeakerTest: function () {
|
|
23440
|
+
startSpeakerTest: function (webrtcSIPPhone) {
|
|
23047
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
|
+
}
|
|
23048
23450
|
try {
|
|
23049
23451
|
intervalID = setInterval(function () {
|
|
23050
23452
|
try {
|
|
23051
|
-
speakerTestTone =
|
|
23052
|
-
/* Close last pending tracks.. */
|
|
23453
|
+
speakerTestTone = webrtcSIPPhone.getSpeakerTestTone();
|
|
23053
23454
|
logger.log("close last track");
|
|
23054
23455
|
speakerTestTone.pause();
|
|
23055
23456
|
parent.closeAudioTrack();
|
|
@@ -23096,14 +23497,18 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23096
23497
|
//Enable this for tone loop - End
|
|
23097
23498
|
},
|
|
23098
23499
|
|
|
23099
|
-
stopSpeakerTest: function () {
|
|
23500
|
+
stopSpeakerTest: function (webrtcSIPPhone) {
|
|
23100
23501
|
var parent = this;
|
|
23101
|
-
|
|
23102
|
-
|
|
23502
|
+
if (!webrtcSIPPhone) {
|
|
23503
|
+
logger.log("stopSpeakerTest: webrtcSIPPhone not provided");
|
|
23504
|
+
return;
|
|
23505
|
+
}
|
|
23506
|
+
speakerTestTone = webrtcSIPPhone.getSpeakerTestTone();
|
|
23103
23507
|
try {
|
|
23104
|
-
|
|
23105
|
-
|
|
23106
|
-
|
|
23508
|
+
if (intervalID) {
|
|
23509
|
+
clearInterval(intervalID);
|
|
23510
|
+
intervalID = 0;
|
|
23511
|
+
}
|
|
23107
23512
|
speakerTestTone.pause();
|
|
23108
23513
|
parent.closeAudioTrack();
|
|
23109
23514
|
parent.addToTrobuleshootReport("INFO", "Speaker device testing is stopped");
|
|
@@ -23170,10 +23575,10 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23170
23575
|
if (deviceInfos[i].deviceId == "default") {
|
|
23171
23576
|
if (deviceInfos[i].kind == "audiooutput") {
|
|
23172
23577
|
var speakerName = deviceInfos[i].label;
|
|
23173
|
-
|
|
23578
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("speakerInfo", deviceInfos[i].label, "speakerInfo");
|
|
23174
23579
|
} else if (deviceInfos[i].kind == "audioinput") {
|
|
23175
23580
|
var micName = deviceInfos[i].label;
|
|
23176
|
-
|
|
23581
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("micInfo", deviceInfos[i].label, "micInfo");
|
|
23177
23582
|
}
|
|
23178
23583
|
}
|
|
23179
23584
|
}
|
|
@@ -23217,7 +23622,7 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23217
23622
|
}
|
|
23218
23623
|
var average = values / length;
|
|
23219
23624
|
//diagnosticsCallback.triggerDiagnosticsMicStatusCallback(average, "mic ok");
|
|
23220
|
-
|
|
23625
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("mic", average, "mic ok");
|
|
23221
23626
|
if (average > 9) {
|
|
23222
23627
|
//fillMicColors(Math.round(average));
|
|
23223
23628
|
}
|
|
@@ -23226,7 +23631,7 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23226
23631
|
logger.log("Media source not available for mic test ..");
|
|
23227
23632
|
average = 0;
|
|
23228
23633
|
//diagnosticsCallback.triggerDiagnosticsMicStatusCallback(average, "mic error");
|
|
23229
|
-
|
|
23634
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("mic", average, "mic error");
|
|
23230
23635
|
}
|
|
23231
23636
|
},
|
|
23232
23637
|
fillStreamSpeaker: function (stream, outDevice) {
|
|
@@ -23249,21 +23654,20 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23249
23654
|
values += array[i];
|
|
23250
23655
|
}
|
|
23251
23656
|
var average = values / length;
|
|
23252
|
-
|
|
23657
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("speaker", average, "speaker ok");
|
|
23253
23658
|
};
|
|
23254
23659
|
} catch (e) {
|
|
23255
23660
|
logger.log("Media source not available for speaker test ..");
|
|
23256
23661
|
average = 0;
|
|
23257
|
-
|
|
23662
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback("speaker", average, "speaker error");
|
|
23258
23663
|
}
|
|
23259
23664
|
},
|
|
23260
23665
|
setUserRegTroubleshootData: function (txtUser) {
|
|
23261
23666
|
logger.log("No explicit registration sent during testing...");
|
|
23262
23667
|
},
|
|
23263
|
-
setWSTroubleshootData: function (txtWsStatus) {
|
|
23264
|
-
|
|
23265
|
-
|
|
23266
|
-
_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);
|
|
23267
23671
|
},
|
|
23268
23672
|
startWSAndUserRegistrationTest: function () {
|
|
23269
23673
|
try {
|
|
@@ -23294,7 +23698,7 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23294
23698
|
},
|
|
23295
23699
|
setTroubleshootCandidateData: function (key, status, value) {
|
|
23296
23700
|
logger.log("Candidate Data \n\t key = " + key + " status = " + status + "\n\tValue = " + value + "\n\n");
|
|
23297
|
-
|
|
23701
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.triggerKeyValueSetCallback(key, status, value);
|
|
23298
23702
|
},
|
|
23299
23703
|
startCandidatesForTroubleshoot: function () {
|
|
23300
23704
|
var keys = ["udp", "tcp", "ipv6", "host", "srflx"];
|
|
@@ -23441,6 +23845,7 @@ var ameyoWebRTCTroubleshooter = {
|
|
|
23441
23845
|
"use strict";
|
|
23442
23846
|
__webpack_require__.r(__webpack_exports__);
|
|
23443
23847
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23848
|
+
/* harmony export */ DiagnosticsListener: () => (/* binding */ DiagnosticsListener),
|
|
23444
23849
|
/* harmony export */ closeDiagnostics: () => (/* binding */ closeDiagnostics),
|
|
23445
23850
|
/* harmony export */ initDiagnostics: () => (/* binding */ initDiagnostics),
|
|
23446
23851
|
/* harmony export */ startMicDiagnosticsTest: () => (/* binding */ startMicDiagnosticsTest),
|
|
@@ -23450,49 +23855,49 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23450
23855
|
/* harmony export */ stopNetworkDiagnostics: () => (/* binding */ stopNetworkDiagnostics),
|
|
23451
23856
|
/* harmony export */ stopSpeakerDiagnosticsTest: () => (/* binding */ stopSpeakerDiagnosticsTest)
|
|
23452
23857
|
/* harmony export */ });
|
|
23453
|
-
/* harmony import */ var
|
|
23454
|
-
/* harmony import */ var
|
|
23455
|
-
/* 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");
|
|
23456
23861
|
|
|
23457
23862
|
|
|
23458
23863
|
|
|
23459
|
-
|
|
23864
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.getLogger)();
|
|
23460
23865
|
function initDiagnostics(setDiagnosticsReportCallback, keyValueSetCallback) {
|
|
23461
23866
|
if (!keyValueSetCallback || !setDiagnosticsReportCallback) {
|
|
23462
23867
|
logger.log("Callbacks are not set");
|
|
23463
23868
|
return;
|
|
23464
23869
|
}
|
|
23465
|
-
|
|
23466
|
-
|
|
23467
|
-
let version =
|
|
23468
|
-
|
|
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);
|
|
23469
23874
|
return;
|
|
23470
23875
|
}
|
|
23471
23876
|
function closeDiagnostics() {
|
|
23472
|
-
|
|
23473
|
-
|
|
23877
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.setKeyValueCallback(null);
|
|
23878
|
+
_listeners_Callback__WEBPACK_IMPORTED_MODULE_1__.diagnosticsCallback.setDiagnosticsReportCallback(null);
|
|
23474
23879
|
return;
|
|
23475
23880
|
}
|
|
23476
|
-
function startSpeakerDiagnosticsTest() {
|
|
23881
|
+
function startSpeakerDiagnosticsTest(webrtcSIPPhone) {
|
|
23477
23882
|
/**
|
|
23478
23883
|
* When user registers the agent phone for the first time, register your callback onto webrtc client
|
|
23479
23884
|
*/
|
|
23480
23885
|
logger.log("Request to startSpeakerTest:\n");
|
|
23481
|
-
|
|
23886
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.startSpeakerTest(webrtcSIPPhone);
|
|
23482
23887
|
return;
|
|
23483
23888
|
}
|
|
23484
|
-
function stopSpeakerDiagnosticsTest(speakerTestResponse) {
|
|
23889
|
+
function stopSpeakerDiagnosticsTest(speakerTestResponse, webrtcSIPPhone) {
|
|
23485
23890
|
/**
|
|
23486
23891
|
* When user registers the agent phone for the first time, register your callback onto webrtc client
|
|
23487
23892
|
*/
|
|
23488
23893
|
|
|
23489
23894
|
logger.log("Request to stopSpeakerTest - Suuccessful Test:\n");
|
|
23490
23895
|
if (speakerTestResponse == 'yes') {
|
|
23491
|
-
|
|
23896
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopSpeakerTesttoneWithSuccess(webrtcSIPPhone);
|
|
23492
23897
|
} else if (speakerTestResponse == 'no') {
|
|
23493
|
-
|
|
23898
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopSpeakerTesttoneWithFailure(webrtcSIPPhone);
|
|
23494
23899
|
} else {
|
|
23495
|
-
|
|
23900
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopSpeakerTest(webrtcSIPPhone);
|
|
23496
23901
|
}
|
|
23497
23902
|
return;
|
|
23498
23903
|
}
|
|
@@ -23501,7 +23906,7 @@ function startMicDiagnosticsTest() {
|
|
|
23501
23906
|
* When user registers the agent phone for the first time, register your callback onto webrtc client
|
|
23502
23907
|
*/
|
|
23503
23908
|
logger.log("Request to startMicTest:\n");
|
|
23504
|
-
|
|
23909
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.startMicTest();
|
|
23505
23910
|
return;
|
|
23506
23911
|
}
|
|
23507
23912
|
function stopMicDiagnosticsTest(micTestResponse) {
|
|
@@ -23510,11 +23915,11 @@ function stopMicDiagnosticsTest(micTestResponse) {
|
|
|
23510
23915
|
*/
|
|
23511
23916
|
logger.log("Request to stopMicTest - Successful Test:\n");
|
|
23512
23917
|
if (micTestResponse == 'yes') {
|
|
23513
|
-
|
|
23918
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopMicTestSuccess();
|
|
23514
23919
|
} else if (micTestResponse == 'no') {
|
|
23515
|
-
|
|
23920
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopMicTestFailure();
|
|
23516
23921
|
} else {
|
|
23517
|
-
|
|
23922
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.stopMicTest();
|
|
23518
23923
|
}
|
|
23519
23924
|
return;
|
|
23520
23925
|
}
|
|
@@ -23527,7 +23932,7 @@ function startNetworkDiagnostics() {
|
|
|
23527
23932
|
* When user registers the agent phone for the first time, register your callback onto webrtc client
|
|
23528
23933
|
*/
|
|
23529
23934
|
logger.log("Request to start network diagnostics:\n");
|
|
23530
|
-
|
|
23935
|
+
_Diagnostics__WEBPACK_IMPORTED_MODULE_2__.ameyoWebRTCTroubleshooter.startWSAndUserRegistrationTest();
|
|
23531
23936
|
return;
|
|
23532
23937
|
}
|
|
23533
23938
|
|
|
@@ -23541,6 +23946,15 @@ function stopNetworkDiagnostics() {
|
|
|
23541
23946
|
logger.log("Request to stop network diagnostics:\n");
|
|
23542
23947
|
return;
|
|
23543
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
|
+
}
|
|
23544
23958
|
|
|
23545
23959
|
/***/ }),
|
|
23546
23960
|
|
|
@@ -23558,7 +23972,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23558
23972
|
/* harmony export */ });
|
|
23559
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");
|
|
23560
23974
|
|
|
23561
|
-
|
|
23975
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.getLogger)();
|
|
23562
23976
|
|
|
23563
23977
|
/**
|
|
23564
23978
|
* Function to register the phone onto a webRTC client
|
|
@@ -23596,37 +24010,11 @@ function DoRegister(sipAccountInfo, exWebClient, delay = 500) {
|
|
|
23596
24010
|
* @param {*} exWebClient
|
|
23597
24011
|
*/
|
|
23598
24012
|
function UnRegister(sipAccountInfo, exWebClient) {
|
|
23599
|
-
try {
|
|
23600
|
-
exWebClient.unregister(sipAccountInfo);
|
|
23601
|
-
} catch (e) {
|
|
23602
|
-
logger.log("Unregister failed ", e);
|
|
23603
|
-
}
|
|
23604
|
-
}
|
|
23605
|
-
|
|
23606
|
-
/***/ }),
|
|
23607
|
-
|
|
23608
|
-
/***/ "./src/constants/common.js":
|
|
23609
|
-
/*!*********************************!*\
|
|
23610
|
-
!*** ./src/constants/common.js ***!
|
|
23611
|
-
\*********************************/
|
|
23612
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
23613
|
-
|
|
23614
|
-
"use strict";
|
|
23615
|
-
__webpack_require__.r(__webpack_exports__);
|
|
23616
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23617
|
-
/* harmony export */ FetchTabInfo: () => (/* binding */ FetchTabInfo)
|
|
23618
|
-
/* harmony export */ });
|
|
23619
|
-
/**
|
|
23620
|
-
* Function to fetch the tab details from tabID
|
|
23621
|
-
*/
|
|
23622
|
-
function FetchTabInfo(tabID) {
|
|
23623
|
-
const tabArr = JSON.parse(window.localStorage.getItem('tabs'));
|
|
23624
|
-
for (var x = 0; x < tabArr.length; x++) {
|
|
23625
|
-
if (tabArr[x].tabID == tabID) {
|
|
23626
|
-
return tabArr[x];
|
|
23627
|
-
}
|
|
24013
|
+
try {
|
|
24014
|
+
exWebClient.unregister(sipAccountInfo);
|
|
24015
|
+
} catch (e) {
|
|
24016
|
+
logger.log("Unregister failed ", e);
|
|
23628
24017
|
}
|
|
23629
|
-
return null;
|
|
23630
24018
|
}
|
|
23631
24019
|
|
|
23632
24020
|
/***/ }),
|
|
@@ -23664,43 +24052,34 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23664
24052
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23665
24053
|
/* harmony export */ CallListener: () => (/* binding */ CallListener)
|
|
23666
24054
|
/* harmony export */ });
|
|
23667
|
-
/* harmony import */ var
|
|
23668
|
-
/* 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");
|
|
23669
|
-
|
|
23670
|
-
|
|
23671
|
-
var logger = _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_1__.webrtcSIPPhone.getLogger();
|
|
23672
|
-
function CallListener() {
|
|
23673
|
-
this.onIncomingCall = function (call, phone) {
|
|
23674
|
-
/**
|
|
23675
|
-
* When there is an incoming call, [INVITE is received on SIP] send a call back to the
|
|
23676
|
-
*/
|
|
23677
|
-
logger.log("CallListener:Initialise call");
|
|
23678
|
-
_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");
|
|
23679
24056
|
|
|
23680
|
-
|
|
23681
|
-
|
|
23682
|
-
|
|
23683
|
-
|
|
23684
|
-
|
|
23685
|
-
|
|
23686
|
-
|
|
23687
|
-
|
|
23688
|
-
|
|
23689
|
-
|
|
23690
|
-
|
|
23691
|
-
logger.log("CallListener:
|
|
23692
|
-
|
|
23693
|
-
}
|
|
23694
|
-
|
|
23695
|
-
|
|
23696
|
-
|
|
23697
|
-
|
|
23698
|
-
|
|
23699
|
-
|
|
23700
|
-
|
|
23701
|
-
|
|
23702
|
-
|
|
23703
|
-
|
|
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
|
+
}
|
|
23704
24083
|
}
|
|
23705
24084
|
|
|
23706
24085
|
/***/ }),
|
|
@@ -23714,17 +24093,17 @@ function CallListener() {
|
|
|
23714
24093
|
"use strict";
|
|
23715
24094
|
__webpack_require__.r(__webpack_exports__);
|
|
23716
24095
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23717
|
-
/* harmony export */
|
|
24096
|
+
/* harmony export */ Callback: () => (/* binding */ Callback),
|
|
24097
|
+
/* harmony export */ RegisterCallback: () => (/* binding */ RegisterCallback),
|
|
24098
|
+
/* harmony export */ SessionCallback: () => (/* binding */ SessionCallback),
|
|
23718
24099
|
/* harmony export */ diagnosticsCallback: () => (/* binding */ diagnosticsCallback),
|
|
23719
24100
|
/* harmony export */ phoneInstance: () => (/* binding */ phoneInstance),
|
|
23720
|
-
/* harmony export */ registerCallback: () => (/* binding */ registerCallback),
|
|
23721
|
-
/* harmony export */ sessionCallback: () => (/* binding */ sessionCallback),
|
|
23722
24101
|
/* harmony export */ timerSession: () => (/* binding */ timerSession),
|
|
23723
24102
|
/* harmony export */ webrtcTroubleshooterEventBus: () => (/* binding */ webrtcTroubleshooterEventBus)
|
|
23724
24103
|
/* harmony export */ });
|
|
23725
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");
|
|
23726
24105
|
|
|
23727
|
-
|
|
24106
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.getLogger)();
|
|
23728
24107
|
|
|
23729
24108
|
/**
|
|
23730
24109
|
* The call backs are called through this function. First initiates the call object and then
|
|
@@ -23734,43 +24113,49 @@ var logger = _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.webrtc
|
|
|
23734
24113
|
/**
|
|
23735
24114
|
* Initializes call event callbacks and also sends to which phone callback was received
|
|
23736
24115
|
*/
|
|
23737
|
-
|
|
23738
|
-
|
|
23739
|
-
|
|
23740
|
-
|
|
23741
|
-
|
|
23742
|
-
|
|
23743
|
-
|
|
23744
|
-
|
|
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) {
|
|
23745
24126
|
this.call = call;
|
|
23746
24127
|
this.phone = phone;
|
|
23747
|
-
},
|
|
23748
|
-
triggerCallback: function (eventType) {
|
|
23749
|
-
const callbackFunc = this.callback;
|
|
23750
|
-
const call = this.call;
|
|
23751
|
-
return callbackFunc(call, eventType, this.phone);
|
|
23752
24128
|
}
|
|
23753
|
-
|
|
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
|
+
|
|
23754
24138
|
/**
|
|
23755
24139
|
* Initializes register callback and also sets to which phone registration was renewed
|
|
23756
24140
|
*/
|
|
23757
|
-
|
|
23758
|
-
|
|
23759
|
-
|
|
23760
|
-
|
|
23761
|
-
|
|
23762
|
-
|
|
23763
|
-
|
|
23764
|
-
|
|
23765
|
-
|
|
23766
|
-
|
|
23767
|
-
|
|
23768
|
-
|
|
23769
|
-
|
|
23770
|
-
const
|
|
23771
|
-
|
|
23772
|
-
|
|
23773
|
-
};
|
|
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
|
+
}
|
|
23774
24159
|
/**
|
|
23775
24160
|
* Sets all the phone instances
|
|
23776
24161
|
*/
|
|
@@ -23803,30 +24188,30 @@ var phoneInstance = {
|
|
|
23803
24188
|
}
|
|
23804
24189
|
}
|
|
23805
24190
|
};
|
|
23806
|
-
|
|
23807
|
-
sessioncallback
|
|
23808
|
-
callState
|
|
23809
|
-
document
|
|
23810
|
-
documentCallback
|
|
23811
|
-
phone
|
|
23812
|
-
initializeSessionCallback
|
|
24191
|
+
class SessionCallback {
|
|
24192
|
+
sessioncallback = null;
|
|
24193
|
+
callState = null;
|
|
24194
|
+
document = null;
|
|
24195
|
+
documentCallback = null;
|
|
24196
|
+
phone = '';
|
|
24197
|
+
initializeSessionCallback = function (SessionCallback) {
|
|
23813
24198
|
this.sessioncallback = SessionCallback;
|
|
23814
|
-
}
|
|
23815
|
-
intializeDocumentCallback
|
|
24199
|
+
};
|
|
24200
|
+
intializeDocumentCallback = function (DocumentCallback) {
|
|
23816
24201
|
this.documentCallback = DocumentCallback;
|
|
23817
|
-
}
|
|
23818
|
-
initializeSession
|
|
24202
|
+
};
|
|
24203
|
+
initializeSession = function (state, phone) {
|
|
23819
24204
|
this.callState = state;
|
|
23820
24205
|
this.phone = phone;
|
|
23821
|
-
}
|
|
23822
|
-
initializeDocument
|
|
24206
|
+
};
|
|
24207
|
+
initializeDocument = function (calldocument) {
|
|
23823
24208
|
this.document = calldocument;
|
|
23824
|
-
}
|
|
23825
|
-
triggerDocumentCallback
|
|
24209
|
+
};
|
|
24210
|
+
triggerDocumentCallback = function () {
|
|
23826
24211
|
const documentCallbackFunc = this.documentCallback;
|
|
23827
24212
|
return documentCallbackFunc(this.document);
|
|
23828
|
-
}
|
|
23829
|
-
triggerSessionCallback
|
|
24213
|
+
};
|
|
24214
|
+
triggerSessionCallback = function () {
|
|
23830
24215
|
const sessionCallBackFunc = this.sessioncallback;
|
|
23831
24216
|
if (sessionCallBackFunc) {
|
|
23832
24217
|
return sessionCallBackFunc(this.callState, this.phone);
|
|
@@ -23834,8 +24219,8 @@ var sessionCallback = {
|
|
|
23834
24219
|
logger.log("Session callback is null");
|
|
23835
24220
|
return;
|
|
23836
24221
|
}
|
|
23837
|
-
}
|
|
23838
|
-
}
|
|
24222
|
+
};
|
|
24223
|
+
}
|
|
23839
24224
|
var diagnosticsCallback = {
|
|
23840
24225
|
saveDiagnosticsCallback: null,
|
|
23841
24226
|
keyValueSetCallback: null,
|
|
@@ -23948,6 +24333,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23948
24333
|
/* harmony import */ var _listeners_Callback__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Callback */ "./src/listeners/Callback.js");
|
|
23949
24334
|
/* harmony import */ var _exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @exotel-npm-dev/webrtc-core-sdk */ "./node_modules/@exotel-npm-dev/webrtc-core-sdk/index.js");
|
|
23950
24335
|
/* harmony import */ var _api_callAPI_CallDetails__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../api/callAPI/CallDetails */ "./src/api/callAPI/CallDetails.js");
|
|
24336
|
+
/* harmony import */ var _api_LogManager_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../api/LogManager.js */ "./src/api/LogManager.js");
|
|
23951
24337
|
|
|
23952
24338
|
|
|
23953
24339
|
|
|
@@ -23959,9 +24345,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23959
24345
|
|
|
23960
24346
|
|
|
23961
24347
|
|
|
24348
|
+
|
|
24349
|
+
const phonePool = new Map();
|
|
23962
24350
|
var intervalId;
|
|
23963
24351
|
var intervalIDMap = new Map();
|
|
23964
|
-
|
|
24352
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.getLogger)();
|
|
23965
24353
|
function sleep(ms) {
|
|
23966
24354
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
23967
24355
|
}
|
|
@@ -23970,113 +24358,117 @@ function sleep(ms) {
|
|
|
23970
24358
|
* FQDN for fetching IP
|
|
23971
24359
|
*/
|
|
23972
24360
|
function fetchPublicIP(sipAccountInfo) {
|
|
23973
|
-
|
|
23974
|
-
|
|
23975
|
-
|
|
23976
|
-
|
|
23977
|
-
|
|
23978
|
-
|
|
23979
|
-
|
|
23980
|
-
|
|
23981
|
-
|
|
23982
|
-
|
|
23983
|
-
|
|
23984
|
-
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
|
|
23988
|
-
|
|
23989
|
-
|
|
23990
|
-
|
|
23991
|
-
|
|
23992
|
-
|
|
23993
|
-
|
|
23994
|
-
|
|
23995
|
-
|
|
23996
|
-
|
|
23997
|
-
|
|
23998
|
-
|
|
23999
|
-
|
|
24000
|
-
|
|
24001
|
-
|
|
24002
|
-
|
|
24003
|
-
|
|
24004
|
-
|
|
24005
|
-
|
|
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);
|
|
24006
24398
|
});
|
|
24007
|
-
return;
|
|
24008
24399
|
}
|
|
24009
|
-
|
|
24010
|
-
|
|
24011
|
-
|
|
24012
|
-
|
|
24400
|
+
class ExDelegationHandler {
|
|
24401
|
+
constructor(exClient) {
|
|
24402
|
+
this.exClient = exClient;
|
|
24403
|
+
}
|
|
24404
|
+
setTestingMode(mode) {
|
|
24013
24405
|
logger.log("delegationHandler: setTestingMode\n");
|
|
24014
|
-
}
|
|
24015
|
-
|
|
24016
|
-
logger.log("delegationHandler: onCallStatSipJsSessionEvent
|
|
24017
|
-
}
|
|
24018
|
-
|
|
24406
|
+
}
|
|
24407
|
+
onCallStatSipJsSessionEvent(ev) {
|
|
24408
|
+
logger.log("delegationHandler: onCallStatSipJsSessionEvent", ev);
|
|
24409
|
+
}
|
|
24410
|
+
sendWebRTCEventsToFSM(eventType, sipMethod) {
|
|
24019
24411
|
logger.log("delegationHandler: sendWebRTCEventsToFSM\n");
|
|
24020
24412
|
logger.log("delegationHandler: eventType\n", eventType);
|
|
24021
24413
|
logger.log("delegationHandler: sipMethod\n", sipMethod);
|
|
24022
24414
|
if (sipMethod == "CONNECTION") {
|
|
24023
|
-
exClient.registerEventCallback(eventType, exClient.userName);
|
|
24415
|
+
this.exClient.registerEventCallback(eventType, this.exClient.userName);
|
|
24024
24416
|
} else if (sipMethod == "CALL") {
|
|
24025
|
-
exClient.callEventCallback(eventType, exClient.callFromNumber, exClient.call);
|
|
24417
|
+
this.exClient.callEventCallback(eventType, this.exClient.callFromNumber, this.exClient.call);
|
|
24026
24418
|
}
|
|
24027
|
-
}
|
|
24028
|
-
|
|
24419
|
+
}
|
|
24420
|
+
playBeepTone() {
|
|
24029
24421
|
logger.log("delegationHandler: playBeepTone\n");
|
|
24030
|
-
}
|
|
24031
|
-
|
|
24422
|
+
}
|
|
24423
|
+
onStatPeerConnectionIceGatheringStateChange(iceGatheringState) {
|
|
24032
24424
|
logger.log("delegationHandler: onStatPeerConnectionIceGatheringStateChange\n");
|
|
24033
|
-
}
|
|
24034
|
-
|
|
24425
|
+
}
|
|
24426
|
+
onCallStatIceCandidate(ev, icestate) {
|
|
24035
24427
|
logger.log("delegationHandler: onCallStatIceCandidate\n");
|
|
24036
|
-
}
|
|
24037
|
-
|
|
24428
|
+
}
|
|
24429
|
+
onCallStatNegoNeeded(icestate) {
|
|
24038
24430
|
logger.log("delegationHandler: onCallStatNegoNeeded\n");
|
|
24039
|
-
}
|
|
24040
|
-
|
|
24431
|
+
}
|
|
24432
|
+
onCallStatSignalingStateChange(cstate) {
|
|
24041
24433
|
logger.log("delegationHandler: onCallStatSignalingStateChange\n");
|
|
24042
|
-
}
|
|
24043
|
-
|
|
24434
|
+
}
|
|
24435
|
+
onStatPeerConnectionIceConnectionStateChange() {
|
|
24044
24436
|
logger.log("delegationHandler: onStatPeerConnectionIceConnectionStateChange\n");
|
|
24045
|
-
}
|
|
24046
|
-
|
|
24437
|
+
}
|
|
24438
|
+
onStatPeerConnectionConnectionStateChange() {
|
|
24047
24439
|
logger.log("delegationHandler: onStatPeerConnectionConnectionStateChange\n");
|
|
24048
|
-
}
|
|
24049
|
-
|
|
24440
|
+
}
|
|
24441
|
+
onGetUserMediaSuccessCallstatCallback() {
|
|
24050
24442
|
logger.log("delegationHandler: onGetUserMediaSuccessCallstatCallback\n");
|
|
24051
|
-
}
|
|
24052
|
-
|
|
24443
|
+
}
|
|
24444
|
+
onGetUserMediaErrorCallstatCallback() {
|
|
24053
24445
|
logger.log("delegationHandler: onGetUserMediaErrorCallstatCallback\n");
|
|
24054
|
-
}
|
|
24055
|
-
|
|
24446
|
+
}
|
|
24447
|
+
onCallStatAddStream() {
|
|
24056
24448
|
logger.log("delegationHandler: onCallStatAddStream\n");
|
|
24057
|
-
}
|
|
24058
|
-
|
|
24449
|
+
}
|
|
24450
|
+
onCallStatRemoveStream() {
|
|
24059
24451
|
logger.log("delegationHandler: onCallStatRemoveStream\n");
|
|
24060
|
-
}
|
|
24061
|
-
|
|
24452
|
+
}
|
|
24453
|
+
setWebRTCFSMMapper(stack) {
|
|
24062
24454
|
logger.log("delegationHandler: setWebRTCFSMMapper : Initialisation complete \n");
|
|
24063
|
-
}
|
|
24064
|
-
|
|
24455
|
+
}
|
|
24456
|
+
onCallStatSipJsTransportEvent() {
|
|
24065
24457
|
logger.log("delegationHandler: onCallStatSipJsTransportEvent\n");
|
|
24066
|
-
}
|
|
24067
|
-
|
|
24458
|
+
}
|
|
24459
|
+
onCallStatSipSendCallback() {
|
|
24068
24460
|
logger.log("delegationHandler: onCallStatSipSendCallback\n");
|
|
24069
|
-
}
|
|
24070
|
-
|
|
24461
|
+
}
|
|
24462
|
+
onCallStatSipRecvCallback() {
|
|
24071
24463
|
logger.log("delegationHandler: onCallStatSipRecvCallback\n");
|
|
24072
|
-
}
|
|
24073
|
-
|
|
24464
|
+
}
|
|
24465
|
+
stopCallStat() {
|
|
24074
24466
|
logger.log("delegationHandler: stopCallStat\n");
|
|
24075
|
-
}
|
|
24076
|
-
|
|
24467
|
+
}
|
|
24468
|
+
onRecieveInvite(incomingSession) {
|
|
24077
24469
|
logger.log("delegationHandler: onRecieveInvite\n");
|
|
24078
24470
|
const obj = incomingSession.incomingInviteRequest.message.headers;
|
|
24079
|
-
exClient.callFromNumber = incomingSession.incomingInviteRequest.message.from.displayName;
|
|
24471
|
+
this.exClient.callFromNumber = incomingSession.incomingInviteRequest.message.from.displayName;
|
|
24080
24472
|
if (obj.hasOwnProperty("X-Exotel-Callsid")) {
|
|
24081
24473
|
_api_callAPI_CallDetails__WEBPACK_IMPORTED_MODULE_9__.CallDetails.callSid = obj['X-Exotel-Callsid'][0].raw;
|
|
24082
24474
|
}
|
|
@@ -24097,35 +24489,40 @@ function ExDelegationHandler(exClient_) {
|
|
|
24097
24489
|
}
|
|
24098
24490
|
}
|
|
24099
24491
|
_api_callAPI_CallDetails__WEBPACK_IMPORTED_MODULE_9__.CallDetails.sipHeaders = result;
|
|
24100
|
-
}
|
|
24101
|
-
|
|
24492
|
+
}
|
|
24493
|
+
onPickCall() {
|
|
24102
24494
|
logger.log("delegationHandler: onPickCall\n");
|
|
24103
|
-
}
|
|
24104
|
-
|
|
24495
|
+
}
|
|
24496
|
+
onRejectCall() {
|
|
24105
24497
|
logger.log("delegationHandler: onRejectCall\n");
|
|
24106
|
-
}
|
|
24107
|
-
|
|
24498
|
+
}
|
|
24499
|
+
onCreaterAnswer() {
|
|
24108
24500
|
logger.log("delegationHandler: onCreaterAnswer\n");
|
|
24109
|
-
}
|
|
24110
|
-
|
|
24501
|
+
}
|
|
24502
|
+
onSettingLocalDesc() {
|
|
24111
24503
|
logger.log("delegationHandler: onSettingLocalDesc\n");
|
|
24112
|
-
}
|
|
24113
|
-
|
|
24504
|
+
}
|
|
24505
|
+
initGetStats(pc, callid, username) {
|
|
24114
24506
|
logger.log("delegationHandler: initGetStats\n");
|
|
24115
|
-
}
|
|
24116
|
-
|
|
24507
|
+
}
|
|
24508
|
+
onRegisterWebRTCSIPEngine(engine) {
|
|
24117
24509
|
logger.log("delegationHandler: onRegisterWebRTCSIPEngine, engine=\n", engine);
|
|
24118
|
-
}
|
|
24510
|
+
}
|
|
24119
24511
|
}
|
|
24120
|
-
|
|
24121
|
-
|
|
24512
|
+
class ExSynchronousHandler {
|
|
24513
|
+
onFailure() {
|
|
24122
24514
|
logger.log("synchronousHandler: onFailure, phone is offline.\n");
|
|
24123
|
-
}
|
|
24124
|
-
|
|
24515
|
+
}
|
|
24516
|
+
onResponse() {
|
|
24125
24517
|
logger.log("synchronousHandler: onResponse, phone is connected.\n");
|
|
24126
|
-
}
|
|
24518
|
+
}
|
|
24127
24519
|
}
|
|
24520
|
+
|
|
24128
24521
|
class ExotelWebClient {
|
|
24522
|
+
/**
|
|
24523
|
+
* @param {Object} sipAccntInfo
|
|
24524
|
+
*/
|
|
24525
|
+
|
|
24129
24526
|
ctrlr = null;
|
|
24130
24527
|
call;
|
|
24131
24528
|
eventListener = null;
|
|
@@ -24135,47 +24532,113 @@ class ExotelWebClient {
|
|
|
24135
24532
|
unregisterInitiated = false;
|
|
24136
24533
|
registrationInProgress = false;
|
|
24137
24534
|
isReadyToRegister = true;
|
|
24138
|
-
/* OLD-Way to be revisited for multile phone support */
|
|
24139
|
-
//this.webRTCPhones = {};
|
|
24140
|
-
|
|
24141
24535
|
sipAccountInfo = null;
|
|
24142
|
-
|
|
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)();
|
|
24541
|
+
constructor() {
|
|
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) => {
|
|
24562
|
+
_api_LogManager_js__WEBPACK_IMPORTED_MODULE_10__["default"].onLog(type, message, args);
|
|
24563
|
+
if (this.clientSDKLoggerCallback) {
|
|
24564
|
+
this.clientSDKLoggerCallback("log", message, args);
|
|
24565
|
+
}
|
|
24566
|
+
});
|
|
24567
|
+
}
|
|
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);
|
|
24143
24581
|
if (!this.eventListener) {
|
|
24144
|
-
this.eventListener = new _listeners_ExotelVoiceClientListener__WEBPACK_IMPORTED_MODULE_3__.ExotelVoiceClientListener();
|
|
24582
|
+
this.eventListener = new _listeners_ExotelVoiceClientListener__WEBPACK_IMPORTED_MODULE_3__.ExotelVoiceClientListener(this.registerCallback);
|
|
24145
24583
|
}
|
|
24146
24584
|
if (!this.callListener) {
|
|
24147
|
-
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);
|
|
24148
24589
|
}
|
|
24149
24590
|
if (!this.ctrlr) {
|
|
24150
24591
|
this.ctrlr = new _CallCtrlerDummy__WEBPACK_IMPORTED_MODULE_5__.CallController();
|
|
24151
24592
|
}
|
|
24152
|
-
|
|
24153
|
-
this.call = new _api_callAPI_Call__WEBPACK_IMPORTED_MODULE_0__.Call();
|
|
24154
|
-
}
|
|
24155
|
-
logger.log("Exotel Client Initialised with " + JSON.stringify(sipAccountInfo_));
|
|
24593
|
+
logger.log("ExWebClient: initWebrtc: Exotel Client Initialised with " + JSON.stringify(sipAccountInfo_));
|
|
24156
24594
|
this.sipAccountInfo = sipAccountInfo_;
|
|
24157
24595
|
if (!this.sipAccountInfo["userName"] || !this.sipAccountInfo["sipdomain"] || !this.sipAccountInfo["port"]) {
|
|
24158
24596
|
return false;
|
|
24159
24597
|
}
|
|
24160
24598
|
this.sipAccountInfo["sipUri"] = "wss://" + this.sipAccountInfo["userName"] + "@" + this.sipAccountInfo["sipdomain"] + ":" + this.sipAccountInfo["port"];
|
|
24161
|
-
|
|
24162
|
-
|
|
24163
|
-
|
|
24164
|
-
|
|
24599
|
+
|
|
24600
|
+
// Register callbacks using the correct methods
|
|
24601
|
+
this.callbacks.registerCallback('call', CallListenerCallback);
|
|
24602
|
+
this.registerCallback.initializeRegisterCallback(RegisterEventCallBack);
|
|
24603
|
+
logger.log("ExWebClient: initWebrtc: Initializing session callback");
|
|
24604
|
+
this.sessionCallback.initializeSessionCallback(SessionCallback);
|
|
24165
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
|
+
}
|
|
24166
24629
|
return true;
|
|
24167
24630
|
};
|
|
24168
24631
|
DoRegister = () => {
|
|
24169
|
-
logger.log("ExWebClient:DoRegister Entry");
|
|
24632
|
+
logger.log("ExWebClient: DoRegister: Entry");
|
|
24170
24633
|
if (!this.isReadyToRegister) {
|
|
24171
|
-
logger.warn("ExWebClient:DoRegister SDK is not ready to register");
|
|
24634
|
+
logger.warn("ExWebClient: DoRegister: SDK is not ready to register");
|
|
24172
24635
|
return false;
|
|
24173
24636
|
}
|
|
24174
24637
|
(0,_api_registerAPI_RegisterListener__WEBPACK_IMPORTED_MODULE_1__.DoRegister)(this.sipAccountInfo, this);
|
|
24175
24638
|
return true;
|
|
24176
24639
|
};
|
|
24177
24640
|
UnRegister = () => {
|
|
24178
|
-
logger.log("ExWebClient:UnRegister Entry");
|
|
24641
|
+
logger.log("ExWebClient: UnRegister: Entry");
|
|
24179
24642
|
(0,_api_registerAPI_RegisterListener__WEBPACK_IMPORTED_MODULE_1__.UnRegister)(this.sipAccountInfo, this);
|
|
24180
24643
|
};
|
|
24181
24644
|
initDiagnostics = (saveDiagnosticsCallback, keyValueSetCallback) => {
|
|
@@ -24185,10 +24648,10 @@ class ExotelWebClient {
|
|
|
24185
24648
|
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.closeDiagnostics)();
|
|
24186
24649
|
};
|
|
24187
24650
|
startSpeakerDiagnosticsTest = () => {
|
|
24188
|
-
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.startSpeakerDiagnosticsTest)();
|
|
24651
|
+
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.startSpeakerDiagnosticsTest)(this.webrtcSIPPhone);
|
|
24189
24652
|
};
|
|
24190
24653
|
stopSpeakerDiagnosticsTest = (speakerTestResponse = 'none') => {
|
|
24191
|
-
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.stopSpeakerDiagnosticsTest)(speakerTestResponse);
|
|
24654
|
+
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.stopSpeakerDiagnosticsTest)(speakerTestResponse, this.webrtcSIPPhone);
|
|
24192
24655
|
};
|
|
24193
24656
|
startMicDiagnosticsTest = () => {
|
|
24194
24657
|
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.startMicDiagnosticsTest)();
|
|
@@ -24203,27 +24666,16 @@ class ExotelWebClient {
|
|
|
24203
24666
|
stopNetworkDiagnostics = () => {
|
|
24204
24667
|
(0,_api_omAPI_DiagnosticsListener__WEBPACK_IMPORTED_MODULE_6__.stopNetworkDiagnostics)();
|
|
24205
24668
|
};
|
|
24206
|
-
|
|
24207
|
-
(0,_listeners_SessionListeners__WEBPACK_IMPORTED_MODULE_4__.SessionListener)();
|
|
24208
|
-
};
|
|
24209
|
-
|
|
24210
|
-
/**
|
|
24211
|
-
* function that returns the instance of the call controller object object
|
|
24212
|
-
*/
|
|
24213
|
-
|
|
24669
|
+
SessionListenerMethod = () => {};
|
|
24214
24670
|
getCallController = () => {
|
|
24215
24671
|
return this.ctrlr;
|
|
24216
24672
|
};
|
|
24217
24673
|
getCall = () => {
|
|
24218
24674
|
if (!this.call) {
|
|
24219
|
-
this.call =
|
|
24675
|
+
this.call = new _api_callAPI_Call__WEBPACK_IMPORTED_MODULE_0__.Call(this.webrtcSIPPhone);
|
|
24220
24676
|
}
|
|
24221
24677
|
return this.call;
|
|
24222
24678
|
};
|
|
24223
|
-
|
|
24224
|
-
/**
|
|
24225
|
-
* Dummy function to set the event listener object
|
|
24226
|
-
*/
|
|
24227
24679
|
setEventListener = eventListener => {
|
|
24228
24680
|
this.eventListener = eventListener;
|
|
24229
24681
|
};
|
|
@@ -24236,37 +24688,18 @@ class ExotelWebClient {
|
|
|
24236
24688
|
*/
|
|
24237
24689
|
|
|
24238
24690
|
registerEventCallback = (event, phone, param) => {
|
|
24239
|
-
logger.log("
|
|
24240
|
-
|
|
24241
|
-
|
|
24242
|
-
* When registration is successful then send the phone number of the same to UI
|
|
24243
|
-
*/
|
|
24244
|
-
this.eventListener.onInitializationSuccess(phone);
|
|
24691
|
+
logger.log("ExWebClient: registerEventCallback: Received ---> " + event, [phone, param]);
|
|
24692
|
+
const lowerCaseEvent = event.toLowerCase();
|
|
24693
|
+
if (lowerCaseEvent === "registered") {
|
|
24245
24694
|
this.registrationInProgress = false;
|
|
24246
|
-
|
|
24247
|
-
|
|
24248
|
-
|
|
24249
|
-
|
|
24250
|
-
|
|
24251
|
-
|
|
24252
|
-
|
|
24253
|
-
|
|
24254
|
-
*/
|
|
24255
|
-
this.eventListener.onInitializationFailure(phone);
|
|
24256
|
-
if (this.unregisterInitiated) {
|
|
24257
|
-
this.shouldAutoRetry = false;
|
|
24258
|
-
this.unregisterInitiated = false;
|
|
24259
|
-
this.isReadyToRegister = true;
|
|
24260
|
-
}
|
|
24261
|
-
if (this.shouldAutoRetry) {
|
|
24262
|
-
logger.log("ExWebClient:registerEventCallback Autoretrying");
|
|
24263
|
-
(0,_api_registerAPI_RegisterListener__WEBPACK_IMPORTED_MODULE_1__.DoRegister)(this.sipAccountInfo, this, 5000);
|
|
24264
|
-
}
|
|
24265
|
-
} else if (event === "sent_request") {
|
|
24266
|
-
/**
|
|
24267
|
-
* If registration request waiting...
|
|
24268
|
-
*/
|
|
24269
|
-
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);
|
|
24270
24703
|
}
|
|
24271
24704
|
};
|
|
24272
24705
|
/**
|
|
@@ -24276,9 +24709,15 @@ class ExotelWebClient {
|
|
|
24276
24709
|
* @param {*} param
|
|
24277
24710
|
*/
|
|
24278
24711
|
callEventCallback = (event, phone, param) => {
|
|
24279
|
-
logger.log("
|
|
24712
|
+
logger.log("ExWebClient: callEventCallback: Received ---> " + event + 'param sent....' + param + 'for phone....' + phone);
|
|
24280
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
|
+
|
|
24281
24718
|
this.callListener.onIncomingCall(param, phone);
|
|
24719
|
+
} else if (event === "ringing" || event === "accept_reject") {
|
|
24720
|
+
this.callListener.onRinging(param, phone);
|
|
24282
24721
|
} else if (event === "connected") {
|
|
24283
24722
|
this.callListener.onCallEstablished(param, phone);
|
|
24284
24723
|
} else if (event === "terminated") {
|
|
@@ -24301,22 +24740,22 @@ class ExotelWebClient {
|
|
|
24301
24740
|
* @param {*} sipAccountInfo
|
|
24302
24741
|
*/
|
|
24303
24742
|
unregister = sipAccountInfo => {
|
|
24304
|
-
logger.log("ExWebClient:unregister Entry");
|
|
24743
|
+
logger.log("ExWebClient: unregister: Entry");
|
|
24305
24744
|
this.shouldAutoRetry = false;
|
|
24306
24745
|
this.unregisterInitiated = true;
|
|
24307
24746
|
if (!this.registrationInProgress) {
|
|
24308
|
-
setTimeout(
|
|
24309
|
-
|
|
24747
|
+
setTimeout(() => {
|
|
24748
|
+
const phone = phonePool[this.userName] || this.webrtcSIPPhone;
|
|
24749
|
+
if (phone) {
|
|
24750
|
+
phone.sipUnRegisterWebRTC();
|
|
24751
|
+
phone.disconnect?.();
|
|
24752
|
+
}
|
|
24310
24753
|
}, 500);
|
|
24311
24754
|
}
|
|
24312
24755
|
};
|
|
24313
24756
|
webRTCStatusCallbackHandler = (msg1, arg1) => {
|
|
24314
|
-
logger.log("webRTCStatusCallbackHandler: " + msg1 + " " + arg1);
|
|
24757
|
+
logger.log("ExWebClient: webRTCStatusCallbackHandler: " + msg1 + " " + arg1);
|
|
24315
24758
|
};
|
|
24316
|
-
|
|
24317
|
-
/**
|
|
24318
|
-
* initialize function called when user wants to register client
|
|
24319
|
-
*/
|
|
24320
24759
|
initialize = (uiContext, hostName, subscriberName, displayName, accountSid, subscriberToken, sipAccountInfo) => {
|
|
24321
24760
|
let wssPort = sipAccountInfo.port;
|
|
24322
24761
|
let wsPort = 4442;
|
|
@@ -24337,10 +24776,8 @@ class ExotelWebClient {
|
|
|
24337
24776
|
'port': '',
|
|
24338
24777
|
'contactHost': ''
|
|
24339
24778
|
};
|
|
24340
|
-
logger.log('Sending register for the number..', subscriberName);
|
|
24779
|
+
logger.log('ExWebClient: initialize: Sending register for the number..', subscriberName);
|
|
24341
24780
|
fetchPublicIP(sipAccountInfo);
|
|
24342
|
-
|
|
24343
|
-
/* Temporary till we figure out the arguments - Start */
|
|
24344
24781
|
this.domain = hostName = sipAccountInfo.domain;
|
|
24345
24782
|
this.sipdomain = sipAccountInfo.sipdomain;
|
|
24346
24783
|
this.accountName = this.userName = sipAccountInfo.userName;
|
|
@@ -24356,9 +24793,6 @@ class ExotelWebClient {
|
|
|
24356
24793
|
this.sipWsPort = 5061;
|
|
24357
24794
|
this.sipPort = 5061;
|
|
24358
24795
|
this.sipSecurePort = 5062;
|
|
24359
|
-
/* Temporary till we figure out the arguments - End */
|
|
24360
|
-
|
|
24361
|
-
/* This is permanent -Start */
|
|
24362
24796
|
let webrtcPort = wssPort;
|
|
24363
24797
|
if (this.security === 'ws') {
|
|
24364
24798
|
webrtcPort = wsPort;
|
|
@@ -24375,37 +24809,21 @@ class ExotelWebClient {
|
|
|
24375
24809
|
this.sipAccntInfo['port'] = webrtcPort;
|
|
24376
24810
|
this.sipAccntInfo['contactHost'] = this.contactHost;
|
|
24377
24811
|
localStorage.setItem('contactHost', this.contactHost);
|
|
24378
|
-
|
|
24379
|
-
|
|
24380
|
-
/**
|
|
24381
|
-
* Call the webclient function inside this and pass register and call callbacks as arg
|
|
24382
|
-
*/
|
|
24383
|
-
var synchronousHandler = new ExSynchronousHandler(this);
|
|
24812
|
+
var synchronousHandler = new ExSynchronousHandler();
|
|
24384
24813
|
var delegationHandler = new ExDelegationHandler(this);
|
|
24385
24814
|
var userName = this.userName;
|
|
24386
|
-
|
|
24387
|
-
|
|
24388
|
-
|
|
24389
|
-
/* New-Way */
|
|
24390
|
-
_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.webrtcSIPPhone.registerPhone("sipjs", delegationHandler);
|
|
24391
|
-
_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_8__.webrtcSIPPhone.registerWebRTCClient(this.sipAccntInfo, synchronousHandler);
|
|
24392
|
-
|
|
24393
|
-
/**
|
|
24394
|
-
* Store the intervalID against a map
|
|
24395
|
-
*/
|
|
24815
|
+
this.webrtcSIPPhone.registerPhone("sipjs", delegationHandler);
|
|
24816
|
+
this.webrtcSIPPhone.registerWebRTCClient(this.sipAccntInfo, synchronousHandler);
|
|
24817
|
+
phonePool[this.userName] = this.webrtcSIPPhone;
|
|
24396
24818
|
intervalIDMap.set(userName, intervalId);
|
|
24397
24819
|
};
|
|
24398
24820
|
checkClientStatus = callback => {
|
|
24399
|
-
// using this function , first it will check mic permission is given or not
|
|
24400
|
-
// then it will check if transport is intialize or not
|
|
24401
|
-
// then it will check if user is registered or not
|
|
24402
|
-
// based on this we can evaludate SDK is ready for call
|
|
24403
24821
|
var constraints = {
|
|
24404
24822
|
audio: true,
|
|
24405
24823
|
video: false
|
|
24406
24824
|
};
|
|
24407
24825
|
navigator.mediaDevices.getUserMedia(constraints).then(function (mediaStream) {
|
|
24408
|
-
var transportState =
|
|
24826
|
+
var transportState = this.webrtcSIPPhone.getTransportState();
|
|
24409
24827
|
transportState = transportState.toLowerCase();
|
|
24410
24828
|
switch (transportState) {
|
|
24411
24829
|
case "":
|
|
@@ -24416,7 +24834,7 @@ class ExotelWebClient {
|
|
|
24416
24834
|
callback(transportState);
|
|
24417
24835
|
break;
|
|
24418
24836
|
default:
|
|
24419
|
-
var registerationState =
|
|
24837
|
+
var registerationState = this.webrtcSIPPhone.getRegistrationState();
|
|
24420
24838
|
registerationState = registerationState.toLowerCase();
|
|
24421
24839
|
switch (registerationState) {
|
|
24422
24840
|
case "":
|
|
@@ -24434,27 +24852,40 @@ class ExotelWebClient {
|
|
|
24434
24852
|
}
|
|
24435
24853
|
}
|
|
24436
24854
|
}).catch(function (error) {
|
|
24437
|
-
logger.log("something went wrong during checkClientStatus ", error);
|
|
24855
|
+
logger.log("ExWebClient: checkClientStatus: something went wrong during checkClientStatus ", error);
|
|
24438
24856
|
callback("media_permission_denied");
|
|
24439
24857
|
});
|
|
24440
24858
|
};
|
|
24441
24859
|
changeAudioInputDevice(deviceId, onSuccess, onError) {
|
|
24442
|
-
logger.log(`
|
|
24443
|
-
|
|
24860
|
+
logger.log(`ExWebClient: changeAudioInputDevice: Entry`);
|
|
24861
|
+
this.webrtcSIPPhone.changeAudioInputDevice(deviceId, onSuccess, onError);
|
|
24444
24862
|
}
|
|
24445
24863
|
changeAudioOutputDevice(deviceId, onSuccess, onError) {
|
|
24446
|
-
logger.log(`
|
|
24447
|
-
|
|
24864
|
+
logger.log(`ExWebClient: changeAudioOutputDevice: Entry`);
|
|
24865
|
+
this.webrtcSIPPhone.changeAudioOutputDevice(deviceId, onSuccess, onError);
|
|
24866
|
+
}
|
|
24867
|
+
downloadLogs() {
|
|
24868
|
+
logger.log(`ExWebClient: downloadLogs: Entry`);
|
|
24869
|
+
_api_LogManager_js__WEBPACK_IMPORTED_MODULE_10__["default"].downloadLogs();
|
|
24448
24870
|
}
|
|
24449
24871
|
setPreferredCodec(codecName) {
|
|
24450
|
-
logger.log("ExWebClient:setPreferredCodec
|
|
24451
|
-
|
|
24872
|
+
logger.log("ExWebClient: setPreferredCodec: Entry");
|
|
24873
|
+
if (!this.webrtcSIPPhone || !this.webrtcSIPPhone.phone) {
|
|
24874
|
+
logger.warn("ExWebClient: setPreferredCodec: Phone not initialized");
|
|
24875
|
+
return;
|
|
24876
|
+
}
|
|
24877
|
+
this.webrtcSIPPhone.setPreferredCodec(codecName);
|
|
24452
24878
|
}
|
|
24453
24879
|
registerLoggerCallback(callback) {
|
|
24454
|
-
|
|
24880
|
+
this.clientSDKLoggerCallback = callback;
|
|
24455
24881
|
}
|
|
24456
24882
|
registerAudioDeviceChangeCallback(audioInputDeviceChangeCallback, audioOutputDeviceChangeCallback, onDeviceChangeCallback) {
|
|
24457
|
-
|
|
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);
|
|
24458
24889
|
}
|
|
24459
24890
|
}
|
|
24460
24891
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ExotelWebClient);
|
|
@@ -24474,35 +24905,43 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
24474
24905
|
/* harmony export */ });
|
|
24475
24906
|
/* harmony import */ var _Callback__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Callback */ "./src/listeners/Callback.js");
|
|
24476
24907
|
|
|
24477
|
-
|
|
24478
24908
|
class ExotelVoiceClientListener {
|
|
24909
|
+
registerCallback = null;
|
|
24910
|
+
constructor(registerCallback) {
|
|
24911
|
+
this.registerCallback = registerCallback;
|
|
24912
|
+
}
|
|
24479
24913
|
onInitializationSuccess(phone) {
|
|
24480
24914
|
/**
|
|
24481
24915
|
* Abstract class for Initialization Success
|
|
24482
24916
|
*/
|
|
24483
|
-
|
|
24917
|
+
this.registerCallback.initializeRegister("registered", phone);
|
|
24484
24918
|
/**
|
|
24485
24919
|
* Triggers UI callback to indicate the status of the registered phone
|
|
24486
24920
|
*/
|
|
24487
|
-
|
|
24921
|
+
this.registerCallback.triggerRegisterCallback();
|
|
24488
24922
|
_Callback__WEBPACK_IMPORTED_MODULE_0__.diagnosticsCallback.triggerKeyValueSetCallback("userReg", "registered", phone);
|
|
24489
24923
|
}
|
|
24490
24924
|
onInitializationFailure(phone) {
|
|
24491
24925
|
/**
|
|
24492
24926
|
* If register fails send error message to Callback function
|
|
24493
24927
|
*/
|
|
24494
|
-
|
|
24495
|
-
|
|
24928
|
+
this.registerCallback.initializeRegister("unregistered", phone);
|
|
24929
|
+
this.registerCallback.triggerRegisterCallback();
|
|
24496
24930
|
_Callback__WEBPACK_IMPORTED_MODULE_0__.diagnosticsCallback.triggerKeyValueSetCallback("userReg", "unregistered", phone);
|
|
24497
24931
|
}
|
|
24498
24932
|
onInitializationWaiting(phone) {
|
|
24499
24933
|
/**
|
|
24500
24934
|
* If register fails send error message to Callback function
|
|
24501
24935
|
*/
|
|
24502
|
-
|
|
24503
|
-
|
|
24936
|
+
this.registerCallback.initializeRegister("sent_request", phone);
|
|
24937
|
+
this.registerCallback.triggerRegisterCallback();
|
|
24504
24938
|
_Callback__WEBPACK_IMPORTED_MODULE_0__.diagnosticsCallback.triggerKeyValueSetCallback("userReg", "sent_request", phone);
|
|
24505
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
|
+
}
|
|
24506
24945
|
onLog(LogLevel, tag, message) {
|
|
24507
24946
|
/**
|
|
24508
24947
|
* To get SDK logs
|
|
@@ -24528,126 +24967,138 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
24528
24967
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
24529
24968
|
/* harmony export */ SessionListener: () => (/* binding */ SessionListener)
|
|
24530
24969
|
/* harmony export */ });
|
|
24531
|
-
/* harmony import */ var
|
|
24532
|
-
/* harmony import */ var
|
|
24533
|
-
/* harmony import */ var _constants_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../constants/common */ "./src/constants/common.js");
|
|
24534
|
-
/* 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");
|
|
24535
|
-
|
|
24536
|
-
|
|
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");
|
|
24537
24972
|
|
|
24538
24973
|
|
|
24539
|
-
|
|
24974
|
+
const logger = (0,_exotel_npm_dev_webrtc_core_sdk__WEBPACK_IMPORTED_MODULE_0__.getLogger)();
|
|
24540
24975
|
/**
|
|
24541
24976
|
* Session listeners is invoked when user opens two tabs, the data in tab 1 is
|
|
24542
24977
|
* copied into tab 2
|
|
24543
24978
|
*/
|
|
24544
|
-
|
|
24545
|
-
|
|
24546
|
-
|
|
24547
|
-
|
|
24548
|
-
|
|
24549
|
-
|
|
24550
|
-
|
|
24551
|
-
|
|
24552
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.initializeSession('logout', '');
|
|
24553
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.triggerSessionCallback();
|
|
24554
|
-
} else if (event.data.message == 'login-successful') {
|
|
24555
|
-
const loginObj = {
|
|
24556
|
-
phone: window.localStorage.getItem('currentUser'),
|
|
24557
|
-
tabHash: event.data.tabHash
|
|
24558
|
-
};
|
|
24559
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.initializeSession('login-successful', JSON.stringify(loginObj));
|
|
24560
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.triggerSessionCallback();
|
|
24561
|
-
} else if (window.sessionStorage.getItem("activeSessionTab") !== null) {
|
|
24562
|
-
if (event.data.callState !== null && event.data.callState !== undefined) {
|
|
24563
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.initializeSession(event.data.callState, event.data.callNumber);
|
|
24564
|
-
}
|
|
24565
|
-
_Callback__WEBPACK_IMPORTED_MODULE_0__.sessionCallback.triggerSessionCallback();
|
|
24566
|
-
}
|
|
24567
|
-
});
|
|
24568
|
-
/**
|
|
24569
|
-
* Add listeners for all storage events
|
|
24570
|
-
*/
|
|
24571
|
-
window.localStorage.setItem('REQUESTING_SHARED_CREDENTIALS', Date.now().toString());
|
|
24572
|
-
window.localStorage.removeItem('REQUESTING_SHARED_CREDENTIALS');
|
|
24573
|
-
const credentials = {
|
|
24574
|
-
user: window.sessionStorage.getItem('user'),
|
|
24575
|
-
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);
|
|
24576
24987
|
};
|
|
24577
|
-
|
|
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
|
+
});
|
|
24578
25019
|
/**
|
|
24579
|
-
|
|
24580
|
-
|
|
24581
|
-
|
|
24582
|
-
|
|
24583
|
-
|
|
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 => {
|
|
24584
25029
|
/**
|
|
24585
|
-
|
|
24586
|
-
|
|
24587
|
-
|
|
24588
|
-
|
|
24589
|
-
|
|
24590
|
-
|
|
24591
|
-
|
|
24592
|
-
|
|
24593
|
-
|
|
24594
|
-
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();
|
|
24595
25039
|
}
|
|
24596
|
-
/**
|
|
24597
|
-
* Fetch the array of tabs and add the tab, put it on session also
|
|
24598
|
-
*/
|
|
24599
|
-
const currentTab = {
|
|
24600
|
-
tabID: (0,uuid__WEBPACK_IMPORTED_MODULE_3__["default"])(),
|
|
24601
|
-
tabType: 'child',
|
|
24602
|
-
tabStatus: 'active'
|
|
24603
|
-
};
|
|
24604
|
-
const tabArr = JSON.parse(window.localStorage.getItem('tabs'));
|
|
24605
|
-
/** Based on activeSessionTab id fetch the type */
|
|
24606
25040
|
|
|
24607
|
-
if (
|
|
24608
|
-
|
|
24609
|
-
|
|
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 */
|
|
24610
25061
|
|
|
24611
|
-
|
|
24612
|
-
|
|
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));
|
|
24613
25071
|
const lastIndex = tabArr.length - 1;
|
|
24614
25072
|
window.sessionStorage.setItem('activeSessionTab', tabArr[lastIndex].tabID);
|
|
24615
25073
|
}
|
|
24616
25074
|
} else {
|
|
24617
|
-
|
|
24618
|
-
|
|
24619
|
-
window.localStorage.setItem('tabs', JSON.stringify(tabArr));
|
|
25075
|
+
/** pull from the tabarray and then add it to the session storage */
|
|
25076
|
+
|
|
24620
25077
|
const lastIndex = tabArr.length - 1;
|
|
24621
25078
|
window.sessionStorage.setItem('activeSessionTab', tabArr[lastIndex].tabID);
|
|
24622
25079
|
}
|
|
24623
|
-
|
|
24624
|
-
|
|
24625
|
-
|
|
24626
|
-
const lastIndex = tabArr.length - 1;
|
|
24627
|
-
window.sessionStorage.setItem('activeSessionTab', tabArr[lastIndex].tabID);
|
|
25080
|
+
//window.localStorage.setItem('selectedPhone', newData.selectedPhone);
|
|
25081
|
+
return;
|
|
25082
|
+
//}
|
|
24628
25083
|
}
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
|
|
24632
|
-
|
|
24633
|
-
|
|
24634
|
-
|
|
24635
|
-
|
|
24636
|
-
|
|
24637
|
-
|
|
24638
|
-
|
|
24639
|
-
|
|
24640
|
-
|
|
24641
|
-
|
|
24642
|
-
|
|
24643
|
-
|
|
24644
|
-
|
|
24645
|
-
|
|
24646
|
-
window.sessionStorage.removeItem('activeSession');
|
|
24647
|
-
}
|
|
24648
|
-
});
|
|
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
|
+
}
|
|
24649
25101
|
}
|
|
24650
|
-
;
|
|
24651
25102
|
|
|
24652
25103
|
/***/ }),
|
|
24653
25104
|
|
|
@@ -24977,12 +25428,11 @@ var __webpack_exports__ = {};
|
|
|
24977
25428
|
\******************/
|
|
24978
25429
|
__webpack_require__.r(__webpack_exports__);
|
|
24979
25430
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
24980
|
-
/* harmony export */ ExDelegationHandler: () => (/* reexport safe */ _src_listeners_ExWebClient__WEBPACK_IMPORTED_MODULE_0__.ExDelegationHandler),
|
|
24981
|
-
/* harmony export */ ExSynchronousHandler: () => (/* reexport safe */ _src_listeners_ExWebClient__WEBPACK_IMPORTED_MODULE_0__.ExSynchronousHandler),
|
|
24982
25431
|
/* harmony export */ ExotelWebClient: () => (/* reexport safe */ _src_listeners_ExWebClient__WEBPACK_IMPORTED_MODULE_0__.ExotelWebClient)
|
|
24983
25432
|
/* harmony export */ });
|
|
24984
25433
|
/* harmony import */ var _src_listeners_ExWebClient__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/listeners/ExWebClient */ "./src/listeners/ExWebClient.js");
|
|
24985
25434
|
|
|
25435
|
+
|
|
24986
25436
|
})();
|
|
24987
25437
|
|
|
24988
25438
|
/******/ return __webpack_exports__;
|