@wazo/sdk 0.37.20 → 0.37.24
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/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +91 -21
- package/esm/__tests__/web-rtc-client.test.js +214 -165
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +26 -3
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +34 -4
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +56 -9
- package/esm/api/ctid-ng.js +38 -5
- package/esm/api/dird.js +29 -3
- package/esm/api/webhookd.js +26 -3
- package/esm/api-client.js +91 -21
- package/esm/checker/Checker.js +241 -190
- package/esm/checker/checks/aor.js +91 -21
- package/esm/checker/checks/api.js +91 -21
- package/esm/checker/checks/index.js +231 -180
- package/esm/checker/checks/wazo-websocket.js +42 -17
- package/esm/checker/checks/webrtc-transport.js +214 -165
- package/esm/checker/checks/webrtc.js +214 -165
- package/esm/domain/AdHocAPIConference.js +91 -21
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +8 -1
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +4 -1
- package/esm/domain/Features.js +91 -21
- package/esm/domain/Meeting.js +28 -5
- package/esm/domain/Phone/CTIPhone.js +109 -35
- package/esm/domain/Phone/WebRTCPhone.js +159 -102
- package/esm/domain/Recording.js +3 -0
- package/esm/domain/Voicemail.js +3 -0
- package/esm/domain/__tests__/Call.test.js +3 -0
- package/esm/domain/__tests__/CallLog.test.js +8 -1
- package/esm/domain/__tests__/Contact.test.js +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +509 -414
- package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
- package/esm/service/CallApi.js +91 -21
- package/esm/service/IssueReporter.js +26 -3
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +91 -21
- package/esm/simple/Auth.js +499 -404
- package/esm/simple/Configuration.js +499 -404
- package/esm/simple/Directory.js +91 -21
- package/esm/simple/Phone.js +499 -404
- package/esm/simple/Websocket.js +45 -19
- package/esm/simple/index.js +503 -408
- package/esm/simple/room/LocalParticipant.js +503 -408
- package/esm/simple/room/Participant.js +503 -408
- package/esm/simple/room/RemoteParticipant.js +503 -408
- package/esm/simple/room/Room.js +504 -409
- package/esm/simple/room/SipRoom.js +503 -408
- package/esm/simple/room/Stream.js +503 -408
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/esm/simple/utils.js +503 -408
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +214 -165
- package/esm/websocket-client.js +43 -18
- package/lib/__tests__/api-client.test.js +91 -21
- package/lib/__tests__/web-rtc-client.test.js +214 -165
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +26 -3
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +34 -4
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +56 -9
- package/lib/api/ctid-ng.js +38 -5
- package/lib/api/dird.js +29 -3
- package/lib/api/webhookd.js +26 -3
- package/lib/api-client.js +91 -21
- package/lib/checker/Checker.js +241 -190
- package/lib/checker/checks/aor.js +91 -21
- package/lib/checker/checks/api.js +91 -21
- package/lib/checker/checks/index.js +231 -180
- package/lib/checker/checks/wazo-websocket.js +42 -17
- package/lib/checker/checks/webrtc-transport.js +214 -165
- package/lib/checker/checks/webrtc.js +214 -165
- package/lib/domain/AdHocAPIConference.js +91 -21
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +8 -1
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +4 -1
- package/lib/domain/Features.js +91 -21
- package/lib/domain/Meeting.js +32 -5
- package/lib/domain/Phone/CTIPhone.js +109 -35
- package/lib/domain/Phone/WebRTCPhone.js +159 -102
- package/lib/domain/Recording.js +3 -0
- package/lib/domain/Voicemail.js +3 -0
- package/lib/domain/__tests__/Call.test.js +3 -0
- package/lib/domain/__tests__/CallLog.test.js +8 -1
- package/lib/domain/__tests__/Contact.test.js +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +509 -414
- package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
- package/lib/service/CallApi.js +91 -21
- package/lib/service/IssueReporter.js +26 -3
- package/lib/service/__tests__/IssueReporter.test.js +26 -3
- package/lib/service/getApiClient.js +91 -21
- package/lib/simple/Auth.js +499 -404
- package/lib/simple/Configuration.js +499 -404
- package/lib/simple/Directory.js +91 -21
- package/lib/simple/Phone.js +499 -404
- package/lib/simple/Websocket.js +45 -19
- package/lib/simple/index.js +503 -408
- package/lib/simple/room/LocalParticipant.js +503 -408
- package/lib/simple/room/Participant.js +503 -408
- package/lib/simple/room/RemoteParticipant.js +503 -408
- package/lib/simple/room/Room.js +504 -409
- package/lib/simple/room/SipRoom.js +503 -408
- package/lib/simple/room/Stream.js +503 -408
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/lib/simple/utils.js +503 -408
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +214 -165
- package/lib/websocket-client.js +43 -17
- package/package.json +1 -1
- package/src/api/confd.js +5 -2
- package/src/domain/Call.js +3 -0
- package/src/domain/CallLog.js +4 -0
- package/src/domain/ChatMessage.js +4 -0
- package/src/domain/ChatRoom.js +3 -0
- package/src/domain/Contact.js +3 -0
- package/src/domain/Meeting.js +28 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +49 -15
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -0
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +1 -35
- package/src/service/IssueReporter.js +25 -2
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +41 -24
- package/src/websocket-client.js +2 -0
package/lib/simple/index.js
CHANGED
|
@@ -873,6 +873,9 @@ class Contact {
|
|
|
873
873
|
}
|
|
874
874
|
|
|
875
875
|
static parseMany(response ) {
|
|
876
|
+
if (!response || !response.results) {
|
|
877
|
+
return [];
|
|
878
|
+
}
|
|
876
879
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
877
880
|
}
|
|
878
881
|
|
|
@@ -1644,6 +1647,7 @@ class IssueReporter {
|
|
|
1644
1647
|
|
|
1645
1648
|
|
|
1646
1649
|
|
|
1650
|
+
|
|
1647
1651
|
|
|
1648
1652
|
constructor() {
|
|
1649
1653
|
addLevelsTo(this);
|
|
@@ -1655,12 +1659,17 @@ class IssueReporter {
|
|
|
1655
1659
|
this.bufferTimeout = null;
|
|
1656
1660
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
1657
1661
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
1662
|
+
this._callback = null;
|
|
1658
1663
|
}
|
|
1659
1664
|
|
|
1660
1665
|
init() {
|
|
1661
1666
|
this._catchConsole();
|
|
1662
1667
|
}
|
|
1663
1668
|
|
|
1669
|
+
setCallback(cb ) {
|
|
1670
|
+
this._callback = cb;
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1664
1673
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
1665
1674
|
this.remoteClientConfiguration = configuration;
|
|
1666
1675
|
}
|
|
@@ -1696,6 +1705,7 @@ class IssueReporter {
|
|
|
1696
1705
|
|
|
1697
1706
|
// Handle category label
|
|
1698
1707
|
let category = null;
|
|
1708
|
+
let skipSendToRemote = false;
|
|
1699
1709
|
let extra = {};
|
|
1700
1710
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
1701
1711
|
category = args[0].split('=')[1];
|
|
@@ -1711,6 +1721,7 @@ class IssueReporter {
|
|
|
1711
1721
|
errorMessage: lastArg.message,
|
|
1712
1722
|
errorStack: lastArg.stack,
|
|
1713
1723
|
errorType: lastArg.constructor.name,
|
|
1724
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
1714
1725
|
};
|
|
1715
1726
|
} else {
|
|
1716
1727
|
extra = lastArg;
|
|
@@ -1719,6 +1730,11 @@ class IssueReporter {
|
|
|
1719
1730
|
args.splice(1, 1);
|
|
1720
1731
|
}
|
|
1721
1732
|
|
|
1733
|
+
if (extra.skipSendToRemote) {
|
|
1734
|
+
skipSendToRemote = true;
|
|
1735
|
+
delete extra.skipSendToRemote;
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1722
1738
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
1723
1739
|
const message = args.join(', ');
|
|
1724
1740
|
let consoleMessage = message;
|
|
@@ -1739,7 +1755,13 @@ class IssueReporter {
|
|
|
1739
1755
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
1740
1756
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
1741
1757
|
|
|
1742
|
-
this.
|
|
1758
|
+
if (this._callback) {
|
|
1759
|
+
this._callback(level, consoleMessage);
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
if (!skipSendToRemote) {
|
|
1763
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
1764
|
+
}
|
|
1743
1765
|
}
|
|
1744
1766
|
|
|
1745
1767
|
logRequest(url , options , response , start ) {
|
|
@@ -1884,7 +1906,11 @@ class IssueReporter {
|
|
|
1884
1906
|
},
|
|
1885
1907
|
// $FlowFixMe
|
|
1886
1908
|
body,
|
|
1887
|
-
}).catch(() => {
|
|
1909
|
+
}).catch((e ) => {
|
|
1910
|
+
// $FlowFixMe
|
|
1911
|
+
e.skipSendToRemote = true;
|
|
1912
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
1913
|
+
|
|
1888
1914
|
setTimeout(() => {
|
|
1889
1915
|
if (isArray) {
|
|
1890
1916
|
payload = payload.map(message => {
|
|
@@ -1931,7 +1957,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
1931
1957
|
|
|
1932
1958
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
1933
1959
|
|
|
1934
|
-
const logger
|
|
1960
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1935
1961
|
|
|
1936
1962
|
// Use a function here to be able to mock it in tests
|
|
1937
1963
|
const realFetch = () => {
|
|
@@ -2070,7 +2096,7 @@ class ApiRequester {
|
|
|
2070
2096
|
};
|
|
2071
2097
|
|
|
2072
2098
|
if (this.refreshTokenPromise) {
|
|
2073
|
-
logger
|
|
2099
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
2074
2100
|
await this.refreshTokenPromise;
|
|
2075
2101
|
}
|
|
2076
2102
|
|
|
@@ -2090,7 +2116,7 @@ class ApiRequester {
|
|
|
2090
2116
|
return promise.then(async (err ) => {
|
|
2091
2117
|
// Check if the token is still valid
|
|
2092
2118
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
2093
|
-
logger
|
|
2119
|
+
logger.warn('token expired', { error: err.reason });
|
|
2094
2120
|
// Replay the call after refreshing the token
|
|
2095
2121
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
2096
2122
|
}
|
|
@@ -2100,7 +2126,7 @@ class ApiRequester {
|
|
|
2100
2126
|
: exceptionClass.fromResponse(err, response.status);
|
|
2101
2127
|
|
|
2102
2128
|
if (this.shouldLogErrors) {
|
|
2103
|
-
logger
|
|
2129
|
+
logger.error('API error', error);
|
|
2104
2130
|
}
|
|
2105
2131
|
|
|
2106
2132
|
throw error;
|
|
@@ -2110,7 +2136,7 @@ class ApiRequester {
|
|
|
2110
2136
|
return newParse(response, isJson);
|
|
2111
2137
|
}).catch(error => {
|
|
2112
2138
|
if (this.shouldLogErrors) {
|
|
2113
|
-
logger
|
|
2139
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
2114
2140
|
}
|
|
2115
2141
|
|
|
2116
2142
|
throw error;
|
|
@@ -2138,13 +2164,13 @@ class ApiRequester {
|
|
|
2138
2164
|
) {
|
|
2139
2165
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
2140
2166
|
let newPath = path;
|
|
2141
|
-
logger
|
|
2167
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
2142
2168
|
|
|
2143
2169
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
2144
2170
|
|
|
2145
2171
|
return this.refreshTokenPromise.then(() => {
|
|
2146
2172
|
this.refreshTokenPromise = null;
|
|
2147
|
-
logger
|
|
2173
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
2148
2174
|
if (isTokenNotFound) {
|
|
2149
2175
|
const pathParts = path.split('/');
|
|
2150
2176
|
pathParts.pop();
|
|
@@ -2614,8 +2640,9 @@ class ExternalApp {
|
|
|
2614
2640
|
|
|
2615
2641
|
|
|
2616
2642
|
|
|
2617
|
-
|
|
2643
|
+
|
|
2618
2644
|
|
|
2645
|
+
|
|
2619
2646
|
|
|
2620
2647
|
|
|
2621
2648
|
class Meeting {
|
|
@@ -2626,9 +2653,10 @@ class Meeting {
|
|
|
2626
2653
|
|
|
2627
2654
|
|
|
2628
2655
|
|
|
2629
|
-
|
|
2656
|
+
|
|
2630
2657
|
|
|
2631
2658
|
|
|
2659
|
+
|
|
2632
2660
|
|
|
2633
2661
|
static parse(plain ) {
|
|
2634
2662
|
return new Meeting({
|
|
@@ -2638,24 +2666,43 @@ class Meeting {
|
|
|
2638
2666
|
ownerUuids: plain.owner_uuids,
|
|
2639
2667
|
port: plain.port,
|
|
2640
2668
|
uuid: plain.uuid,
|
|
2641
|
-
|
|
2669
|
+
extension: plain.exten,
|
|
2642
2670
|
persistent: plain.persistent,
|
|
2671
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2643
2672
|
});
|
|
2644
2673
|
}
|
|
2645
2674
|
|
|
2675
|
+
static parseMany(items ) {
|
|
2676
|
+
if (!items) {
|
|
2677
|
+
return [];
|
|
2678
|
+
}
|
|
2679
|
+
return items.map(plain => Meeting.parse(plain));
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2646
2682
|
static newFrom(meeting ) {
|
|
2647
2683
|
return newFrom(meeting, Meeting);
|
|
2648
2684
|
}
|
|
2649
2685
|
|
|
2650
|
-
constructor({
|
|
2686
|
+
constructor({
|
|
2687
|
+
uuid,
|
|
2688
|
+
name,
|
|
2689
|
+
guestSipAuthorization,
|
|
2690
|
+
ownerUuids,
|
|
2691
|
+
port,
|
|
2692
|
+
uri,
|
|
2693
|
+
extension,
|
|
2694
|
+
persistent,
|
|
2695
|
+
creationTime,
|
|
2696
|
+
} = {}) {
|
|
2651
2697
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2652
2698
|
this.uri = uri;
|
|
2653
2699
|
this.name = name;
|
|
2654
2700
|
this.ownerUuids = ownerUuids;
|
|
2655
2701
|
this.port = port;
|
|
2656
2702
|
this.uuid = uuid;
|
|
2657
|
-
this.
|
|
2703
|
+
this.extension = extension;
|
|
2658
2704
|
this.persistent = persistent;
|
|
2705
|
+
this.creationTime = creationTime;
|
|
2659
2706
|
|
|
2660
2707
|
// Useful to compare instead of instanceof with minified code
|
|
2661
2708
|
this.type = 'Meeting';
|
|
@@ -2733,8 +2780,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2733
2780
|
}
|
|
2734
2781
|
},
|
|
2735
2782
|
|
|
2736
|
-
|
|
2737
|
-
client.
|
|
2783
|
+
getMyMeetings: () =>
|
|
2784
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2785
|
+
|
|
2786
|
+
createMyMeeting: (name , persistent ) =>
|
|
2787
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
2738
2788
|
|
|
2739
2789
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2740
2790
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2830,6 +2880,10 @@ class ChatMessage {
|
|
|
2830
2880
|
|
|
2831
2881
|
|
|
2832
2882
|
static parseMany(plain ) {
|
|
2883
|
+
if (!plain || !plain.items) {
|
|
2884
|
+
return [];
|
|
2885
|
+
}
|
|
2886
|
+
|
|
2833
2887
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2834
2888
|
}
|
|
2835
2889
|
|
|
@@ -2939,6 +2993,9 @@ class Voicemail {
|
|
|
2939
2993
|
}
|
|
2940
2994
|
|
|
2941
2995
|
static parseMany(plain ) {
|
|
2996
|
+
if (!plain) {
|
|
2997
|
+
return [];
|
|
2998
|
+
}
|
|
2942
2999
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2943
3000
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2944
3001
|
|
|
@@ -3048,6 +3105,9 @@ class Call {
|
|
|
3048
3105
|
|
|
3049
3106
|
|
|
3050
3107
|
static parseMany(plain ) {
|
|
3108
|
+
if (!plain) {
|
|
3109
|
+
return [];
|
|
3110
|
+
}
|
|
3051
3111
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3052
3112
|
}
|
|
3053
3113
|
|
|
@@ -3591,6 +3651,9 @@ class Recording {
|
|
|
3591
3651
|
|
|
3592
3652
|
|
|
3593
3653
|
static parseMany(recordings = []) {
|
|
3654
|
+
if (!recordings) {
|
|
3655
|
+
return [];
|
|
3656
|
+
}
|
|
3594
3657
|
return recordings.map(item => Recording.parse(item));
|
|
3595
3658
|
}
|
|
3596
3659
|
|
|
@@ -3692,6 +3755,10 @@ class CallLog {
|
|
|
3692
3755
|
}
|
|
3693
3756
|
|
|
3694
3757
|
static parseMany(plain ) {
|
|
3758
|
+
if (!plain || !plain.items) {
|
|
3759
|
+
return [];
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3695
3762
|
return plain.items.map(item => CallLog.parse(item));
|
|
3696
3763
|
}
|
|
3697
3764
|
|
|
@@ -3996,7 +4063,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3996
4063
|
|
|
3997
4064
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3998
4065
|
|
|
3999
|
-
const logger$
|
|
4066
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4000
4067
|
|
|
4001
4068
|
class CTIPhone extends Emitter {
|
|
4002
4069
|
|
|
@@ -4009,7 +4076,7 @@ class CTIPhone extends Emitter {
|
|
|
4009
4076
|
|
|
4010
4077
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4011
4078
|
super();
|
|
4012
|
-
logger$
|
|
4079
|
+
logger$1.info('CTI Phone created');
|
|
4013
4080
|
this.session = session;
|
|
4014
4081
|
this.isMobile = isMobile;
|
|
4015
4082
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4070,7 +4137,7 @@ class CTIPhone extends Emitter {
|
|
|
4070
4137
|
}
|
|
4071
4138
|
|
|
4072
4139
|
async makeCall(number , line ) {
|
|
4073
|
-
logger$
|
|
4140
|
+
logger$1.info('make CTI call', { number });
|
|
4074
4141
|
|
|
4075
4142
|
if (!number) {
|
|
4076
4143
|
return null;
|
|
@@ -4093,7 +4160,7 @@ class CTIPhone extends Emitter {
|
|
|
4093
4160
|
if (!callSession) {
|
|
4094
4161
|
return Promise.resolve(null);
|
|
4095
4162
|
}
|
|
4096
|
-
logger$
|
|
4163
|
+
logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4097
4164
|
|
|
4098
4165
|
if (!this.currentCall) {
|
|
4099
4166
|
this.currentCall = callSession.call;
|
|
@@ -4106,7 +4173,7 @@ class CTIPhone extends Emitter {
|
|
|
4106
4173
|
if (!callSession) {
|
|
4107
4174
|
return;
|
|
4108
4175
|
}
|
|
4109
|
-
logger$
|
|
4176
|
+
logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4110
4177
|
|
|
4111
4178
|
this.currentCall = undefined;
|
|
4112
4179
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4116,7 +4183,7 @@ class CTIPhone extends Emitter {
|
|
|
4116
4183
|
if (!callSession) {
|
|
4117
4184
|
return Promise.resolve(false);
|
|
4118
4185
|
}
|
|
4119
|
-
logger$
|
|
4186
|
+
logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4120
4187
|
|
|
4121
4188
|
try {
|
|
4122
4189
|
await CallApi.cancelCall(callSession);
|
|
@@ -4127,7 +4194,7 @@ class CTIPhone extends Emitter {
|
|
|
4127
4194
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4128
4195
|
return true;
|
|
4129
4196
|
} catch (e) {
|
|
4130
|
-
logger$
|
|
4197
|
+
logger$1.error('hangup CTI call, error', e);
|
|
4131
4198
|
|
|
4132
4199
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4133
4200
|
return false;
|
|
@@ -4140,7 +4207,7 @@ class CTIPhone extends Emitter {
|
|
|
4140
4207
|
if (!callSession) {
|
|
4141
4208
|
return;
|
|
4142
4209
|
}
|
|
4143
|
-
logger$
|
|
4210
|
+
logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4144
4211
|
|
|
4145
4212
|
await CallApi.cancelCall(callSession);
|
|
4146
4213
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4150,7 +4217,7 @@ class CTIPhone extends Emitter {
|
|
|
4150
4217
|
if (!callSession) {
|
|
4151
4218
|
return;
|
|
4152
4219
|
}
|
|
4153
|
-
logger$
|
|
4220
|
+
logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4154
4221
|
|
|
4155
4222
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4156
4223
|
}
|
|
@@ -4163,19 +4230,19 @@ class CTIPhone extends Emitter {
|
|
|
4163
4230
|
if (!callSession) {
|
|
4164
4231
|
return;
|
|
4165
4232
|
}
|
|
4166
|
-
logger$
|
|
4233
|
+
logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4167
4234
|
|
|
4168
4235
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4169
4236
|
}
|
|
4170
4237
|
|
|
4171
4238
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4172
|
-
logger$
|
|
4239
|
+
logger$1.info('cancel CTI transfer', { transferId });
|
|
4173
4240
|
|
|
4174
4241
|
return CallApi.cancelCallTransfer(transferId);
|
|
4175
4242
|
}
|
|
4176
4243
|
|
|
4177
4244
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4178
|
-
logger$
|
|
4245
|
+
logger$1.info('confirm CTI transfer', { transferId });
|
|
4179
4246
|
|
|
4180
4247
|
return CallApi.confirmCallTransfer(transferId);
|
|
4181
4248
|
}
|
|
@@ -4184,19 +4251,19 @@ class CTIPhone extends Emitter {
|
|
|
4184
4251
|
if (!callSession) {
|
|
4185
4252
|
return;
|
|
4186
4253
|
}
|
|
4187
|
-
logger$
|
|
4254
|
+
logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4188
4255
|
|
|
4189
4256
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4190
4257
|
}
|
|
4191
4258
|
|
|
4192
4259
|
onConnectionMade() {
|
|
4193
|
-
logger$
|
|
4260
|
+
logger$1.info('on CTI connection made');
|
|
4194
4261
|
|
|
4195
4262
|
this.eventEmitter.emit('onCallAccepted');
|
|
4196
4263
|
}
|
|
4197
4264
|
|
|
4198
4265
|
async close() {
|
|
4199
|
-
logger$
|
|
4266
|
+
logger$1.info('CTI close');
|
|
4200
4267
|
|
|
4201
4268
|
return Promise.resolve();
|
|
4202
4269
|
}
|
|
@@ -4205,7 +4272,7 @@ class CTIPhone extends Emitter {
|
|
|
4205
4272
|
if (!callSession) {
|
|
4206
4273
|
return;
|
|
4207
4274
|
}
|
|
4208
|
-
logger$
|
|
4275
|
+
logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4209
4276
|
|
|
4210
4277
|
return CallApi.hold(callSession.callId);
|
|
4211
4278
|
}
|
|
@@ -4214,7 +4281,7 @@ class CTIPhone extends Emitter {
|
|
|
4214
4281
|
if (!callSession) {
|
|
4215
4282
|
return;
|
|
4216
4283
|
}
|
|
4217
|
-
logger$
|
|
4284
|
+
logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4218
4285
|
|
|
4219
4286
|
return CallApi.resume(callSession.callId);
|
|
4220
4287
|
}
|
|
@@ -4223,7 +4290,7 @@ class CTIPhone extends Emitter {
|
|
|
4223
4290
|
if (!callSession) {
|
|
4224
4291
|
return;
|
|
4225
4292
|
}
|
|
4226
|
-
logger$
|
|
4293
|
+
logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4227
4294
|
|
|
4228
4295
|
return CallApi.mute(callSession.callId);
|
|
4229
4296
|
}
|
|
@@ -4232,7 +4299,7 @@ class CTIPhone extends Emitter {
|
|
|
4232
4299
|
if (!callSession) {
|
|
4233
4300
|
return;
|
|
4234
4301
|
}
|
|
4235
|
-
logger$
|
|
4302
|
+
logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4236
4303
|
|
|
4237
4304
|
return CallApi.unmute(callSession.callId);
|
|
4238
4305
|
}
|
|
@@ -4261,6 +4328,10 @@ class CTIPhone extends Emitter {
|
|
|
4261
4328
|
return false;
|
|
4262
4329
|
}
|
|
4263
4330
|
|
|
4331
|
+
hasAVideoTrack() {
|
|
4332
|
+
return false;
|
|
4333
|
+
}
|
|
4334
|
+
|
|
4264
4335
|
getLocalStreamForCall() {
|
|
4265
4336
|
return null;
|
|
4266
4337
|
}
|
|
@@ -4654,6 +4725,9 @@ class ChatRoom {
|
|
|
4654
4725
|
|
|
4655
4726
|
|
|
4656
4727
|
static parseMany(plain ) {
|
|
4728
|
+
if (!plain || !plain.items) {
|
|
4729
|
+
return [];
|
|
4730
|
+
}
|
|
4657
4731
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4658
4732
|
}
|
|
4659
4733
|
|
|
@@ -5234,7 +5308,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5234
5308
|
const WEBHOOKD_VERSION = '1.0';
|
|
5235
5309
|
const AMID_VERSION = '1.0';
|
|
5236
5310
|
|
|
5237
|
-
const logger$
|
|
5311
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5238
5312
|
|
|
5239
5313
|
class ApiClient {
|
|
5240
5314
|
|
|
@@ -5286,12 +5360,12 @@ class ApiClient {
|
|
|
5286
5360
|
}
|
|
5287
5361
|
|
|
5288
5362
|
async forceRefreshToken() {
|
|
5289
|
-
logger$
|
|
5363
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5290
5364
|
return this.refreshTokenCallback();
|
|
5291
5365
|
}
|
|
5292
5366
|
|
|
5293
5367
|
async refreshTokenCallback() {
|
|
5294
|
-
logger$
|
|
5368
|
+
logger$2.info('refresh token callback called', {
|
|
5295
5369
|
refreshToken: this.refreshToken,
|
|
5296
5370
|
refreshBackend: this.refreshBackend,
|
|
5297
5371
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5309,7 +5383,7 @@ class ApiClient {
|
|
|
5309
5383
|
this.isMobile,
|
|
5310
5384
|
);
|
|
5311
5385
|
|
|
5312
|
-
logger$
|
|
5386
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5313
5387
|
|
|
5314
5388
|
if (this.onRefreshToken) {
|
|
5315
5389
|
this.onRefreshToken(session.token, session);
|
|
@@ -5450,7 +5524,7 @@ var getApiClient = (forServer ) => {
|
|
|
5450
5524
|
class InvalidSubscription extends Error {}
|
|
5451
5525
|
class InvalidAuthorization extends Error {}
|
|
5452
5526
|
|
|
5453
|
-
const logger$
|
|
5527
|
+
const logger$3 = IssueReporter$1.loggerFor('simple-auth');
|
|
5454
5528
|
|
|
5455
5529
|
class Auth {
|
|
5456
5530
|
|
|
@@ -5485,7 +5559,7 @@ class Auth {
|
|
|
5485
5559
|
setApiClientId(this.clientId);
|
|
5486
5560
|
setRefreshExpiration(this.expiration);
|
|
5487
5561
|
setOnRefreshToken((token , session ) => {
|
|
5488
|
-
logger$
|
|
5562
|
+
logger$3.info('on refresh token done', { token });
|
|
5489
5563
|
setApiToken(token);
|
|
5490
5564
|
Wazo.Websocket.updateToken(token);
|
|
5491
5565
|
|
|
@@ -5530,7 +5604,7 @@ class Auth {
|
|
|
5530
5604
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
5531
5605
|
return this._onAuthenticated(rawSession);
|
|
5532
5606
|
} catch (e) {
|
|
5533
|
-
logger$
|
|
5607
|
+
logger$3.error('on validate token error', e);
|
|
5534
5608
|
console.warn(e);
|
|
5535
5609
|
return false;
|
|
5536
5610
|
}
|
|
@@ -5886,7 +5960,7 @@ class AdHocAPIConference {
|
|
|
5886
5960
|
|
|
5887
5961
|
/* */
|
|
5888
5962
|
|
|
5889
|
-
const parseCandidate
|
|
5963
|
+
const parseCandidate = (candidate ) => {
|
|
5890
5964
|
if (!candidate) {
|
|
5891
5965
|
return null;
|
|
5892
5966
|
}
|
|
@@ -5899,10 +5973,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5899
5973
|
candidates
|
|
5900
5974
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5901
5975
|
|
|
5902
|
-
const areCandidateValid = (candidates ) =>
|
|
5903
|
-
getSrflxOrRelay(candidates)
|
|
5904
|
-
.length > 0;
|
|
5905
|
-
|
|
5906
5976
|
const getVideoDirection = (sdp ) => {
|
|
5907
5977
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
5908
5978
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5955,8 +6025,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5955
6025
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5956
6026
|
|
|
5957
6027
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5958
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5959
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5960
6028
|
|
|
5961
6029
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5962
6030
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -6046,7 +6114,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6046
6114
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
6047
6115
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
6048
6116
|
if (event.candidate) {
|
|
6049
|
-
this.gatheredCandidates.push(parseCandidate
|
|
6117
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
6050
6118
|
}
|
|
6051
6119
|
};
|
|
6052
6120
|
|
|
@@ -6146,38 +6214,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6146
6214
|
this._peerConnection = undefined;
|
|
6147
6215
|
}
|
|
6148
6216
|
|
|
6149
|
-
async _waitForValidGatheredIce() {
|
|
6150
|
-
let tries = 0;
|
|
6151
|
-
|
|
6152
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
6153
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
6154
|
-
tries,
|
|
6155
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
6156
|
-
});
|
|
6157
|
-
|
|
6158
|
-
tries++;
|
|
6159
|
-
|
|
6160
|
-
// eslint-disable-next-line no-await-in-loop
|
|
6161
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
6162
|
-
}
|
|
6163
|
-
|
|
6164
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
6165
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
6166
|
-
const error = new Error(errorMsg);
|
|
6167
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
6168
|
-
|
|
6169
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
6170
|
-
this.eventEmitter.emit('error', error);
|
|
6171
|
-
|
|
6172
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
6173
|
-
}
|
|
6174
|
-
|
|
6175
|
-
// eslint-disable-next-line
|
|
6176
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
6177
|
-
|
|
6178
|
-
return this.getLocalSessionDescription();
|
|
6179
|
-
}
|
|
6180
|
-
|
|
6181
6217
|
// Overridden to send `inactive` in conference
|
|
6182
6218
|
updateDirection(options , isConference = false,
|
|
6183
6219
|
audioOnly = false) {
|
|
@@ -6542,7 +6578,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6542
6578
|
const SEND_STATS_DELAY = 5000;
|
|
6543
6579
|
|
|
6544
6580
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6545
|
-
const logger$
|
|
6581
|
+
const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6546
6582
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6547
6583
|
|
|
6548
6584
|
// events
|
|
@@ -6556,14 +6592,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6556
6592
|
const MESSAGE = 'message';
|
|
6557
6593
|
const ACCEPTED = 'accepted';
|
|
6558
6594
|
const REJECTED = 'rejected';
|
|
6559
|
-
const ON_TRACK
|
|
6560
|
-
const ON_REINVITE
|
|
6595
|
+
const ON_TRACK = 'onTrack';
|
|
6596
|
+
const ON_REINVITE = 'reinvite';
|
|
6561
6597
|
const ON_ERROR = 'onError';
|
|
6562
6598
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6563
|
-
const ON_NETWORK_STATS
|
|
6564
|
-
const ON_DISCONNECTED
|
|
6599
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6600
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
6565
6601
|
|
|
6566
|
-
const events
|
|
6602
|
+
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6567
6603
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6568
6604
|
class CanceledCallError extends Error {}
|
|
6569
6605
|
|
|
@@ -6699,12 +6735,12 @@ class WebRTCClient extends Emitter {
|
|
|
6699
6735
|
this.MESSAGE = MESSAGE;
|
|
6700
6736
|
this.ACCEPTED = ACCEPTED;
|
|
6701
6737
|
this.REJECTED = REJECTED;
|
|
6702
|
-
this.ON_TRACK = ON_TRACK
|
|
6703
|
-
this.ON_REINVITE = ON_REINVITE
|
|
6738
|
+
this.ON_TRACK = ON_TRACK;
|
|
6739
|
+
this.ON_REINVITE = ON_REINVITE;
|
|
6704
6740
|
this.ON_ERROR = ON_ERROR;
|
|
6705
6741
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6706
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS
|
|
6707
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED
|
|
6742
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6743
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6708
6744
|
}
|
|
6709
6745
|
|
|
6710
6746
|
configureMedia(media ) {
|
|
@@ -6721,13 +6757,13 @@ class WebRTCClient extends Emitter {
|
|
|
6721
6757
|
|
|
6722
6758
|
createUserAgent(configOverrides ) {
|
|
6723
6759
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6724
|
-
logger$
|
|
6760
|
+
logger$4.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6725
6761
|
|
|
6726
6762
|
webRTCConfiguration.delegate = {
|
|
6727
6763
|
onConnect: this.onConnect.bind(this),
|
|
6728
6764
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6729
6765
|
onInvite: (invitation ) => {
|
|
6730
|
-
logger$
|
|
6766
|
+
logger$4.info('sdk webrtc on invite', {
|
|
6731
6767
|
method: 'delegate.onInvite',
|
|
6732
6768
|
id: invitation.id,
|
|
6733
6769
|
remoteURI: invitation.remoteURI,
|
|
@@ -6770,7 +6806,7 @@ class WebRTCClient extends Emitter {
|
|
|
6770
6806
|
}
|
|
6771
6807
|
|
|
6772
6808
|
onConnect() {
|
|
6773
|
-
logger$
|
|
6809
|
+
logger$4.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6774
6810
|
this.eventEmitter.emit(CONNECTED);
|
|
6775
6811
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6776
6812
|
this.registerer.waitingToggle(false);
|
|
@@ -6779,7 +6815,7 @@ class WebRTCClient extends Emitter {
|
|
|
6779
6815
|
}
|
|
6780
6816
|
|
|
6781
6817
|
async onDisconnect(error ) {
|
|
6782
|
-
logger$
|
|
6818
|
+
logger$4.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6783
6819
|
this.connectionPromise = null;
|
|
6784
6820
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6785
6821
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6804,37 +6840,37 @@ class WebRTCClient extends Emitter {
|
|
|
6804
6840
|
};
|
|
6805
6841
|
|
|
6806
6842
|
if (this.skipRegister) {
|
|
6807
|
-
logger$
|
|
6843
|
+
logger$4.info('sdk webrtc skip register...', logInfo);
|
|
6808
6844
|
return Promise.resolve();
|
|
6809
6845
|
}
|
|
6810
6846
|
|
|
6811
|
-
logger$
|
|
6847
|
+
logger$4.info('sdk webrtc registering...', logInfo);
|
|
6812
6848
|
|
|
6813
6849
|
if (!this.userAgent) {
|
|
6814
|
-
logger$
|
|
6850
|
+
logger$4.info('sdk webrtc recreating User Agent');
|
|
6815
6851
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6816
6852
|
}
|
|
6817
6853
|
if (!this.userAgent || this.isRegistered()) {
|
|
6818
|
-
logger$
|
|
6854
|
+
logger$4.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6819
6855
|
return Promise.resolve();
|
|
6820
6856
|
}
|
|
6821
6857
|
|
|
6822
6858
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6823
|
-
logger$
|
|
6859
|
+
logger$4.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6824
6860
|
return Promise.resolve();
|
|
6825
6861
|
}
|
|
6826
6862
|
|
|
6827
6863
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6828
6864
|
|
|
6829
6865
|
const onRegisterFailed = () => {
|
|
6830
|
-
logger$
|
|
6866
|
+
logger$4.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6831
6867
|
this.connectionPromise = null;
|
|
6832
6868
|
if (this.registerer && this.registerer.waiting) {
|
|
6833
6869
|
this.registerer.waitingToggle(false);
|
|
6834
6870
|
}
|
|
6835
6871
|
|
|
6836
6872
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6837
|
-
logger$
|
|
6873
|
+
logger$4.info('sdk webrtc registering, retrying...', { tries });
|
|
6838
6874
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6839
6875
|
}
|
|
6840
6876
|
};
|
|
@@ -6843,18 +6879,18 @@ class WebRTCClient extends Emitter {
|
|
|
6843
6879
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6844
6880
|
// during the resolution of the primise.
|
|
6845
6881
|
if (!this.userAgent) {
|
|
6846
|
-
logger$
|
|
6882
|
+
logger$4.info('sdk webrtc recreating User Agent after connection');
|
|
6847
6883
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6848
6884
|
}
|
|
6849
6885
|
|
|
6850
|
-
logger$
|
|
6886
|
+
logger$4.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6851
6887
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
6852
6888
|
this.connectionPromise = null;
|
|
6853
6889
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6854
6890
|
|
|
6855
6891
|
// Bind registerer events
|
|
6856
6892
|
this.registerer.stateChange.addListener(newState => {
|
|
6857
|
-
logger$
|
|
6893
|
+
logger$4.info('sdk webrtc registering, state changed', { newState });
|
|
6858
6894
|
|
|
6859
6895
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
6860
6896
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -6867,7 +6903,7 @@ class WebRTCClient extends Emitter {
|
|
|
6867
6903
|
const options = {
|
|
6868
6904
|
requestDelegate: {
|
|
6869
6905
|
onReject: response => {
|
|
6870
|
-
logger$
|
|
6906
|
+
logger$4.error('sdk webrtc registering, rejected', { response });
|
|
6871
6907
|
|
|
6872
6908
|
onRegisterFailed();
|
|
6873
6909
|
},
|
|
@@ -6875,13 +6911,13 @@ class WebRTCClient extends Emitter {
|
|
|
6875
6911
|
};
|
|
6876
6912
|
|
|
6877
6913
|
return this.registerer.register(options).catch((e) => {
|
|
6878
|
-
logger$
|
|
6914
|
+
logger$4.error('sdk webrtc registering, error', e);
|
|
6879
6915
|
|
|
6880
6916
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6881
6917
|
return e;
|
|
6882
6918
|
});
|
|
6883
6919
|
}).catch(error => {
|
|
6884
|
-
logger$
|
|
6920
|
+
logger$4.error('sdk webrtc registering, transport error', error);
|
|
6885
6921
|
onRegisterFailed();
|
|
6886
6922
|
});
|
|
6887
6923
|
}
|
|
@@ -6910,21 +6946,21 @@ class WebRTCClient extends Emitter {
|
|
|
6910
6946
|
}
|
|
6911
6947
|
|
|
6912
6948
|
unregister() {
|
|
6913
|
-
logger$
|
|
6949
|
+
logger$4.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6914
6950
|
if (!this.registerer) {
|
|
6915
6951
|
return Promise.resolve();
|
|
6916
6952
|
}
|
|
6917
6953
|
|
|
6918
6954
|
try {
|
|
6919
6955
|
return this.registerer.unregister().then(() => {
|
|
6920
|
-
logger$
|
|
6956
|
+
logger$4.info('sdk webrtc unregistered');
|
|
6921
6957
|
this._cleanupRegister();
|
|
6922
6958
|
}).catch(e => {
|
|
6923
|
-
logger$
|
|
6959
|
+
logger$4.error('sdk webrtc unregistering, promise error', e);
|
|
6924
6960
|
this._cleanupRegister();
|
|
6925
6961
|
});
|
|
6926
6962
|
} catch (e) {
|
|
6927
|
-
logger$
|
|
6963
|
+
logger$4.error('sdk webrtc unregistering, error', e);
|
|
6928
6964
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6929
6965
|
// error when the registerer is in a bad state
|
|
6930
6966
|
this._cleanupRegister();
|
|
@@ -6932,7 +6968,7 @@ class WebRTCClient extends Emitter {
|
|
|
6932
6968
|
}
|
|
6933
6969
|
|
|
6934
6970
|
stop() {
|
|
6935
|
-
logger$
|
|
6971
|
+
logger$4.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6936
6972
|
if (!this.userAgent) {
|
|
6937
6973
|
return Promise.resolve();
|
|
6938
6974
|
}
|
|
@@ -6940,12 +6976,12 @@ class WebRTCClient extends Emitter {
|
|
|
6940
6976
|
return this.userAgent.stop().then(() => {
|
|
6941
6977
|
return this._cleanupRegister();
|
|
6942
6978
|
}).catch(e => {
|
|
6943
|
-
logger$
|
|
6979
|
+
logger$4.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6944
6980
|
});
|
|
6945
6981
|
}
|
|
6946
6982
|
|
|
6947
6983
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6948
|
-
logger$
|
|
6984
|
+
logger$4.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6949
6985
|
const inviterOptions = {
|
|
6950
6986
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6951
6987
|
conference,
|
|
@@ -6970,11 +7006,13 @@ class WebRTCClient extends Emitter {
|
|
|
6970
7006
|
const inviteOptions = {
|
|
6971
7007
|
requestDelegate: {
|
|
6972
7008
|
onAccept: (response ) => {
|
|
6973
|
-
session.sessionDescriptionHandler.peerConnection
|
|
7009
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
7010
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
7011
|
+
}
|
|
6974
7012
|
this._onAccepted(session, response.session, true);
|
|
6975
7013
|
},
|
|
6976
7014
|
onReject: (response ) => {
|
|
6977
|
-
logger$
|
|
7015
|
+
logger$4.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6978
7016
|
this._stopSendingStats(session);
|
|
6979
7017
|
this.stopNetworkMonitoring(session);
|
|
6980
7018
|
|
|
@@ -6997,11 +7035,11 @@ class WebRTCClient extends Emitter {
|
|
|
6997
7035
|
}
|
|
6998
7036
|
|
|
6999
7037
|
answer(session , enableVideo ) {
|
|
7000
|
-
logger$
|
|
7038
|
+
logger$4.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
7001
7039
|
|
|
7002
7040
|
if (!session || !session.accept) {
|
|
7003
7041
|
const error = 'No session to answer, or not an invitation';
|
|
7004
|
-
logger$
|
|
7042
|
+
logger$4.warn(error);
|
|
7005
7043
|
return Promise.reject(new Error(error));
|
|
7006
7044
|
}
|
|
7007
7045
|
const options = {
|
|
@@ -7011,15 +7049,15 @@ class WebRTCClient extends Emitter {
|
|
|
7011
7049
|
return session.accept(options).then(() => {
|
|
7012
7050
|
if (session.isCanceled) {
|
|
7013
7051
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
7014
|
-
logger$
|
|
7052
|
+
logger$4.error(message, { id: session.id });
|
|
7015
7053
|
this.onCallEnded(session);
|
|
7016
7054
|
|
|
7017
7055
|
throw new CanceledCallError(message);
|
|
7018
7056
|
}
|
|
7019
|
-
logger$
|
|
7057
|
+
logger$4.info('sdk webrtc answer, accepted.');
|
|
7020
7058
|
this._onAccepted(session);
|
|
7021
7059
|
}).catch(e => {
|
|
7022
|
-
logger$
|
|
7060
|
+
logger$4.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
7023
7061
|
|
|
7024
7062
|
throw e;
|
|
7025
7063
|
});
|
|
@@ -7027,7 +7065,7 @@ class WebRTCClient extends Emitter {
|
|
|
7027
7065
|
|
|
7028
7066
|
hangup(session ) {
|
|
7029
7067
|
const { state, id } = session;
|
|
7030
|
-
logger$
|
|
7068
|
+
logger$4.info('sdk webrtc hangup call', { id, state });
|
|
7031
7069
|
|
|
7032
7070
|
try {
|
|
7033
7071
|
this._stopSendingStats(session);
|
|
@@ -7056,7 +7094,7 @@ class WebRTCClient extends Emitter {
|
|
|
7056
7094
|
|
|
7057
7095
|
return bye();
|
|
7058
7096
|
} catch (error) {
|
|
7059
|
-
logger$
|
|
7097
|
+
logger$4.warn('sdk webrtc hangup, error', error);
|
|
7060
7098
|
}
|
|
7061
7099
|
|
|
7062
7100
|
return null;
|
|
@@ -7074,7 +7112,7 @@ class WebRTCClient extends Emitter {
|
|
|
7074
7112
|
// Fetch and emit an event at `interval` with session network stats
|
|
7075
7113
|
startNetworkMonitoring(session , interval = 1000) {
|
|
7076
7114
|
const sessionId = this.getSipSessionId(session);
|
|
7077
|
-
logger$
|
|
7115
|
+
logger$4.info('starting network inspection', { id: sessionId });
|
|
7078
7116
|
|
|
7079
7117
|
this.sessionNetworkStats[sessionId] = [];
|
|
7080
7118
|
|
|
@@ -7084,7 +7122,7 @@ class WebRTCClient extends Emitter {
|
|
|
7084
7122
|
stopNetworkMonitoring(session ) {
|
|
7085
7123
|
const sessionId = this.getSipSessionId(session);
|
|
7086
7124
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
7087
|
-
logger$
|
|
7125
|
+
logger$4.info('stopping network inspection', { id: sessionId, exists });
|
|
7088
7126
|
|
|
7089
7127
|
if (exists) {
|
|
7090
7128
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -7094,17 +7132,17 @@ class WebRTCClient extends Emitter {
|
|
|
7094
7132
|
}
|
|
7095
7133
|
|
|
7096
7134
|
reject(session ) {
|
|
7097
|
-
logger$
|
|
7135
|
+
logger$4.info('sdk webrtc reject call', { id: session.id });
|
|
7098
7136
|
|
|
7099
7137
|
try {
|
|
7100
7138
|
return session.reject ? session.reject() : session.cancel();
|
|
7101
7139
|
} catch (e) {
|
|
7102
|
-
logger$
|
|
7140
|
+
logger$4.warn('Error when rejecting call', e.message, e.stack);
|
|
7103
7141
|
}
|
|
7104
7142
|
}
|
|
7105
7143
|
|
|
7106
7144
|
async close() {
|
|
7107
|
-
logger$
|
|
7145
|
+
logger$4.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
7108
7146
|
this._cleanupMedia();
|
|
7109
7147
|
this.connectionPromise = null;
|
|
7110
7148
|
|
|
@@ -7135,7 +7173,7 @@ class WebRTCClient extends Emitter {
|
|
|
7135
7173
|
// eg: "INVITE not rejectable in state Completed"
|
|
7136
7174
|
}
|
|
7137
7175
|
this.userAgent = null;
|
|
7138
|
-
logger$
|
|
7176
|
+
logger$4.info('sdk webrtc client closed');
|
|
7139
7177
|
}
|
|
7140
7178
|
|
|
7141
7179
|
getNumber(session ) {
|
|
@@ -7148,13 +7186,13 @@ class WebRTCClient extends Emitter {
|
|
|
7148
7186
|
}
|
|
7149
7187
|
|
|
7150
7188
|
mute(session ) {
|
|
7151
|
-
logger$
|
|
7189
|
+
logger$4.info('sdk webrtc mute', { id: session.id });
|
|
7152
7190
|
|
|
7153
7191
|
this._toggleAudio(session, true);
|
|
7154
7192
|
}
|
|
7155
7193
|
|
|
7156
7194
|
unmute(session ) {
|
|
7157
|
-
logger$
|
|
7195
|
+
logger$4.info('sdk webrtc unmute', { id: session.id });
|
|
7158
7196
|
|
|
7159
7197
|
this._toggleAudio(session, false);
|
|
7160
7198
|
}
|
|
@@ -7194,13 +7232,13 @@ class WebRTCClient extends Emitter {
|
|
|
7194
7232
|
}
|
|
7195
7233
|
|
|
7196
7234
|
toggleCameraOn(session ) {
|
|
7197
|
-
logger$
|
|
7235
|
+
logger$4.info('sdk webrtc toggle camera on', { id: session.id });
|
|
7198
7236
|
|
|
7199
7237
|
this._toggleVideo(session, false);
|
|
7200
7238
|
}
|
|
7201
7239
|
|
|
7202
7240
|
toggleCameraOff(session ) {
|
|
7203
|
-
logger$
|
|
7241
|
+
logger$4.info('sdk webrtc toggle camera off', { id: session.id });
|
|
7204
7242
|
|
|
7205
7243
|
this._toggleVideo(session, true);
|
|
7206
7244
|
}
|
|
@@ -7209,7 +7247,7 @@ class WebRTCClient extends Emitter {
|
|
|
7209
7247
|
const sessionId = this.getSipSessionId(session);
|
|
7210
7248
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
7211
7249
|
|
|
7212
|
-
logger$
|
|
7250
|
+
logger$4.info('sdk webrtc hold', {
|
|
7213
7251
|
sessionId,
|
|
7214
7252
|
keys: Object.keys(this.heldSessions),
|
|
7215
7253
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7258,7 +7296,7 @@ class WebRTCClient extends Emitter {
|
|
|
7258
7296
|
const sessionId = this.getSipSessionId(session);
|
|
7259
7297
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
7260
7298
|
|
|
7261
|
-
logger$
|
|
7299
|
+
logger$4.info('sdk webrtc unhold', {
|
|
7262
7300
|
sessionId,
|
|
7263
7301
|
keys: Object.keys(this.heldSessions),
|
|
7264
7302
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7406,7 +7444,7 @@ class WebRTCClient extends Emitter {
|
|
|
7406
7444
|
if (!session.sessionDescriptionHandler) {
|
|
7407
7445
|
return;
|
|
7408
7446
|
}
|
|
7409
|
-
logger$
|
|
7447
|
+
logger$4.info('Sending DTMF', {
|
|
7410
7448
|
id: this.getSipSessionId(session),
|
|
7411
7449
|
tone,
|
|
7412
7450
|
});
|
|
@@ -7422,7 +7460,7 @@ class WebRTCClient extends Emitter {
|
|
|
7422
7460
|
transfer(session , target ) {
|
|
7423
7461
|
this.hold(session);
|
|
7424
7462
|
|
|
7425
|
-
logger$
|
|
7463
|
+
logger$4.info('Transfering a session', {
|
|
7426
7464
|
id: this.getSipSessionId(session),
|
|
7427
7465
|
target,
|
|
7428
7466
|
});
|
|
@@ -7444,17 +7482,17 @@ class WebRTCClient extends Emitter {
|
|
|
7444
7482
|
atxfer(session ) {
|
|
7445
7483
|
this.hold(session);
|
|
7446
7484
|
|
|
7447
|
-
logger$
|
|
7485
|
+
logger$4.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7448
7486
|
|
|
7449
7487
|
const result = {
|
|
7450
7488
|
newSession: null,
|
|
7451
7489
|
init: async (target ) => {
|
|
7452
|
-
logger$
|
|
7490
|
+
logger$4.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7453
7491
|
|
|
7454
7492
|
result.newSession = await this.call(target);
|
|
7455
7493
|
},
|
|
7456
7494
|
complete: () => {
|
|
7457
|
-
logger$
|
|
7495
|
+
logger$4.info('webrtc transfer completed', {
|
|
7458
7496
|
id: this.getSipSessionId(session),
|
|
7459
7497
|
referId: this.getSipSessionId(result.newSession),
|
|
7460
7498
|
});
|
|
@@ -7475,7 +7513,7 @@ class WebRTCClient extends Emitter {
|
|
|
7475
7513
|
return;
|
|
7476
7514
|
}
|
|
7477
7515
|
|
|
7478
|
-
logger$
|
|
7516
|
+
logger$4.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7479
7517
|
|
|
7480
7518
|
try {
|
|
7481
7519
|
sipSession.message({
|
|
@@ -7517,7 +7555,7 @@ class WebRTCClient extends Emitter {
|
|
|
7517
7555
|
}
|
|
7518
7556
|
|
|
7519
7557
|
changeAudioOutputVolume(volume ) {
|
|
7520
|
-
logger$
|
|
7558
|
+
logger$4.info('Changing audio output volume', { volume });
|
|
7521
7559
|
|
|
7522
7560
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7523
7561
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7529,7 +7567,7 @@ class WebRTCClient extends Emitter {
|
|
|
7529
7567
|
}
|
|
7530
7568
|
|
|
7531
7569
|
changeAudioOutputDevice(id ) {
|
|
7532
|
-
logger$
|
|
7570
|
+
logger$4.info('Changing audio output device', { id });
|
|
7533
7571
|
|
|
7534
7572
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7535
7573
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7546,7 +7584,7 @@ class WebRTCClient extends Emitter {
|
|
|
7546
7584
|
|
|
7547
7585
|
changeAudioInputDevice(id , session ) {
|
|
7548
7586
|
const currentId = this.getAudioDeviceId();
|
|
7549
|
-
logger$
|
|
7587
|
+
logger$4.info('setting audio input device', { id, currentId, session: !!session });
|
|
7550
7588
|
|
|
7551
7589
|
if (id === currentId) {
|
|
7552
7590
|
return null;
|
|
@@ -7592,7 +7630,7 @@ class WebRTCClient extends Emitter {
|
|
|
7592
7630
|
|
|
7593
7631
|
setVideoInputDevice(id ) {
|
|
7594
7632
|
const currentId = this.getVideoDeviceId();
|
|
7595
|
-
logger$
|
|
7633
|
+
logger$4.info('setting video input device', { id, currentId });
|
|
7596
7634
|
|
|
7597
7635
|
if (id === currentId) {
|
|
7598
7636
|
return null;
|
|
@@ -7617,7 +7655,7 @@ class WebRTCClient extends Emitter {
|
|
|
7617
7655
|
const sessionId = this.getSipSessionId(session);
|
|
7618
7656
|
const localStream = this.getLocalStream(sessionId);
|
|
7619
7657
|
|
|
7620
|
-
logger$
|
|
7658
|
+
logger$4.info('changing video input device', { id, sessionId });
|
|
7621
7659
|
|
|
7622
7660
|
// Release old video stream
|
|
7623
7661
|
if (localStream) {
|
|
@@ -7685,7 +7723,7 @@ class WebRTCClient extends Emitter {
|
|
|
7685
7723
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7686
7724
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7687
7725
|
|
|
7688
|
-
logger$
|
|
7726
|
+
logger$4.info('Sending reinvite', {
|
|
7689
7727
|
id: this.getSipSessionId(sipSession),
|
|
7690
7728
|
newConstraints,
|
|
7691
7729
|
conference,
|
|
@@ -7723,7 +7761,7 @@ class WebRTCClient extends Emitter {
|
|
|
7723
7761
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7724
7762
|
}
|
|
7725
7763
|
|
|
7726
|
-
logger$
|
|
7764
|
+
logger$4.info('on re-INVITE accepted', {
|
|
7727
7765
|
id: this.getSipSessionId(sipSession),
|
|
7728
7766
|
wasMuted,
|
|
7729
7767
|
shouldDoScreenSharing,
|
|
@@ -7741,7 +7779,7 @@ class WebRTCClient extends Emitter {
|
|
|
7741
7779
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7742
7780
|
}
|
|
7743
7781
|
|
|
7744
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7782
|
+
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7745
7783
|
},
|
|
7746
7784
|
},
|
|
7747
7785
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7842,6 +7880,16 @@ class WebRTCClient extends Emitter {
|
|
|
7842
7880
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
7843
7881
|
}
|
|
7844
7882
|
|
|
7883
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
7884
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
7885
|
+
const pc = this.getPeerConnection(sessionId);
|
|
7886
|
+
if (!pc) {
|
|
7887
|
+
return null;
|
|
7888
|
+
}
|
|
7889
|
+
|
|
7890
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
7891
|
+
}
|
|
7892
|
+
|
|
7845
7893
|
hasVideo(sessionId ) {
|
|
7846
7894
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
7847
7895
|
}
|
|
@@ -7888,7 +7936,7 @@ class WebRTCClient extends Emitter {
|
|
|
7888
7936
|
}
|
|
7889
7937
|
|
|
7890
7938
|
startHeartbeat() {
|
|
7891
|
-
logger$
|
|
7939
|
+
logger$4.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7892
7940
|
if (!this.userAgent) {
|
|
7893
7941
|
this.heartbeat.stop();
|
|
7894
7942
|
return;
|
|
@@ -7901,7 +7949,7 @@ class WebRTCClient extends Emitter {
|
|
|
7901
7949
|
}
|
|
7902
7950
|
|
|
7903
7951
|
stopHeartbeat() {
|
|
7904
|
-
logger$
|
|
7952
|
+
logger$4.info('sdk webrtc stop heartbeat');
|
|
7905
7953
|
this.heartbeat.stop();
|
|
7906
7954
|
}
|
|
7907
7955
|
|
|
@@ -7922,7 +7970,7 @@ class WebRTCClient extends Emitter {
|
|
|
7922
7970
|
}
|
|
7923
7971
|
|
|
7924
7972
|
attemptReconnection() {
|
|
7925
|
-
logger$
|
|
7973
|
+
logger$4.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7926
7974
|
if (!this.userAgent) {
|
|
7927
7975
|
return;
|
|
7928
7976
|
}
|
|
@@ -7947,7 +7995,7 @@ class WebRTCClient extends Emitter {
|
|
|
7947
7995
|
return;
|
|
7948
7996
|
}
|
|
7949
7997
|
|
|
7950
|
-
logger$
|
|
7998
|
+
logger$4.info('setting local media stream', {
|
|
7951
7999
|
sipSessionId,
|
|
7952
8000
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7953
8001
|
});
|
|
@@ -7964,7 +8012,7 @@ class WebRTCClient extends Emitter {
|
|
|
7964
8012
|
|
|
7965
8013
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7966
8014
|
|
|
7967
|
-
logger$
|
|
8015
|
+
logger$4.info('updating local stream', {
|
|
7968
8016
|
sipSessionId,
|
|
7969
8017
|
oldStream: !!oldStream,
|
|
7970
8018
|
tracks: newStream.getTracks(),
|
|
@@ -7984,7 +8032,7 @@ class WebRTCClient extends Emitter {
|
|
|
7984
8032
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7985
8033
|
const pc = this.getPeerConnection(sessionId);
|
|
7986
8034
|
|
|
7987
|
-
logger$
|
|
8035
|
+
logger$4.info('Updating remote stream', {
|
|
7988
8036
|
sessionId,
|
|
7989
8037
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7990
8038
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -8010,7 +8058,7 @@ class WebRTCClient extends Emitter {
|
|
|
8010
8058
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
8011
8059
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
8012
8060
|
|
|
8013
|
-
logger$
|
|
8061
|
+
logger$4.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
8014
8062
|
|
|
8015
8063
|
return {
|
|
8016
8064
|
constraints: {
|
|
@@ -8059,7 +8107,7 @@ class WebRTCClient extends Emitter {
|
|
|
8059
8107
|
}
|
|
8060
8108
|
|
|
8061
8109
|
_onTransportError() {
|
|
8062
|
-
logger$
|
|
8110
|
+
logger$4.error('on transport error');
|
|
8063
8111
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
8064
8112
|
this.attemptReconnection();
|
|
8065
8113
|
}
|
|
@@ -8068,7 +8116,7 @@ class WebRTCClient extends Emitter {
|
|
|
8068
8116
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
8069
8117
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
8070
8118
|
if (this.hasHeartbeat()) {
|
|
8071
|
-
logger$
|
|
8119
|
+
logger$4.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
8072
8120
|
|
|
8073
8121
|
this.heartbeat.onHeartbeat();
|
|
8074
8122
|
if (this.heartbeatCb) {
|
|
@@ -8079,7 +8127,7 @@ class WebRTCClient extends Emitter {
|
|
|
8079
8127
|
}
|
|
8080
8128
|
|
|
8081
8129
|
async _onHeartbeatTimeout() {
|
|
8082
|
-
logger$
|
|
8130
|
+
logger$4.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
8083
8131
|
|
|
8084
8132
|
if (this.heartbeatTimeoutCb) {
|
|
8085
8133
|
this.heartbeatTimeoutCb();
|
|
@@ -8091,7 +8139,7 @@ class WebRTCClient extends Emitter {
|
|
|
8091
8139
|
try {
|
|
8092
8140
|
await this.userAgent.transport.disconnect();
|
|
8093
8141
|
} catch (e) {
|
|
8094
|
-
logger$
|
|
8142
|
+
logger$4.error('Transport disconnection after heartbeat timeout, error', e);
|
|
8095
8143
|
}
|
|
8096
8144
|
}
|
|
8097
8145
|
|
|
@@ -8124,31 +8172,31 @@ class WebRTCClient extends Emitter {
|
|
|
8124
8172
|
}
|
|
8125
8173
|
|
|
8126
8174
|
_connectIfNeeded() {
|
|
8127
|
-
logger$
|
|
8175
|
+
logger$4.info('connect if needed, checking', { connected: this.isConnected() });
|
|
8128
8176
|
if (!this.userAgent) {
|
|
8129
|
-
logger$
|
|
8177
|
+
logger$4.info('need to recreate User Agent');
|
|
8130
8178
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
8131
8179
|
}
|
|
8132
8180
|
|
|
8133
8181
|
if (this.isConnected()) {
|
|
8134
|
-
logger$
|
|
8182
|
+
logger$4.info('webrtc sdk, already connected');
|
|
8135
8183
|
return Promise.resolve();
|
|
8136
8184
|
}
|
|
8137
8185
|
|
|
8138
8186
|
if (this.isConnecting()) {
|
|
8139
|
-
logger$
|
|
8187
|
+
logger$4.info('webrtc sdk, already connecting...');
|
|
8140
8188
|
|
|
8141
8189
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
8142
8190
|
return this.connectionPromise;
|
|
8143
8191
|
}
|
|
8144
8192
|
|
|
8145
8193
|
if (this.connectionPromise) {
|
|
8146
|
-
logger$
|
|
8194
|
+
logger$4.info('webrtc sdk, connection promise connecting...');
|
|
8147
8195
|
// $FlowFixMe
|
|
8148
8196
|
return this.connectionPromise;
|
|
8149
8197
|
}
|
|
8150
8198
|
|
|
8151
|
-
logger$
|
|
8199
|
+
logger$4.info('WebRTC UA needs to connect');
|
|
8152
8200
|
|
|
8153
8201
|
// Force UA to reconnect
|
|
8154
8202
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -8273,7 +8321,7 @@ class WebRTCClient extends Emitter {
|
|
|
8273
8321
|
|
|
8274
8322
|
sdh.peerConnectionDelegate = {
|
|
8275
8323
|
onicecandidateerror: (error ) => {
|
|
8276
|
-
logger$
|
|
8324
|
+
logger$4.error('on icecandidate error', {
|
|
8277
8325
|
address: error.address,
|
|
8278
8326
|
port: error.port,
|
|
8279
8327
|
errorCode: error.errorCode,
|
|
@@ -8302,7 +8350,7 @@ class WebRTCClient extends Emitter {
|
|
|
8302
8350
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
8303
8351
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
8304
8352
|
}
|
|
8305
|
-
logger$
|
|
8353
|
+
logger$4.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
8306
8354
|
|
|
8307
8355
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
8308
8356
|
|
|
@@ -8318,12 +8366,12 @@ class WebRTCClient extends Emitter {
|
|
|
8318
8366
|
|
|
8319
8367
|
this._setupMedias(session);
|
|
8320
8368
|
|
|
8321
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
8369
|
+
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
8322
8370
|
};
|
|
8323
8371
|
}
|
|
8324
8372
|
|
|
8325
8373
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
8326
|
-
logger$
|
|
8374
|
+
logger$4.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
8327
8375
|
|
|
8328
8376
|
this.storeSipSession(session);
|
|
8329
8377
|
|
|
@@ -8335,14 +8383,14 @@ class WebRTCClient extends Emitter {
|
|
|
8335
8383
|
const onTrack = (event ) => {
|
|
8336
8384
|
const isAudioOnly = this._isAudioOnly(session);
|
|
8337
8385
|
const { kind, label, readyState, id, muted } = event.track;
|
|
8338
|
-
logger$
|
|
8386
|
+
logger$4.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
8339
8387
|
|
|
8340
8388
|
// Stop video track in audio only mode
|
|
8341
8389
|
if (isAudioOnly && kind === 'video') {
|
|
8342
8390
|
event.track.stop();
|
|
8343
8391
|
}
|
|
8344
8392
|
|
|
8345
|
-
this.eventEmitter.emit(ON_TRACK
|
|
8393
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
8346
8394
|
};
|
|
8347
8395
|
|
|
8348
8396
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -8352,8 +8400,9 @@ class WebRTCClient extends Emitter {
|
|
|
8352
8400
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8353
8401
|
|
|
8354
8402
|
pc.oniceconnectionstatechange = () => {
|
|
8403
|
+
logger$4.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8355
8404
|
if (pc.iceConnectionState === 'disconnected') {
|
|
8356
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
8405
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
8357
8406
|
}
|
|
8358
8407
|
};
|
|
8359
8408
|
|
|
@@ -8524,10 +8573,10 @@ class WebRTCClient extends Emitter {
|
|
|
8524
8573
|
|
|
8525
8574
|
_stopSendingStats(session ) {
|
|
8526
8575
|
const sessionId = this.getSipSessionId(session);
|
|
8527
|
-
logger$
|
|
8576
|
+
logger$4.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8528
8577
|
|
|
8529
8578
|
if (sessionId in this.statsIntervals) {
|
|
8530
|
-
logger$
|
|
8579
|
+
logger$4.trace('Stop sending stats for call', { sessionId });
|
|
8531
8580
|
this.statsIntervals[sessionId]();
|
|
8532
8581
|
delete this.statsIntervals[sessionId];
|
|
8533
8582
|
}
|
|
@@ -8543,7 +8592,7 @@ class WebRTCClient extends Emitter {
|
|
|
8543
8592
|
try {
|
|
8544
8593
|
await this.userAgent.transport.disconnect();
|
|
8545
8594
|
} catch (e) {
|
|
8546
|
-
logger$
|
|
8595
|
+
logger$4.error('WebRTC transport disconnect, error', e);
|
|
8547
8596
|
}
|
|
8548
8597
|
}
|
|
8549
8598
|
}
|
|
@@ -8580,25 +8629,25 @@ class WebRTCClient extends Emitter {
|
|
|
8580
8629
|
|
|
8581
8630
|
stats.forEach(report => {
|
|
8582
8631
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8583
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8632
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8584
8633
|
}
|
|
8585
8634
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8586
|
-
audioBytesSent += report.bytesSent;
|
|
8635
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8587
8636
|
}
|
|
8588
8637
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8589
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8638
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8590
8639
|
}
|
|
8591
8640
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8592
|
-
packetsLost += report.packetsLost;
|
|
8593
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8594
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8641
|
+
packetsLost += Number(report.packetsLost);
|
|
8642
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8643
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8595
8644
|
}
|
|
8596
8645
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8597
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8646
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8598
8647
|
}
|
|
8599
8648
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8600
8649
|
if ('framesPerSecond' in report) {
|
|
8601
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8650
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8602
8651
|
}
|
|
8603
8652
|
if ('framerateMean' in report) {
|
|
8604
8653
|
// framerateMean is only available in FF
|
|
@@ -8606,34 +8655,38 @@ class WebRTCClient extends Emitter {
|
|
|
8606
8655
|
}
|
|
8607
8656
|
}
|
|
8608
8657
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8609
|
-
packetsLost += report.packetsLost;
|
|
8610
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8611
|
-
networkStats.jitter = report.jitter;
|
|
8658
|
+
packetsLost += Number(report.packetsLost);
|
|
8659
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8660
|
+
networkStats.jitter = Number(report.jitter);
|
|
8612
8661
|
}
|
|
8613
8662
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8614
|
-
packetsLost += report.packetsLost;
|
|
8663
|
+
packetsLost += Number(report.packetsLost);
|
|
8615
8664
|
}
|
|
8616
8665
|
if (report.type === 'transport') {
|
|
8617
|
-
transportSent += report.bytesSent;
|
|
8618
|
-
transportReceived += report.bytesReceived;
|
|
8666
|
+
transportSent += Number(report.bytesSent);
|
|
8667
|
+
transportReceived += Number(report.bytesReceived);
|
|
8619
8668
|
}
|
|
8620
8669
|
});
|
|
8621
8670
|
|
|
8622
8671
|
networkStats.packetsLost = packetsLost;
|
|
8623
|
-
networkStats.
|
|
8672
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8673
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8674
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8624
8675
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8625
|
-
networkStats.
|
|
8626
|
-
networkStats.
|
|
8676
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8677
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8678
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
8679
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
8680
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
8627
8681
|
networkStats.transportSent = transportSent;
|
|
8628
|
-
networkStats.
|
|
8629
|
-
|
|
8630
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
8631
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
8632
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
8682
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
8683
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
8633
8684
|
|
|
8634
|
-
networkStats.bandwidth =
|
|
8685
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
8686
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8687
|
+
+ networkStats.transportSent;
|
|
8635
8688
|
|
|
8636
|
-
this.eventEmitter.emit(ON_NETWORK_STATS
|
|
8689
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8637
8690
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8638
8691
|
}
|
|
8639
8692
|
|
|
@@ -8661,8 +8714,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
8661
8714
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8662
8715
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8663
8716
|
const ON_MESSAGE = 'onMessage';
|
|
8664
|
-
const ON_REINVITE = 'reinvite';
|
|
8665
|
-
const ON_TRACK = 'onTrack';
|
|
8717
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
8718
|
+
const ON_TRACK$1 = 'onTrack';
|
|
8666
8719
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
8667
8720
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
8668
8721
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -8677,15 +8730,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
8677
8730
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
8678
8731
|
const ON_CALL_ERROR = 'onCallError';
|
|
8679
8732
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
8680
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
8733
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
8681
8734
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
8682
8735
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
8683
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
8736
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
8684
8737
|
|
|
8685
8738
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
8686
8739
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
8687
8740
|
|
|
8688
|
-
const events = [
|
|
8741
|
+
const events$1 = [
|
|
8689
8742
|
ON_USER_AGENT,
|
|
8690
8743
|
ON_REGISTERED,
|
|
8691
8744
|
ON_UNREGISTERED,
|
|
@@ -8703,8 +8756,8 @@ const events = [
|
|
|
8703
8756
|
ON_CALL_FAILED,
|
|
8704
8757
|
ON_CALL_ENDED,
|
|
8705
8758
|
ON_MESSAGE,
|
|
8706
|
-
ON_REINVITE,
|
|
8707
|
-
ON_TRACK,
|
|
8759
|
+
ON_REINVITE$1,
|
|
8760
|
+
ON_TRACK$1,
|
|
8708
8761
|
ON_AUDIO_STREAM,
|
|
8709
8762
|
ON_VIDEO_STREAM,
|
|
8710
8763
|
ON_REMOVE_STREAM,
|
|
@@ -8719,11 +8772,11 @@ const events = [
|
|
|
8719
8772
|
ON_CALL_ERROR,
|
|
8720
8773
|
ON_CHAT,
|
|
8721
8774
|
ON_SIGNAL,
|
|
8722
|
-
ON_NETWORK_STATS,
|
|
8723
|
-
ON_DISCONNECTED,
|
|
8775
|
+
ON_NETWORK_STATS$1,
|
|
8776
|
+
ON_DISCONNECTED$1,
|
|
8724
8777
|
];
|
|
8725
8778
|
|
|
8726
|
-
const logger$
|
|
8779
|
+
const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
8727
8780
|
|
|
8728
8781
|
class WebRTCPhone extends Emitter {
|
|
8729
8782
|
|
|
@@ -8796,7 +8849,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8796
8849
|
}).catch(error => {
|
|
8797
8850
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
8798
8851
|
console.error('register error', error, error.message, error.stack);
|
|
8799
|
-
logger$
|
|
8852
|
+
logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
8800
8853
|
});
|
|
8801
8854
|
}
|
|
8802
8855
|
|
|
@@ -8811,7 +8864,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8811
8864
|
if (!this.client) {
|
|
8812
8865
|
return;
|
|
8813
8866
|
}
|
|
8814
|
-
logger$
|
|
8867
|
+
logger$5.info('WebRTC phone stop');
|
|
8815
8868
|
this.client.stop();
|
|
8816
8869
|
}
|
|
8817
8870
|
|
|
@@ -8826,7 +8879,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8826
8879
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8827
8880
|
audioOnly = false, iceRestart = false) {
|
|
8828
8881
|
const sipSession = this.findSipSession(callSession);
|
|
8829
|
-
logger$
|
|
8882
|
+
logger$5.info('WebRTC phone - send reinvite', {
|
|
8830
8883
|
sessionId: sipSession ? sipSession.id : null,
|
|
8831
8884
|
constraints,
|
|
8832
8885
|
audioOnly,
|
|
@@ -8863,7 +8916,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8863
8916
|
}
|
|
8864
8917
|
|
|
8865
8918
|
startHeartbeat() {
|
|
8866
|
-
logger$
|
|
8919
|
+
logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
8867
8920
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
8868
8921
|
return;
|
|
8869
8922
|
}
|
|
@@ -8872,7 +8925,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8872
8925
|
}
|
|
8873
8926
|
|
|
8874
8927
|
stopHeartbeat() {
|
|
8875
|
-
logger$
|
|
8928
|
+
logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
8876
8929
|
if (!this.client) {
|
|
8877
8930
|
return;
|
|
8878
8931
|
}
|
|
@@ -8889,7 +8942,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8889
8942
|
}
|
|
8890
8943
|
|
|
8891
8944
|
reconnect() {
|
|
8892
|
-
logger$
|
|
8945
|
+
logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8893
8946
|
if (!this.client) {
|
|
8894
8947
|
return;
|
|
8895
8948
|
}
|
|
@@ -8930,10 +8983,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8930
8983
|
return false;
|
|
8931
8984
|
}
|
|
8932
8985
|
|
|
8933
|
-
logger$
|
|
8986
|
+
logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
8934
8987
|
|
|
8935
8988
|
this.client.downgradeToAudio(sipSession);
|
|
8936
8989
|
|
|
8990
|
+
if (callSession) {
|
|
8991
|
+
callSession.cameraEnabled = false;
|
|
8992
|
+
this._updateCallSession(callSession);
|
|
8993
|
+
}
|
|
8994
|
+
|
|
8937
8995
|
if (withMessage) {
|
|
8938
8996
|
this._sendReinviteMessage(callSession, false);
|
|
8939
8997
|
}
|
|
@@ -8948,7 +9006,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8948
9006
|
return Promise.resolve(false);
|
|
8949
9007
|
}
|
|
8950
9008
|
|
|
8951
|
-
logger$
|
|
9009
|
+
logger$5.info('Upgrade to video', {
|
|
8952
9010
|
id: callSession ? callSession.getId() : null,
|
|
8953
9011
|
constraints,
|
|
8954
9012
|
isConference,
|
|
@@ -8961,6 +9019,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8961
9019
|
|
|
8962
9020
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8963
9021
|
|
|
9022
|
+
if (callSession) {
|
|
9023
|
+
callSession.cameraEnabled = true;
|
|
9024
|
+
this._updateCallSession(callSession);
|
|
9025
|
+
}
|
|
9026
|
+
|
|
8964
9027
|
// If no stream is returned, it means we have to reinvite
|
|
8965
9028
|
if (!newStream) {
|
|
8966
9029
|
return true;
|
|
@@ -8983,7 +9046,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8983
9046
|
|
|
8984
9047
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
8985
9048
|
const sipSession = this.findSipSession(callSession);
|
|
8986
|
-
logger$
|
|
9049
|
+
logger$5.info('Sending reinvite message', {
|
|
8987
9050
|
id: callSession ? callSession.getId() : null,
|
|
8988
9051
|
isUpgrade,
|
|
8989
9052
|
});
|
|
@@ -9009,11 +9072,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9009
9072
|
// Monkey patch to know when canceled with the CANCEL message
|
|
9010
9073
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
9011
9074
|
sipSession._onCancel = (message ) => {
|
|
9012
|
-
logger$
|
|
9075
|
+
logger$5.trace('on sip session canceled', { callId: message.callId });
|
|
9013
9076
|
|
|
9014
9077
|
onCancel(message);
|
|
9015
9078
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
9016
|
-
|
|
9079
|
+
const callSession = this._createCallSession(sipSession);
|
|
9080
|
+
delete this.callSessions[callSession.getId()];
|
|
9081
|
+
|
|
9082
|
+
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
9017
9083
|
};
|
|
9018
9084
|
} else if (sipSession instanceof invitation.Invitation) {
|
|
9019
9085
|
console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
|
|
@@ -9034,17 +9100,19 @@ class WebRTCPhone extends Emitter {
|
|
|
9034
9100
|
this.audioOutputVolume,
|
|
9035
9101
|
);
|
|
9036
9102
|
case sessionState.SessionState.Terminating:
|
|
9037
|
-
logger$
|
|
9103
|
+
logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
9038
9104
|
|
|
9039
9105
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
9040
9106
|
|
|
9041
9107
|
break;
|
|
9042
9108
|
case sessionState.SessionState.Terminated: {
|
|
9043
|
-
logger$
|
|
9109
|
+
logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
9044
9110
|
|
|
9111
|
+
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
9112
|
+
const callSession = this._createCallSession(sipSession);
|
|
9045
9113
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
9046
9114
|
|
|
9047
|
-
return this.eventEmitter.emit(ON_CALL_ENDED,
|
|
9115
|
+
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
9048
9116
|
}
|
|
9049
9117
|
}
|
|
9050
9118
|
});
|
|
@@ -9060,7 +9128,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9060
9128
|
const [stream] = event.streams;
|
|
9061
9129
|
const kind = event && event.track && event.track.kind;
|
|
9062
9130
|
|
|
9063
|
-
logger$
|
|
9131
|
+
logger$5.info('on track stream called on the peer connection', {
|
|
9064
9132
|
callId: this.getSipSessionId(sipSession),
|
|
9065
9133
|
streamId: stream ? stream.id : null,
|
|
9066
9134
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -9080,7 +9148,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9080
9148
|
};
|
|
9081
9149
|
|
|
9082
9150
|
peerConnection.onremovestream = event => {
|
|
9083
|
-
logger$
|
|
9151
|
+
logger$5.info('on remove stream called on the peer connection', {
|
|
9084
9152
|
id: event.stream.id,
|
|
9085
9153
|
tracks: event.stream.getTracks(),
|
|
9086
9154
|
});
|
|
@@ -9090,7 +9158,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9090
9158
|
}
|
|
9091
9159
|
|
|
9092
9160
|
async startScreenSharing(constraints , callSession ) {
|
|
9093
|
-
logger$
|
|
9161
|
+
logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
9094
9162
|
|
|
9095
9163
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
9096
9164
|
if (!screenShareStream) {
|
|
@@ -9130,7 +9198,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9130
9198
|
return;
|
|
9131
9199
|
}
|
|
9132
9200
|
|
|
9133
|
-
logger$
|
|
9201
|
+
logger$5.info('WebRTC phone - stop screen sharing', {
|
|
9134
9202
|
restoreLocalStream,
|
|
9135
9203
|
});
|
|
9136
9204
|
|
|
@@ -9186,24 +9254,26 @@ class WebRTCPhone extends Emitter {
|
|
|
9186
9254
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
9187
9255
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
9188
9256
|
|
|
9189
|
-
logger$
|
|
9257
|
+
logger$5.info('WebRTC phone - on screensharing', {
|
|
9190
9258
|
hadVideo,
|
|
9191
9259
|
id: this.getSipSessionId(sipSession),
|
|
9192
9260
|
screenTrack,
|
|
9193
9261
|
});
|
|
9194
9262
|
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9263
|
+
if (screenTrack) {
|
|
9264
|
+
screenTrack.onended = () => {
|
|
9265
|
+
logger$5.info('WebRTC phone - on screenshare ended', {
|
|
9266
|
+
hadVideo,
|
|
9267
|
+
id: this.getSipSessionId(sipSession),
|
|
9268
|
+
screenTrack,
|
|
9269
|
+
});
|
|
9201
9270
|
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9271
|
+
this.eventEmitter.emit(
|
|
9272
|
+
ON_SHARE_SCREEN_ENDING,
|
|
9273
|
+
this._createCallSession(sipSession, callSession),
|
|
9274
|
+
);
|
|
9275
|
+
};
|
|
9276
|
+
}
|
|
9207
9277
|
|
|
9208
9278
|
this.currentScreenShare = {
|
|
9209
9279
|
stream: screenStream,
|
|
@@ -9223,7 +9293,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9223
9293
|
}
|
|
9224
9294
|
|
|
9225
9295
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9226
|
-
logger$
|
|
9296
|
+
logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9227
9297
|
|
|
9228
9298
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9229
9299
|
this.currentSipSession = sipSession;
|
|
@@ -9241,7 +9311,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9241
9311
|
}
|
|
9242
9312
|
|
|
9243
9313
|
changeAudioDevice(id ) {
|
|
9244
|
-
logger$
|
|
9314
|
+
logger$5.info('WebRTC phone - change audio device', { deviceId: id });
|
|
9245
9315
|
this.audioOutputDeviceId = id;
|
|
9246
9316
|
this.client.changeAudioOutputDevice(id);
|
|
9247
9317
|
}
|
|
@@ -9251,14 +9321,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9251
9321
|
}
|
|
9252
9322
|
|
|
9253
9323
|
changeRingDevice(id ) {
|
|
9254
|
-
logger$
|
|
9324
|
+
logger$5.info('WebRTC phone - changing ring device', { id });
|
|
9255
9325
|
|
|
9256
9326
|
this.audioRingDeviceId = id;
|
|
9257
9327
|
}
|
|
9258
9328
|
|
|
9259
9329
|
// volume is a value between 0 and 1
|
|
9260
9330
|
changeAudioVolume(volume ) {
|
|
9261
|
-
logger$
|
|
9331
|
+
logger$5.info('WebRTC phone - changing audio volume', { volume });
|
|
9262
9332
|
|
|
9263
9333
|
this.audioOutputVolume = volume;
|
|
9264
9334
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -9266,31 +9336,31 @@ class WebRTCPhone extends Emitter {
|
|
|
9266
9336
|
|
|
9267
9337
|
// volume is a value between 0 and 1
|
|
9268
9338
|
changeRingVolume(volume ) {
|
|
9269
|
-
logger$
|
|
9339
|
+
logger$5.info('WebRTC phone - changing ring volume', { volume });
|
|
9270
9340
|
|
|
9271
9341
|
this.audioRingVolume = volume;
|
|
9272
9342
|
}
|
|
9273
9343
|
|
|
9274
9344
|
changeAudioInputDevice(id ) {
|
|
9275
|
-
logger$
|
|
9345
|
+
logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9276
9346
|
|
|
9277
9347
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9278
9348
|
}
|
|
9279
9349
|
|
|
9280
9350
|
changeVideoInputDevice(id ) {
|
|
9281
|
-
logger$
|
|
9351
|
+
logger$5.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9282
9352
|
|
|
9283
9353
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9284
9354
|
}
|
|
9285
9355
|
|
|
9286
9356
|
changeSessionVideoInputDevice(id ) {
|
|
9287
|
-
logger$
|
|
9357
|
+
logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9288
9358
|
|
|
9289
9359
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9290
9360
|
}
|
|
9291
9361
|
|
|
9292
9362
|
_onCallTerminated(sipSession ) {
|
|
9293
|
-
logger$
|
|
9363
|
+
logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9294
9364
|
|
|
9295
9365
|
const callSession = this._createCallSession(sipSession);
|
|
9296
9366
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9324,7 +9394,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9324
9394
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9325
9395
|
|
|
9326
9396
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9327
|
-
logger$
|
|
9397
|
+
logger$5.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9328
9398
|
sipId: sipSession.id,
|
|
9329
9399
|
shouldRetrigger,
|
|
9330
9400
|
hasIncomingCallSession,
|
|
@@ -9415,37 +9485,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9415
9485
|
|
|
9416
9486
|
// Deprecated
|
|
9417
9487
|
getLocalStreamForCall(callSession ) {
|
|
9418
|
-
logger$
|
|
9488
|
+
logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9419
9489
|
|
|
9420
9490
|
return this.getLocalStream(callSession);
|
|
9421
9491
|
}
|
|
9422
9492
|
|
|
9423
9493
|
// Deprecated
|
|
9424
9494
|
getRemoteStreamForCall(callSession ) {
|
|
9425
|
-
logger$
|
|
9495
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9426
9496
|
|
|
9427
9497
|
return this.getRemoteVideoStream(callSession);
|
|
9428
9498
|
}
|
|
9429
9499
|
|
|
9430
9500
|
getRemoteStreamsForCall(callSession ) {
|
|
9431
|
-
logger$
|
|
9501
|
+
logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9432
9502
|
|
|
9433
9503
|
return this.getRemoteStream(callSession);
|
|
9434
9504
|
}
|
|
9435
9505
|
|
|
9436
9506
|
accept(callSession , cameraEnabled ) {
|
|
9437
|
-
logger$
|
|
9507
|
+
logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9438
9508
|
if (this.currentSipSession) {
|
|
9439
9509
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9440
9510
|
}
|
|
9441
9511
|
|
|
9442
9512
|
if (!callSession) {
|
|
9443
|
-
logger$
|
|
9513
|
+
logger$5.warn('no CallSession to accept.');
|
|
9444
9514
|
return Promise.resolve(null);
|
|
9445
9515
|
}
|
|
9446
9516
|
|
|
9447
9517
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9448
|
-
logger$
|
|
9518
|
+
logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9449
9519
|
return Promise.resolve(callSession.sipCallId);
|
|
9450
9520
|
}
|
|
9451
9521
|
|
|
@@ -9457,24 +9527,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9457
9527
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9458
9528
|
if (sipSession) {
|
|
9459
9529
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
9460
|
-
logger$
|
|
9530
|
+
logger$5.warn('Trying to answer a terminated sipSession.');
|
|
9461
9531
|
|
|
9462
9532
|
return Promise.resolve(null);
|
|
9463
9533
|
}
|
|
9464
9534
|
|
|
9465
|
-
logger$
|
|
9535
|
+
logger$5.info('accept call, session found', { sipId: sipSession.id });
|
|
9466
9536
|
|
|
9467
9537
|
// $FlowFixMe
|
|
9468
9538
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9469
9539
|
return callSession.sipCallId;
|
|
9470
9540
|
}).catch(e => {
|
|
9471
|
-
logger$
|
|
9541
|
+
logger$5.error(e);
|
|
9472
9542
|
this.endCurrentCall(callSession);
|
|
9473
9543
|
throw e;
|
|
9474
9544
|
});
|
|
9475
9545
|
}
|
|
9476
9546
|
|
|
9477
|
-
logger$
|
|
9547
|
+
logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9478
9548
|
|
|
9479
9549
|
return Promise.resolve(null);
|
|
9480
9550
|
}
|
|
@@ -9484,7 +9554,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9484
9554
|
}
|
|
9485
9555
|
|
|
9486
9556
|
async reject(callSession ) {
|
|
9487
|
-
logger$
|
|
9557
|
+
logger$5.info('reject WebRTC called', { id: callSession.getId() });
|
|
9488
9558
|
|
|
9489
9559
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9490
9560
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9496,14 +9566,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9496
9566
|
|
|
9497
9567
|
const sipSession = this.findSipSession(callSession);
|
|
9498
9568
|
if (sipSession) {
|
|
9499
|
-
logger$
|
|
9569
|
+
logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
9500
9570
|
|
|
9501
9571
|
this.client.hangup(sipSession);
|
|
9502
9572
|
}
|
|
9503
9573
|
}
|
|
9504
9574
|
|
|
9505
9575
|
async ignore(callSession ) {
|
|
9506
|
-
logger$
|
|
9576
|
+
logger$5.info('WebRTC ignore', { id: callSession.getId() });
|
|
9507
9577
|
|
|
9508
9578
|
// kill the ring
|
|
9509
9579
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -9515,14 +9585,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9515
9585
|
const sipSession = this.findSipSession(callSession);
|
|
9516
9586
|
|
|
9517
9587
|
if (sipSession) {
|
|
9518
|
-
logger$
|
|
9588
|
+
logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
9519
9589
|
|
|
9520
9590
|
return this.client.atxfer(sipSession);
|
|
9521
9591
|
}
|
|
9522
9592
|
}
|
|
9523
9593
|
|
|
9524
9594
|
hold(callSession , withEvent = true, isConference = false) {
|
|
9525
|
-
logger$
|
|
9595
|
+
logger$5.info('WebRTC hold', { id: callSession.getId() });
|
|
9526
9596
|
|
|
9527
9597
|
const sipSession = this.findSipSession(callSession);
|
|
9528
9598
|
|
|
@@ -9537,18 +9607,18 @@ class WebRTCPhone extends Emitter {
|
|
|
9537
9607
|
}
|
|
9538
9608
|
|
|
9539
9609
|
resume(callSession , isConference = false, withEvent = true) {
|
|
9540
|
-
logger$
|
|
9610
|
+
logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
9541
9611
|
|
|
9542
9612
|
const sipSession = this.findSipSession(callSession);
|
|
9543
9613
|
if (!sipSession) {
|
|
9544
9614
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
9545
9615
|
}
|
|
9546
9616
|
|
|
9547
|
-
logger$
|
|
9617
|
+
logger$5.info('WebRTC resuming', { sipId: sipSession.id });
|
|
9548
9618
|
|
|
9549
9619
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9550
9620
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9551
|
-
logger$
|
|
9621
|
+
logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9552
9622
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
9553
9623
|
}
|
|
9554
9624
|
|
|
@@ -9573,7 +9643,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9573
9643
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9574
9644
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
9575
9645
|
|
|
9576
|
-
logger$
|
|
9646
|
+
logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9577
9647
|
|
|
9578
9648
|
// Stop screenshre if needed
|
|
9579
9649
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -9604,7 +9674,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9604
9674
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
9605
9675
|
}
|
|
9606
9676
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9607
|
-
logger$
|
|
9677
|
+
logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
9608
9678
|
|
|
9609
9679
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
9610
9680
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -9648,14 +9718,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9648
9718
|
}
|
|
9649
9719
|
|
|
9650
9720
|
mute(callSession , withEvent = true) {
|
|
9651
|
-
logger$
|
|
9721
|
+
logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
9652
9722
|
|
|
9653
9723
|
const sipSession = this.findSipSession(callSession);
|
|
9654
9724
|
if (!sipSession) {
|
|
9655
9725
|
return;
|
|
9656
9726
|
}
|
|
9657
9727
|
|
|
9658
|
-
logger$
|
|
9728
|
+
logger$5.info('WebRTC muting', { sipId: sipSession.id });
|
|
9659
9729
|
this.client.mute(sipSession);
|
|
9660
9730
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
9661
9731
|
|
|
@@ -9669,14 +9739,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9669
9739
|
}
|
|
9670
9740
|
|
|
9671
9741
|
unmute(callSession , withEvent = true) {
|
|
9672
|
-
logger$
|
|
9742
|
+
logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
9673
9743
|
|
|
9674
9744
|
const sipSession = this.findSipSession(callSession);
|
|
9675
9745
|
if (!sipSession) {
|
|
9676
9746
|
return;
|
|
9677
9747
|
}
|
|
9678
9748
|
|
|
9679
|
-
logger$
|
|
9749
|
+
logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
9680
9750
|
this.client.unmute(sipSession);
|
|
9681
9751
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
9682
9752
|
|
|
@@ -9703,7 +9773,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9703
9773
|
if (!sipSession) {
|
|
9704
9774
|
return;
|
|
9705
9775
|
}
|
|
9706
|
-
logger$
|
|
9776
|
+
logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
9707
9777
|
|
|
9708
9778
|
this.client.toggleCameraOn(sipSession);
|
|
9709
9779
|
|
|
@@ -9715,7 +9785,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9715
9785
|
if (!sipSession) {
|
|
9716
9786
|
return;
|
|
9717
9787
|
}
|
|
9718
|
-
logger$
|
|
9788
|
+
logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
9719
9789
|
|
|
9720
9790
|
this.client.toggleCameraOff(sipSession);
|
|
9721
9791
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -9727,7 +9797,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9727
9797
|
return;
|
|
9728
9798
|
}
|
|
9729
9799
|
|
|
9730
|
-
logger$
|
|
9800
|
+
logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
9731
9801
|
this.client.sendDTMF(sipSession, tone);
|
|
9732
9802
|
}
|
|
9733
9803
|
|
|
@@ -9735,7 +9805,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9735
9805
|
// @TODO: line is not used here
|
|
9736
9806
|
async makeCall(number , line , cameraEnabled ,
|
|
9737
9807
|
audioOnly = false, conference = false) {
|
|
9738
|
-
logger$
|
|
9808
|
+
logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9739
9809
|
if (!number) {
|
|
9740
9810
|
return Promise.resolve(null);
|
|
9741
9811
|
}
|
|
@@ -9745,7 +9815,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9745
9815
|
}
|
|
9746
9816
|
if (this.currentSipSession) {
|
|
9747
9817
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
9748
|
-
logger$
|
|
9818
|
+
logger$5.warn('Unable to hold current session when making another call', e);
|
|
9749
9819
|
});
|
|
9750
9820
|
}
|
|
9751
9821
|
|
|
@@ -9755,7 +9825,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9755
9825
|
this._bindEvents(sipSession);
|
|
9756
9826
|
} catch (error) {
|
|
9757
9827
|
console.warn(error);
|
|
9758
|
-
logger$
|
|
9828
|
+
logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
9759
9829
|
return Promise.resolve(null);
|
|
9760
9830
|
}
|
|
9761
9831
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -9783,7 +9853,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9783
9853
|
return;
|
|
9784
9854
|
}
|
|
9785
9855
|
|
|
9786
|
-
logger$
|
|
9856
|
+
logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
9787
9857
|
|
|
9788
9858
|
this.client.transfer(sipSession, target);
|
|
9789
9859
|
}
|
|
@@ -9792,7 +9862,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9792
9862
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
9793
9863
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
9794
9864
|
|
|
9795
|
-
logger$
|
|
9865
|
+
logger$5.info('WebRTC indirect transfer', {
|
|
9796
9866
|
sipId: sipSession ? sipSession.id : null,
|
|
9797
9867
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
9798
9868
|
});
|
|
@@ -9831,7 +9901,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9831
9901
|
return false;
|
|
9832
9902
|
}
|
|
9833
9903
|
|
|
9834
|
-
logger$
|
|
9904
|
+
logger$5.info('WebRTC hangup', { sipId: sipSession.id });
|
|
9835
9905
|
|
|
9836
9906
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9837
9907
|
|
|
@@ -9877,7 +9947,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9877
9947
|
endCurrentCall(callSession ) {
|
|
9878
9948
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
9879
9949
|
|
|
9880
|
-
logger$
|
|
9950
|
+
logger$5.info('Ending current call', {
|
|
9881
9951
|
id: callSession ? callSession.getId() : null,
|
|
9882
9952
|
isCurrent,
|
|
9883
9953
|
});
|
|
@@ -9901,7 +9971,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9901
9971
|
}
|
|
9902
9972
|
|
|
9903
9973
|
async close() {
|
|
9904
|
-
logger$
|
|
9974
|
+
logger$5.info('WebRTC close');
|
|
9905
9975
|
|
|
9906
9976
|
try {
|
|
9907
9977
|
await Promise.race([
|
|
@@ -9909,7 +9979,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9909
9979
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
9910
9980
|
]);
|
|
9911
9981
|
} catch (e) {
|
|
9912
|
-
logger$
|
|
9982
|
+
logger$5.error('WebRTC close, unregister error', e);
|
|
9913
9983
|
}
|
|
9914
9984
|
|
|
9915
9985
|
this.client.close();
|
|
@@ -9927,12 +9997,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9927
9997
|
}
|
|
9928
9998
|
|
|
9929
9999
|
enableRinging() {
|
|
9930
|
-
logger$
|
|
10000
|
+
logger$5.info('WebRTC enable ringing');
|
|
9931
10001
|
this.ringingEnabled = true;
|
|
9932
10002
|
}
|
|
9933
10003
|
|
|
9934
10004
|
disableRinging() {
|
|
9935
|
-
logger$
|
|
10005
|
+
logger$5.info('WebRTC disable ringing');
|
|
9936
10006
|
this.ringingEnabled = false;
|
|
9937
10007
|
}
|
|
9938
10008
|
|
|
@@ -9972,7 +10042,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9972
10042
|
|
|
9973
10043
|
// Deprecated
|
|
9974
10044
|
getLocalMediaStream(callSession ) {
|
|
9975
|
-
logger$
|
|
10045
|
+
logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9976
10046
|
return this.getLocalStream(callSession);
|
|
9977
10047
|
}
|
|
9978
10048
|
|
|
@@ -9992,6 +10062,10 @@ class WebRTCPhone extends Emitter {
|
|
|
9992
10062
|
return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
|
|
9993
10063
|
}
|
|
9994
10064
|
|
|
10065
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
10066
|
+
return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
|
|
10067
|
+
}
|
|
10068
|
+
|
|
9995
10069
|
hasRemoteVideo(callSession ) {
|
|
9996
10070
|
return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
|
|
9997
10071
|
}
|
|
@@ -10010,7 +10084,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10010
10084
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
10011
10085
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
10012
10086
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
10013
|
-
logger$
|
|
10087
|
+
logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
10014
10088
|
|
|
10015
10089
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
10016
10090
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -10033,7 +10107,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10033
10107
|
});
|
|
10034
10108
|
|
|
10035
10109
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
10036
|
-
logger$
|
|
10110
|
+
logger$5.info('WebRTC on reinvite', {
|
|
10037
10111
|
sessionId: args[0].id,
|
|
10038
10112
|
inviteId: args[1].id,
|
|
10039
10113
|
updatedCalleeName: args[2],
|
|
@@ -10053,7 +10127,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10053
10127
|
});
|
|
10054
10128
|
|
|
10055
10129
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
10056
|
-
logger$
|
|
10130
|
+
logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
10057
10131
|
|
|
10058
10132
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
10059
10133
|
|
|
@@ -10064,22 +10138,22 @@ class WebRTCPhone extends Emitter {
|
|
|
10064
10138
|
this.client.on('ended', () => {});
|
|
10065
10139
|
|
|
10066
10140
|
this.client.on(this.client.ON_ERROR, e => {
|
|
10067
|
-
logger$
|
|
10141
|
+
logger$5.error('WebRTC error', e);
|
|
10068
10142
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
10069
10143
|
});
|
|
10070
10144
|
|
|
10071
10145
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
10072
|
-
logger$
|
|
10146
|
+
logger$5.info('WebRTC unregistered');
|
|
10073
10147
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10074
10148
|
});
|
|
10075
10149
|
|
|
10076
10150
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
10077
|
-
logger$
|
|
10078
|
-
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
10151
|
+
logger$5.info('WebRTC disconnected');
|
|
10152
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
10079
10153
|
});
|
|
10080
10154
|
|
|
10081
10155
|
this.client.on(this.client.REGISTERED, () => {
|
|
10082
|
-
logger$
|
|
10156
|
+
logger$5.info('WebRTC registered', {
|
|
10083
10157
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
10084
10158
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
10085
10159
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -10092,23 +10166,27 @@ class WebRTCPhone extends Emitter {
|
|
|
10092
10166
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
10093
10167
|
&& this.currentSipSession.state === sessionState.SessionState.Established) {
|
|
10094
10168
|
this.shouldSendReinvite = false;
|
|
10169
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
10170
|
+
const isConference = pc ? pc.sfu : false;
|
|
10171
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
10172
|
+
|
|
10095
10173
|
try {
|
|
10096
10174
|
// Send reinvite with iceRestart
|
|
10097
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
10175
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
10098
10176
|
} catch (e) {
|
|
10099
|
-
logger$
|
|
10177
|
+
logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
10100
10178
|
}
|
|
10101
10179
|
}
|
|
10102
10180
|
});
|
|
10103
10181
|
|
|
10104
10182
|
this.client.on(this.client.CONNECTED, () => {
|
|
10105
|
-
logger$
|
|
10183
|
+
logger$5.info('WebRTC client connected');
|
|
10106
10184
|
|
|
10107
10185
|
this.stopHeartbeat();
|
|
10108
10186
|
});
|
|
10109
10187
|
|
|
10110
10188
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
10111
|
-
logger$
|
|
10189
|
+
logger$5.info('WebRTC client disconnected');
|
|
10112
10190
|
|
|
10113
10191
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
10114
10192
|
|
|
@@ -10122,7 +10200,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10122
10200
|
});
|
|
10123
10201
|
|
|
10124
10202
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
10125
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
10203
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
10126
10204
|
});
|
|
10127
10205
|
|
|
10128
10206
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -10137,7 +10215,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10137
10215
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
10138
10216
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
10139
10217
|
|
|
10140
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
10218
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
|
|
10141
10219
|
});
|
|
10142
10220
|
|
|
10143
10221
|
// Used when upgrading directly in screenshare mode
|
|
@@ -10146,7 +10224,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10146
10224
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
10147
10225
|
const callSession = this.callSessions[sipSessionId];
|
|
10148
10226
|
|
|
10149
|
-
logger$
|
|
10227
|
+
logger$5.info('Updrading directly in screensharing mode', {
|
|
10150
10228
|
sipSessionId,
|
|
10151
10229
|
tracks: localStream ? localStream.getTracks() : null,
|
|
10152
10230
|
});
|
|
@@ -10178,6 +10256,15 @@ class WebRTCPhone extends Emitter {
|
|
|
10178
10256
|
return this.client.getSipSessionId(sipSession);
|
|
10179
10257
|
}
|
|
10180
10258
|
|
|
10259
|
+
_updateCallSession(callSession ) {
|
|
10260
|
+
const sipSession = this.findSipSession(callSession);
|
|
10261
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10262
|
+
|
|
10263
|
+
if (sipSessionId) {
|
|
10264
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10265
|
+
}
|
|
10266
|
+
}
|
|
10267
|
+
|
|
10181
10268
|
_onMessage(message ) {
|
|
10182
10269
|
if (!message || message.method !== 'MESSAGE') {
|
|
10183
10270
|
return;
|
|
@@ -10315,8 +10402,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10315
10402
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10316
10403
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10317
10404
|
ON_MESSAGE: ON_MESSAGE,
|
|
10318
|
-
ON_REINVITE: ON_REINVITE,
|
|
10319
|
-
ON_TRACK: ON_TRACK,
|
|
10405
|
+
ON_REINVITE: ON_REINVITE$1,
|
|
10406
|
+
ON_TRACK: ON_TRACK$1,
|
|
10320
10407
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10321
10408
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10322
10409
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10331,13 +10418,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10331
10418
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10332
10419
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10333
10420
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10334
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10421
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS$1,
|
|
10335
10422
|
ON_CHAT: ON_CHAT,
|
|
10336
10423
|
ON_SIGNAL: ON_SIGNAL,
|
|
10337
|
-
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10424
|
+
ON_DISCONNECTED: ON_DISCONNECTED$1,
|
|
10338
10425
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10339
10426
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10340
|
-
events: events,
|
|
10427
|
+
events: events$1,
|
|
10341
10428
|
'default': WebRTCPhone
|
|
10342
10429
|
});
|
|
10343
10430
|
|
|
@@ -10675,6 +10762,11 @@ class Phone extends Emitter {
|
|
|
10675
10762
|
return this.getRemoteVideoStream(callSession);
|
|
10676
10763
|
}
|
|
10677
10764
|
|
|
10765
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
10766
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
10767
|
+
return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
|
|
10768
|
+
}
|
|
10769
|
+
|
|
10678
10770
|
hasVideo(callSession ) {
|
|
10679
10771
|
return this.phone ? this.phone.hasVideo(callSession) : false;
|
|
10680
10772
|
}
|
|
@@ -10726,7 +10818,7 @@ class Phone extends Emitter {
|
|
|
10726
10818
|
|
|
10727
10819
|
_transferEvents() {
|
|
10728
10820
|
this.unbind();
|
|
10729
|
-
[...events
|
|
10821
|
+
[...events, ...transportEvents].forEach(event => {
|
|
10730
10822
|
this.client.on(event, (...args) =>
|
|
10731
10823
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
10732
10824
|
});
|
|
@@ -10748,7 +10840,7 @@ var Phone$1 = global.wazoTelephonyInstance;
|
|
|
10748
10840
|
|
|
10749
10841
|
//
|
|
10750
10842
|
|
|
10751
|
-
const SOCKET_EVENTS
|
|
10843
|
+
const SOCKET_EVENTS = {
|
|
10752
10844
|
ON_OPEN: 'onopen',
|
|
10753
10845
|
ON_MESSAGE: 'onmessage',
|
|
10754
10846
|
ON_ERROR: 'onerror',
|
|
@@ -10834,6 +10926,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
10834
10926
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
10835
10927
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
10836
10928
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
10929
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
10837
10930
|
|
|
10838
10931
|
const BLACKLIST_EVENTS = [
|
|
10839
10932
|
CHAT_MESSAGE_SENT,
|
|
@@ -10843,7 +10936,7 @@ const BLACKLIST_EVENTS = [
|
|
|
10843
10936
|
];
|
|
10844
10937
|
|
|
10845
10938
|
const HEARTBEAT_ENGINE_VERSION = '20.09';
|
|
10846
|
-
const logger$
|
|
10939
|
+
const logger$7 = IssueReporter$1.loggerFor('wazo-ws');
|
|
10847
10940
|
const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
|
|
10848
10941
|
|
|
10849
10942
|
class WebSocketClient extends Emitter {
|
|
@@ -10892,24 +10985,24 @@ class WebSocketClient extends Emitter {
|
|
|
10892
10985
|
}
|
|
10893
10986
|
|
|
10894
10987
|
connect() {
|
|
10895
|
-
logger$
|
|
10988
|
+
logger$7.info('connect method started', { host: this.host, token: this.token });
|
|
10896
10989
|
this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
|
|
10897
10990
|
if (this.options.binaryType) {
|
|
10898
10991
|
this.socket.binaryType = this.options.binaryType;
|
|
10899
10992
|
}
|
|
10900
10993
|
|
|
10901
10994
|
this.socket.onopen = () => {
|
|
10902
|
-
logger$
|
|
10903
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10995
|
+
logger$7.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
10996
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
10904
10997
|
};
|
|
10905
10998
|
|
|
10906
10999
|
this.socket.onerror = event => {
|
|
10907
|
-
logger$
|
|
10908
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11000
|
+
logger$7.error('on Wazo WS error', event.target);
|
|
11001
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
10909
11002
|
};
|
|
10910
11003
|
|
|
10911
11004
|
this.socket.onmessage = (event ) => {
|
|
10912
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11005
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
10913
11006
|
|
|
10914
11007
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
10915
11008
|
let { name } = message;
|
|
@@ -10934,7 +11027,7 @@ class WebSocketClient extends Emitter {
|
|
|
10934
11027
|
|
|
10935
11028
|
this.socket.onclose = event => {
|
|
10936
11029
|
// Can't be converted to JSON (circular structure)
|
|
10937
|
-
logger$
|
|
11030
|
+
logger$7.info('on Wazo WS close', {
|
|
10938
11031
|
reason: event.reason,
|
|
10939
11032
|
code: event.code,
|
|
10940
11033
|
readyState: event.target.readyState,
|
|
@@ -10942,22 +11035,22 @@ class WebSocketClient extends Emitter {
|
|
|
10942
11035
|
token: this.token,
|
|
10943
11036
|
});
|
|
10944
11037
|
this.initialized = false;
|
|
10945
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11038
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
10946
11039
|
|
|
10947
11040
|
switch (event.code) {
|
|
10948
11041
|
case 4002:
|
|
10949
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11042
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
10950
11043
|
break;
|
|
10951
11044
|
}
|
|
10952
11045
|
};
|
|
10953
11046
|
|
|
10954
11047
|
this.socket.onerror = event => {
|
|
10955
|
-
logger$
|
|
11048
|
+
logger$7.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
|
|
10956
11049
|
};
|
|
10957
11050
|
}
|
|
10958
11051
|
|
|
10959
11052
|
close(force = false) {
|
|
10960
|
-
logger$
|
|
11053
|
+
logger$7.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
|
|
10961
11054
|
|
|
10962
11055
|
if (!this.socket) {
|
|
10963
11056
|
return;
|
|
@@ -10975,7 +11068,7 @@ class WebSocketClient extends Emitter {
|
|
|
10975
11068
|
|
|
10976
11069
|
updateToken(token ) {
|
|
10977
11070
|
this.token = token;
|
|
10978
|
-
logger$
|
|
11071
|
+
logger$7.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
|
|
10979
11072
|
|
|
10980
11073
|
if (this.socket) {
|
|
10981
11074
|
// If still connected, send the token to the WS
|
|
@@ -10993,7 +11086,7 @@ class WebSocketClient extends Emitter {
|
|
|
10993
11086
|
}
|
|
10994
11087
|
|
|
10995
11088
|
startHeartbeat() {
|
|
10996
|
-
logger$
|
|
11089
|
+
logger$7.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
|
|
10997
11090
|
|
|
10998
11091
|
if (!this.socket) {
|
|
10999
11092
|
this.heartbeat.stop();
|
|
@@ -11007,7 +11100,7 @@ class WebSocketClient extends Emitter {
|
|
|
11007
11100
|
}
|
|
11008
11101
|
|
|
11009
11102
|
stopHeartbeat() {
|
|
11010
|
-
logger$
|
|
11103
|
+
logger$7.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
|
|
11011
11104
|
|
|
11012
11105
|
this.heartbeat.stop();
|
|
11013
11106
|
}
|
|
@@ -11037,7 +11130,7 @@ class WebSocketClient extends Emitter {
|
|
|
11037
11130
|
}
|
|
11038
11131
|
|
|
11039
11132
|
reconnect(reason ) {
|
|
11040
|
-
logger$
|
|
11133
|
+
logger$7.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
|
|
11041
11134
|
if (!this.socket) {
|
|
11042
11135
|
return;
|
|
11043
11136
|
}
|
|
@@ -11062,7 +11155,7 @@ class WebSocketClient extends Emitter {
|
|
|
11062
11155
|
break;
|
|
11063
11156
|
case 'start':
|
|
11064
11157
|
this.initialized = true;
|
|
11065
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11158
|
+
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
11066
11159
|
break;
|
|
11067
11160
|
default:
|
|
11068
11161
|
this.eventEmitter.emit('message', message);
|
|
@@ -11093,7 +11186,7 @@ class WebSocketClient extends Emitter {
|
|
|
11093
11186
|
this.close();
|
|
11094
11187
|
}
|
|
11095
11188
|
const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
|
|
11096
|
-
logger$
|
|
11189
|
+
logger$7.log('Wazo WS url computed to reconnect', { url });
|
|
11097
11190
|
|
|
11098
11191
|
return url;
|
|
11099
11192
|
}
|
|
@@ -11101,15 +11194,15 @@ class WebSocketClient extends Emitter {
|
|
|
11101
11194
|
_onHeartbeat(message ) {
|
|
11102
11195
|
if (message.payload === 'pong') {
|
|
11103
11196
|
this.heartbeat.onHeartbeat();
|
|
11104
|
-
logger$
|
|
11197
|
+
logger$7.log('on heartbeat received from Wazo WS');
|
|
11105
11198
|
}
|
|
11106
11199
|
}
|
|
11107
11200
|
|
|
11108
11201
|
async _onHeartbeatTimeout() {
|
|
11109
|
-
logger$
|
|
11202
|
+
logger$7.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
11110
11203
|
|
|
11111
11204
|
this.close();
|
|
11112
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
11205
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
11113
11206
|
|
|
11114
11207
|
if (this.onHeartBeatTimeout) {
|
|
11115
11208
|
this.onHeartBeatTimeout();
|
|
@@ -11184,11 +11277,12 @@ WebSocketClient.eventLists = [
|
|
|
11184
11277
|
AGENT_UNPAUSED,
|
|
11185
11278
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
11186
11279
|
CONFERENCE_ADHOC_DELETED,
|
|
11280
|
+
MEETING_USER_PROGRESS,
|
|
11187
11281
|
];
|
|
11188
11282
|
|
|
11189
11283
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
11190
11284
|
__proto__: null,
|
|
11191
|
-
SOCKET_EVENTS: SOCKET_EVENTS
|
|
11285
|
+
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
11192
11286
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
11193
11287
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
11194
11288
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -11254,16 +11348,17 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
11254
11348
|
AGENT_UNPAUSED: AGENT_UNPAUSED,
|
|
11255
11349
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
11256
11350
|
CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
|
|
11351
|
+
MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
|
|
11257
11352
|
HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
|
|
11258
11353
|
'default': WebSocketClient
|
|
11259
11354
|
});
|
|
11260
11355
|
|
|
11261
11356
|
//
|
|
11262
11357
|
|
|
11263
|
-
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11264
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
11358
|
+
const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11359
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
|
|
11265
11360
|
|
|
11266
|
-
const logger$
|
|
11361
|
+
const logger$8 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
11267
11362
|
|
|
11268
11363
|
class Websocket extends Emitter {
|
|
11269
11364
|
|
|
@@ -11277,9 +11372,9 @@ class Websocket extends Emitter {
|
|
|
11277
11372
|
// $FlowFixMe
|
|
11278
11373
|
this[key] = OTHER_EVENTS[key];
|
|
11279
11374
|
});
|
|
11280
|
-
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
11375
|
+
Object.keys(SOCKET_EVENTS$1).forEach(key => {
|
|
11281
11376
|
// $FlowFixMe
|
|
11282
|
-
this[key] = SOCKET_EVENTS[key];
|
|
11377
|
+
this[key] = SOCKET_EVENTS$1[key];
|
|
11283
11378
|
});
|
|
11284
11379
|
this.eventLists = WebSocketClient.eventLists;
|
|
11285
11380
|
|
|
@@ -11287,7 +11382,7 @@ class Websocket extends Emitter {
|
|
|
11287
11382
|
}
|
|
11288
11383
|
|
|
11289
11384
|
open(host , session ) {
|
|
11290
|
-
logger$
|
|
11385
|
+
logger$8.info('open simple WebSocket', { host, token: session.token });
|
|
11291
11386
|
this.ws = new WebSocketClient(
|
|
11292
11387
|
{
|
|
11293
11388
|
host,
|
|
@@ -11315,7 +11410,7 @@ class Websocket extends Emitter {
|
|
|
11315
11410
|
}
|
|
11316
11411
|
|
|
11317
11412
|
updateToken(token ) {
|
|
11318
|
-
logger$
|
|
11413
|
+
logger$8.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
11319
11414
|
|
|
11320
11415
|
if (!this.ws) {
|
|
11321
11416
|
return;
|
|
@@ -11343,7 +11438,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
11343
11438
|
|
|
11344
11439
|
//
|
|
11345
11440
|
|
|
11346
|
-
const logger$
|
|
11441
|
+
const logger$9 = IssueReporter$1.loggerFor('room');
|
|
11347
11442
|
|
|
11348
11443
|
class Participant extends Emitter {
|
|
11349
11444
|
|
|
@@ -11465,7 +11560,7 @@ class Participant extends Emitter {
|
|
|
11465
11560
|
}
|
|
11466
11561
|
|
|
11467
11562
|
onTalking(isTalking ) {
|
|
11468
|
-
logger$
|
|
11563
|
+
logger$9.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
11469
11564
|
this.isTalking = isTalking;
|
|
11470
11565
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
11471
11566
|
// directly from asterisk, there's no need to do so
|
|
@@ -11568,7 +11663,7 @@ class Participant extends Emitter {
|
|
|
11568
11663
|
}
|
|
11569
11664
|
|
|
11570
11665
|
updateStatus(status , broadcast = true) {
|
|
11571
|
-
logger$
|
|
11666
|
+
logger$9.info('updating participant status', { name: this.name, status });
|
|
11572
11667
|
|
|
11573
11668
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
11574
11669
|
if (status.audioMuted) {
|
|
@@ -11616,7 +11711,7 @@ class Participant extends Emitter {
|
|
|
11616
11711
|
|
|
11617
11712
|
broadcastStatus(inboundStatus = null) {
|
|
11618
11713
|
const status = inboundStatus || this.getStatus();
|
|
11619
|
-
logger$
|
|
11714
|
+
logger$9.info('broadcasting participant status', { callId: this.callId, status });
|
|
11620
11715
|
|
|
11621
11716
|
this.room.sendSignal({
|
|
11622
11717
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -11652,9 +11747,9 @@ class LocalParticipant extends Participant {
|
|
|
11652
11747
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
11653
11748
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
11654
11749
|
|
|
11655
|
-
const logger$
|
|
11750
|
+
const logger$a = IssueReporter$1.loggerFor('sdk-room');
|
|
11656
11751
|
|
|
11657
|
-
class Room
|
|
11752
|
+
class Room extends Emitter {
|
|
11658
11753
|
|
|
11659
11754
|
|
|
11660
11755
|
|
|
@@ -11712,7 +11807,7 @@ class Room$1 extends Emitter {
|
|
|
11712
11807
|
extra = {},
|
|
11713
11808
|
) {
|
|
11714
11809
|
super();
|
|
11715
|
-
logger$
|
|
11810
|
+
logger$a.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
11716
11811
|
|
|
11717
11812
|
// Represents the room callSession
|
|
11718
11813
|
this.callSession = callSession;
|
|
@@ -11778,7 +11873,7 @@ class Room$1 extends Emitter {
|
|
|
11778
11873
|
* @returns {Promise<Room>}
|
|
11779
11874
|
*/
|
|
11780
11875
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
11781
|
-
logger$
|
|
11876
|
+
logger$a.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
11782
11877
|
|
|
11783
11878
|
if (!room) {
|
|
11784
11879
|
await Wazo.Phone.connect();
|
|
@@ -11791,7 +11886,7 @@ class Room$1 extends Emitter {
|
|
|
11791
11886
|
|
|
11792
11887
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
11793
11888
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
11794
|
-
logger$
|
|
11889
|
+
logger$a.info('room call received via WS', { callId: data.call_id });
|
|
11795
11890
|
if (room) {
|
|
11796
11891
|
room.setCallId(data.call_id);
|
|
11797
11892
|
}
|
|
@@ -11799,7 +11894,7 @@ class Room$1 extends Emitter {
|
|
|
11799
11894
|
|
|
11800
11895
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
11801
11896
|
// eslint-disable-next-line no-param-reassign
|
|
11802
|
-
room = new Room
|
|
11897
|
+
room = new Room(callSession, extension, null, null, extra);
|
|
11803
11898
|
|
|
11804
11899
|
// Wait for the call to be accepted
|
|
11805
11900
|
await new Promise((resolve, reject) => {
|
|
@@ -11820,7 +11915,7 @@ class Room$1 extends Emitter {
|
|
|
11820
11915
|
// Retrieve conference
|
|
11821
11916
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
11822
11917
|
|
|
11823
|
-
logger$
|
|
11918
|
+
logger$a.info('connected to room', {
|
|
11824
11919
|
sourceId: conference ? conference.sourceId : null,
|
|
11825
11920
|
name: conference ? conference.name : null,
|
|
11826
11921
|
});
|
|
@@ -11830,7 +11925,7 @@ class Room$1 extends Emitter {
|
|
|
11830
11925
|
room.setName(conference.name);
|
|
11831
11926
|
}
|
|
11832
11927
|
} else if (meeting) {
|
|
11833
|
-
logger$
|
|
11928
|
+
logger$a.info('Already connected to meeting', {
|
|
11834
11929
|
uuid: meeting.uuid,
|
|
11835
11930
|
name: meeting.name,
|
|
11836
11931
|
});
|
|
@@ -11843,13 +11938,13 @@ class Room$1 extends Emitter {
|
|
|
11843
11938
|
}
|
|
11844
11939
|
|
|
11845
11940
|
static disconnect() {
|
|
11846
|
-
logger$
|
|
11941
|
+
logger$a.info('static disconnection to room');
|
|
11847
11942
|
|
|
11848
11943
|
Wazo.Phone.disconnect();
|
|
11849
11944
|
}
|
|
11850
11945
|
|
|
11851
11946
|
async disconnect() {
|
|
11852
|
-
logger$
|
|
11947
|
+
logger$a.info('disconnection to room called');
|
|
11853
11948
|
|
|
11854
11949
|
await Wazo.Phone.hangup(this.callSession);
|
|
11855
11950
|
this.callSession = null;
|
|
@@ -11869,19 +11964,19 @@ class Room$1 extends Emitter {
|
|
|
11869
11964
|
}
|
|
11870
11965
|
|
|
11871
11966
|
setSourceId(sourceId ) {
|
|
11872
|
-
logger$
|
|
11967
|
+
logger$a.info('set room source id', { sourceId });
|
|
11873
11968
|
|
|
11874
11969
|
this.sourceId = sourceId;
|
|
11875
11970
|
}
|
|
11876
11971
|
|
|
11877
11972
|
setMeetingUuid(meetingUuid ) {
|
|
11878
|
-
logger$
|
|
11973
|
+
logger$a.info('set meeting uuid', { meetingUuid });
|
|
11879
11974
|
|
|
11880
11975
|
this.meetingUuid = meetingUuid;
|
|
11881
11976
|
}
|
|
11882
11977
|
|
|
11883
11978
|
setCallId(callId ) {
|
|
11884
|
-
logger$
|
|
11979
|
+
logger$a.info('set room call id', { callId });
|
|
11885
11980
|
|
|
11886
11981
|
if (callId) {
|
|
11887
11982
|
this.callId = callId;
|
|
@@ -11889,7 +11984,7 @@ class Room$1 extends Emitter {
|
|
|
11889
11984
|
}
|
|
11890
11985
|
|
|
11891
11986
|
setName(name ) {
|
|
11892
|
-
logger$
|
|
11987
|
+
logger$a.info('set room name', { name });
|
|
11893
11988
|
|
|
11894
11989
|
this.name = name;
|
|
11895
11990
|
}
|
|
@@ -11908,7 +12003,7 @@ class Room$1 extends Emitter {
|
|
|
11908
12003
|
}
|
|
11909
12004
|
|
|
11910
12005
|
async startScreenSharing(constraints ) {
|
|
11911
|
-
logger$
|
|
12006
|
+
logger$a.info('start room screen sharing', { constraints });
|
|
11912
12007
|
|
|
11913
12008
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
11914
12009
|
if (!screensharingStream) {
|
|
@@ -11922,7 +12017,7 @@ class Room$1 extends Emitter {
|
|
|
11922
12017
|
}
|
|
11923
12018
|
|
|
11924
12019
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
11925
|
-
logger$
|
|
12020
|
+
logger$a.info('stop room screen sharing');
|
|
11926
12021
|
|
|
11927
12022
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
11928
12023
|
|
|
@@ -11934,7 +12029,7 @@ class Room$1 extends Emitter {
|
|
|
11934
12029
|
}
|
|
11935
12030
|
|
|
11936
12031
|
turnCameraOff() {
|
|
11937
|
-
logger$
|
|
12032
|
+
logger$a.info('turn room camera off');
|
|
11938
12033
|
|
|
11939
12034
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
11940
12035
|
|
|
@@ -11944,7 +12039,7 @@ class Room$1 extends Emitter {
|
|
|
11944
12039
|
}
|
|
11945
12040
|
|
|
11946
12041
|
turnCameraOn() {
|
|
11947
|
-
logger$
|
|
12042
|
+
logger$a.info('turn room camera on');
|
|
11948
12043
|
|
|
11949
12044
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
11950
12045
|
|
|
@@ -11954,7 +12049,7 @@ class Room$1 extends Emitter {
|
|
|
11954
12049
|
}
|
|
11955
12050
|
|
|
11956
12051
|
mute() {
|
|
11957
|
-
logger$
|
|
12052
|
+
logger$a.info('mute room');
|
|
11958
12053
|
|
|
11959
12054
|
Wazo.Phone.mute(this.callSession);
|
|
11960
12055
|
|
|
@@ -11962,7 +12057,7 @@ class Room$1 extends Emitter {
|
|
|
11962
12057
|
}
|
|
11963
12058
|
|
|
11964
12059
|
unmute() {
|
|
11965
|
-
logger$
|
|
12060
|
+
logger$a.info('unmute room');
|
|
11966
12061
|
|
|
11967
12062
|
Wazo.Phone.unmute(this.callSession);
|
|
11968
12063
|
|
|
@@ -11982,7 +12077,7 @@ class Room$1 extends Emitter {
|
|
|
11982
12077
|
}
|
|
11983
12078
|
|
|
11984
12079
|
hold() {
|
|
11985
|
-
logger$
|
|
12080
|
+
logger$a.info('hold room');
|
|
11986
12081
|
|
|
11987
12082
|
Wazo.Phone.hold(this.callSession, true);
|
|
11988
12083
|
|
|
@@ -11992,7 +12087,7 @@ class Room$1 extends Emitter {
|
|
|
11992
12087
|
}
|
|
11993
12088
|
|
|
11994
12089
|
async resume() {
|
|
11995
|
-
logger$
|
|
12090
|
+
logger$a.info('resume room');
|
|
11996
12091
|
|
|
11997
12092
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
11998
12093
|
|
|
@@ -12020,13 +12115,13 @@ class Room$1 extends Emitter {
|
|
|
12020
12115
|
}
|
|
12021
12116
|
|
|
12022
12117
|
sendDTMF(tone ) {
|
|
12023
|
-
logger$
|
|
12118
|
+
logger$a.info('send room DTMF', { tone });
|
|
12024
12119
|
|
|
12025
12120
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
12026
12121
|
}
|
|
12027
12122
|
|
|
12028
12123
|
async sendReinvite(newConstraints = null) {
|
|
12029
|
-
logger$
|
|
12124
|
+
logger$a.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
12030
12125
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
12031
12126
|
|
|
12032
12127
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -12085,7 +12180,7 @@ class Room$1 extends Emitter {
|
|
|
12085
12180
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
12086
12181
|
|
|
12087
12182
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
12088
|
-
logger$
|
|
12183
|
+
logger$a.info('on room audio stream');
|
|
12089
12184
|
|
|
12090
12185
|
this.audioStream = stream;
|
|
12091
12186
|
if (!this.roomAudioElement) {
|
|
@@ -12098,7 +12193,7 @@ class Room$1 extends Emitter {
|
|
|
12098
12193
|
});
|
|
12099
12194
|
|
|
12100
12195
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
12101
|
-
logger$
|
|
12196
|
+
logger$a.info('on room video stream', { streamId });
|
|
12102
12197
|
|
|
12103
12198
|
this._mapMsid(sipSession.body.body);
|
|
12104
12199
|
|
|
@@ -12113,7 +12208,7 @@ class Room$1 extends Emitter {
|
|
|
12113
12208
|
});
|
|
12114
12209
|
|
|
12115
12210
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
12116
|
-
logger$
|
|
12211
|
+
logger$a.info('on room remove stream');
|
|
12117
12212
|
|
|
12118
12213
|
const participant = this.participants.find(someParticipant =>
|
|
12119
12214
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -12245,7 +12340,7 @@ class Room$1 extends Emitter {
|
|
|
12245
12340
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
12246
12341
|
if (requester) {
|
|
12247
12342
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
12248
|
-
logger$
|
|
12343
|
+
logger$a.info('trigger room requester status', { origin });
|
|
12249
12344
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
12250
12345
|
}
|
|
12251
12346
|
break;
|
|
@@ -12276,24 +12371,24 @@ class Room$1 extends Emitter {
|
|
|
12276
12371
|
|
|
12277
12372
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
12278
12373
|
if (participant.user_uuid === session.uuid) {
|
|
12279
|
-
logger$
|
|
12374
|
+
logger$a.info('room current user joined');
|
|
12280
12375
|
|
|
12281
12376
|
// Retrieve participants via an API calls
|
|
12282
12377
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
12283
12378
|
let response;
|
|
12284
12379
|
try {
|
|
12285
12380
|
if (this.meetingUuid) {
|
|
12286
|
-
logger$
|
|
12381
|
+
logger$a.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
12287
12382
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
12288
12383
|
} else {
|
|
12289
|
-
logger$
|
|
12384
|
+
logger$a.info('fetching conference participants', { conferenceId });
|
|
12290
12385
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
12291
12386
|
}
|
|
12292
12387
|
} catch (e) {
|
|
12293
|
-
logger$
|
|
12388
|
+
logger$a.error('room participants fetching, error', e);
|
|
12294
12389
|
}
|
|
12295
12390
|
if (response) {
|
|
12296
|
-
logger$
|
|
12391
|
+
logger$a.info('conference participants fetched', { nb: response.items.length });
|
|
12297
12392
|
participants = response.items.map(item => {
|
|
12298
12393
|
const isMe = item.call_id === this.callId;
|
|
12299
12394
|
|
|
@@ -12320,7 +12415,7 @@ class Room$1 extends Emitter {
|
|
|
12320
12415
|
? new Wazo.RemoteParticipant(this, participant)
|
|
12321
12416
|
: null;
|
|
12322
12417
|
|
|
12323
|
-
logger$
|
|
12418
|
+
logger$a.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
12324
12419
|
|
|
12325
12420
|
if (remoteParticipant) {
|
|
12326
12421
|
this.participants.push(remoteParticipant);
|
|
@@ -12485,12 +12580,12 @@ class Room$1 extends Emitter {
|
|
|
12485
12580
|
|
|
12486
12581
|
//
|
|
12487
12582
|
|
|
12488
|
-
const logger$
|
|
12583
|
+
const logger$b = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
12489
12584
|
|
|
12490
|
-
class SipRoom extends Room
|
|
12585
|
+
class SipRoom extends Room {
|
|
12491
12586
|
|
|
12492
12587
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
12493
|
-
logger$
|
|
12588
|
+
logger$b.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
12494
12589
|
|
|
12495
12590
|
if (!room) {
|
|
12496
12591
|
await Wazo.Phone.connect();
|
|
@@ -12506,7 +12601,7 @@ class SipRoom extends Room$1 {
|
|
|
12506
12601
|
room.setCallId(room.callSession.call.id);
|
|
12507
12602
|
}
|
|
12508
12603
|
|
|
12509
|
-
logger$
|
|
12604
|
+
logger$b.info('connected to room', {
|
|
12510
12605
|
extension: room.extension,
|
|
12511
12606
|
});
|
|
12512
12607
|
|
|
@@ -12514,7 +12609,7 @@ class SipRoom extends Room$1 {
|
|
|
12514
12609
|
}
|
|
12515
12610
|
|
|
12516
12611
|
mute() {
|
|
12517
|
-
logger$
|
|
12612
|
+
logger$b.info('mute sip room');
|
|
12518
12613
|
|
|
12519
12614
|
Wazo.Phone.mute(this.callSession, false);
|
|
12520
12615
|
|
|
@@ -12522,7 +12617,7 @@ class SipRoom extends Room$1 {
|
|
|
12522
12617
|
}
|
|
12523
12618
|
|
|
12524
12619
|
unmute() {
|
|
12525
|
-
logger$
|
|
12620
|
+
logger$b.info('unmute sip room');
|
|
12526
12621
|
|
|
12527
12622
|
Wazo.Phone.unmute(this.callSession, false);
|
|
12528
12623
|
|
|
@@ -12806,7 +12901,7 @@ class NotificationOptions {
|
|
|
12806
12901
|
|
|
12807
12902
|
|
|
12808
12903
|
// Represents a conference room, like `9000`.
|
|
12809
|
-
class Room {
|
|
12904
|
+
class Room$1 {
|
|
12810
12905
|
|
|
12811
12906
|
|
|
12812
12907
|
|
|
@@ -12827,7 +12922,7 @@ class Room {
|
|
|
12827
12922
|
}
|
|
12828
12923
|
|
|
12829
12924
|
connect(callSession ) {
|
|
12830
|
-
return new Room({ ...this, connectedCallSession: callSession });
|
|
12925
|
+
return new Room$1({ ...this, connectedCallSession: callSession });
|
|
12831
12926
|
}
|
|
12832
12927
|
|
|
12833
12928
|
has(callSession ) {
|
|
@@ -12836,7 +12931,7 @@ class Room {
|
|
|
12836
12931
|
|
|
12837
12932
|
addParticipant(uuid , extension , talking = null) {
|
|
12838
12933
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
12839
|
-
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12934
|
+
return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12840
12935
|
}
|
|
12841
12936
|
|
|
12842
12937
|
return this;
|
|
@@ -12855,7 +12950,7 @@ class Room {
|
|
|
12855
12950
|
updatedParticipants.push(participant);
|
|
12856
12951
|
}
|
|
12857
12952
|
|
|
12858
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12953
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12859
12954
|
}
|
|
12860
12955
|
|
|
12861
12956
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -12871,7 +12966,7 @@ class Room {
|
|
|
12871
12966
|
updatedParticipants.push(participant);
|
|
12872
12967
|
}
|
|
12873
12968
|
|
|
12874
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12969
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12875
12970
|
}
|
|
12876
12971
|
|
|
12877
12972
|
hasCallWithId(id ) {
|
|
@@ -12879,18 +12974,18 @@ class Room {
|
|
|
12879
12974
|
}
|
|
12880
12975
|
|
|
12881
12976
|
disconnect() {
|
|
12882
|
-
return new Room({ ...this, connectedCallSession: null });
|
|
12977
|
+
return new Room$1({ ...this, connectedCallSession: null });
|
|
12883
12978
|
}
|
|
12884
12979
|
|
|
12885
12980
|
removeParticipantWithUUID(uuid ) {
|
|
12886
|
-
return new Room({
|
|
12981
|
+
return new Room$1({
|
|
12887
12982
|
...this,
|
|
12888
12983
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
12889
12984
|
});
|
|
12890
12985
|
}
|
|
12891
12986
|
|
|
12892
12987
|
removeParticipantWithExtension(extension ) {
|
|
12893
|
-
return new Room({
|
|
12988
|
+
return new Room$1({
|
|
12894
12989
|
...this,
|
|
12895
12990
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
12896
12991
|
});
|
|
@@ -12901,7 +12996,7 @@ class Room {
|
|
|
12901
12996
|
}
|
|
12902
12997
|
|
|
12903
12998
|
static newFrom(room ) {
|
|
12904
|
-
return newFrom(room, Room);
|
|
12999
|
+
return newFrom(room, Room$1);
|
|
12905
13000
|
}
|
|
12906
13001
|
}
|
|
12907
13002
|
|
|
@@ -13208,11 +13303,11 @@ var wazoWebsocket = {
|
|
|
13208
13303
|
resolve();
|
|
13209
13304
|
};
|
|
13210
13305
|
|
|
13211
|
-
client.on(SOCKET_EVENTS
|
|
13306
|
+
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
13212
13307
|
handleError(`Connection error : ${error}`);
|
|
13213
13308
|
});
|
|
13214
13309
|
|
|
13215
|
-
client.on(SOCKET_EVENTS
|
|
13310
|
+
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
13216
13311
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
13217
13312
|
client.setOnHeartbeatTimeout(() => {
|
|
13218
13313
|
handleError('No response to heartbeat');
|
|
@@ -13313,7 +13408,7 @@ var webrtc = {
|
|
|
13313
13408
|
}),
|
|
13314
13409
|
};
|
|
13315
13410
|
|
|
13316
|
-
const parseCandidate = line => {
|
|
13411
|
+
const parseCandidate$1 = line => {
|
|
13317
13412
|
let parts;
|
|
13318
13413
|
// Parse both variants.
|
|
13319
13414
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -13404,7 +13499,7 @@ var SymmetricNat = {
|
|
|
13404
13499
|
}
|
|
13405
13500
|
|
|
13406
13501
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
13407
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
13502
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
13408
13503
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
13409
13504
|
candidates[cand.relatedPort].push(cand.port);
|
|
13410
13505
|
} else if (!e.candidate) {
|
|
@@ -13472,7 +13567,7 @@ var iceIpv4 = {
|
|
|
13472
13567
|
const rawCandidate = e.candidate.candidate;
|
|
13473
13568
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
13474
13569
|
hasSrflxOrRelay = true;
|
|
13475
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
13570
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
13476
13571
|
ips.push(candidate.ip);
|
|
13477
13572
|
}
|
|
13478
13573
|
} else if (!e.candidate) {
|
|
@@ -13509,7 +13604,7 @@ var checks = [
|
|
|
13509
13604
|
|
|
13510
13605
|
//
|
|
13511
13606
|
|
|
13512
|
-
const logger = IssueReporter$1.loggerFor('engine-check');
|
|
13607
|
+
const logger$c = IssueReporter$1.loggerFor('engine-check');
|
|
13513
13608
|
|
|
13514
13609
|
class Checker {
|
|
13515
13610
|
|
|
@@ -13527,28 +13622,28 @@ class Checker {
|
|
|
13527
13622
|
async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
|
|
13528
13623
|
await this._addEngineVersion();
|
|
13529
13624
|
|
|
13530
|
-
logger.info('Engine check starting');
|
|
13625
|
+
logger$c.info('Engine check starting');
|
|
13531
13626
|
|
|
13532
13627
|
for (let i = 0; i < this.checks.length; i++) {
|
|
13533
13628
|
const { name, check } = this.checks[i];
|
|
13534
13629
|
|
|
13535
|
-
logger.info(`Checking ${name} ...`);
|
|
13630
|
+
logger$c.info(`Checking ${name} ...`);
|
|
13536
13631
|
|
|
13537
13632
|
onCheckBegin(name);
|
|
13538
13633
|
try {
|
|
13539
13634
|
// eslint-disable-next-line no-await-in-loop
|
|
13540
13635
|
const result = await check(this.server, this.session, this.externalAppConfig);
|
|
13541
|
-
logger.info(`Checking ${name} success.`, { result });
|
|
13636
|
+
logger$c.info(`Checking ${name} success.`, { result });
|
|
13542
13637
|
|
|
13543
13638
|
onCheckResult(name, result);
|
|
13544
13639
|
} catch (e) {
|
|
13545
|
-
logger.info(`Checking ${name} failure`, { message: e.message });
|
|
13640
|
+
logger$c.info(`Checking ${name} failure`, { message: e.message });
|
|
13546
13641
|
|
|
13547
13642
|
onCheckResult(name, e);
|
|
13548
13643
|
}
|
|
13549
13644
|
}
|
|
13550
13645
|
|
|
13551
|
-
logger.info('Engine check done.');
|
|
13646
|
+
logger$c.info('Engine check done.');
|
|
13552
13647
|
}
|
|
13553
13648
|
|
|
13554
13649
|
addCheck(check ) {
|
|
@@ -13572,7 +13667,7 @@ const Wazo = {
|
|
|
13572
13667
|
Auth: Auth$1,
|
|
13573
13668
|
Phone: Phone$1,
|
|
13574
13669
|
Websocket: Websocket$1,
|
|
13575
|
-
Room
|
|
13670
|
+
Room,
|
|
13576
13671
|
SipRoom,
|
|
13577
13672
|
RemoteParticipant,
|
|
13578
13673
|
LocalParticipant,
|
|
@@ -13605,7 +13700,7 @@ const Wazo = {
|
|
|
13605
13700
|
Session,
|
|
13606
13701
|
Voicemail,
|
|
13607
13702
|
Relocation,
|
|
13608
|
-
ConferenceRoom: Room,
|
|
13703
|
+
ConferenceRoom: Room$1,
|
|
13609
13704
|
CallSession,
|
|
13610
13705
|
IndirectTransfer,
|
|
13611
13706
|
SwitchboardCall,
|