@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/esm/simple/Auth.js
CHANGED
|
@@ -863,6 +863,9 @@ class Contact {
|
|
|
863
863
|
}
|
|
864
864
|
|
|
865
865
|
static parseMany(response ) {
|
|
866
|
+
if (!response || !response.results) {
|
|
867
|
+
return [];
|
|
868
|
+
}
|
|
866
869
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
867
870
|
}
|
|
868
871
|
|
|
@@ -1634,6 +1637,7 @@ class IssueReporter {
|
|
|
1634
1637
|
|
|
1635
1638
|
|
|
1636
1639
|
|
|
1640
|
+
|
|
1637
1641
|
|
|
1638
1642
|
constructor() {
|
|
1639
1643
|
addLevelsTo(this);
|
|
@@ -1645,12 +1649,17 @@ class IssueReporter {
|
|
|
1645
1649
|
this.bufferTimeout = null;
|
|
1646
1650
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
1647
1651
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
1652
|
+
this._callback = null;
|
|
1648
1653
|
}
|
|
1649
1654
|
|
|
1650
1655
|
init() {
|
|
1651
1656
|
this._catchConsole();
|
|
1652
1657
|
}
|
|
1653
1658
|
|
|
1659
|
+
setCallback(cb ) {
|
|
1660
|
+
this._callback = cb;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1654
1663
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
1655
1664
|
this.remoteClientConfiguration = configuration;
|
|
1656
1665
|
}
|
|
@@ -1686,6 +1695,7 @@ class IssueReporter {
|
|
|
1686
1695
|
|
|
1687
1696
|
// Handle category label
|
|
1688
1697
|
let category = null;
|
|
1698
|
+
let skipSendToRemote = false;
|
|
1689
1699
|
let extra = {};
|
|
1690
1700
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
1691
1701
|
category = args[0].split('=')[1];
|
|
@@ -1701,6 +1711,7 @@ class IssueReporter {
|
|
|
1701
1711
|
errorMessage: lastArg.message,
|
|
1702
1712
|
errorStack: lastArg.stack,
|
|
1703
1713
|
errorType: lastArg.constructor.name,
|
|
1714
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
1704
1715
|
};
|
|
1705
1716
|
} else {
|
|
1706
1717
|
extra = lastArg;
|
|
@@ -1709,6 +1720,11 @@ class IssueReporter {
|
|
|
1709
1720
|
args.splice(1, 1);
|
|
1710
1721
|
}
|
|
1711
1722
|
|
|
1723
|
+
if (extra.skipSendToRemote) {
|
|
1724
|
+
skipSendToRemote = true;
|
|
1725
|
+
delete extra.skipSendToRemote;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1712
1728
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
1713
1729
|
const message = args.join(', ');
|
|
1714
1730
|
let consoleMessage = message;
|
|
@@ -1729,7 +1745,13 @@ class IssueReporter {
|
|
|
1729
1745
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
1730
1746
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
1731
1747
|
|
|
1732
|
-
this.
|
|
1748
|
+
if (this._callback) {
|
|
1749
|
+
this._callback(level, consoleMessage);
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
if (!skipSendToRemote) {
|
|
1753
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
1754
|
+
}
|
|
1733
1755
|
}
|
|
1734
1756
|
|
|
1735
1757
|
logRequest(url , options , response , start ) {
|
|
@@ -1874,7 +1896,11 @@ class IssueReporter {
|
|
|
1874
1896
|
},
|
|
1875
1897
|
// $FlowFixMe
|
|
1876
1898
|
body,
|
|
1877
|
-
}).catch(() => {
|
|
1899
|
+
}).catch((e ) => {
|
|
1900
|
+
// $FlowFixMe
|
|
1901
|
+
e.skipSendToRemote = true;
|
|
1902
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
1903
|
+
|
|
1878
1904
|
setTimeout(() => {
|
|
1879
1905
|
if (isArray) {
|
|
1880
1906
|
payload = payload.map(message => {
|
|
@@ -1921,7 +1947,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
1921
1947
|
|
|
1922
1948
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
1923
1949
|
|
|
1924
|
-
const logger
|
|
1950
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1925
1951
|
|
|
1926
1952
|
// Use a function here to be able to mock it in tests
|
|
1927
1953
|
const realFetch = () => {
|
|
@@ -2060,7 +2086,7 @@ class ApiRequester {
|
|
|
2060
2086
|
};
|
|
2061
2087
|
|
|
2062
2088
|
if (this.refreshTokenPromise) {
|
|
2063
|
-
logger
|
|
2089
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
2064
2090
|
await this.refreshTokenPromise;
|
|
2065
2091
|
}
|
|
2066
2092
|
|
|
@@ -2080,7 +2106,7 @@ class ApiRequester {
|
|
|
2080
2106
|
return promise.then(async (err ) => {
|
|
2081
2107
|
// Check if the token is still valid
|
|
2082
2108
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
2083
|
-
logger
|
|
2109
|
+
logger.warn('token expired', { error: err.reason });
|
|
2084
2110
|
// Replay the call after refreshing the token
|
|
2085
2111
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
2086
2112
|
}
|
|
@@ -2090,7 +2116,7 @@ class ApiRequester {
|
|
|
2090
2116
|
: exceptionClass.fromResponse(err, response.status);
|
|
2091
2117
|
|
|
2092
2118
|
if (this.shouldLogErrors) {
|
|
2093
|
-
logger
|
|
2119
|
+
logger.error('API error', error);
|
|
2094
2120
|
}
|
|
2095
2121
|
|
|
2096
2122
|
throw error;
|
|
@@ -2100,7 +2126,7 @@ class ApiRequester {
|
|
|
2100
2126
|
return newParse(response, isJson);
|
|
2101
2127
|
}).catch(error => {
|
|
2102
2128
|
if (this.shouldLogErrors) {
|
|
2103
|
-
logger
|
|
2129
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
2104
2130
|
}
|
|
2105
2131
|
|
|
2106
2132
|
throw error;
|
|
@@ -2128,13 +2154,13 @@ class ApiRequester {
|
|
|
2128
2154
|
) {
|
|
2129
2155
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
2130
2156
|
let newPath = path;
|
|
2131
|
-
logger
|
|
2157
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
2132
2158
|
|
|
2133
2159
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
2134
2160
|
|
|
2135
2161
|
return this.refreshTokenPromise.then(() => {
|
|
2136
2162
|
this.refreshTokenPromise = null;
|
|
2137
|
-
logger
|
|
2163
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
2138
2164
|
if (isTokenNotFound) {
|
|
2139
2165
|
const pathParts = path.split('/');
|
|
2140
2166
|
pathParts.pop();
|
|
@@ -2604,8 +2630,9 @@ class ExternalApp {
|
|
|
2604
2630
|
|
|
2605
2631
|
|
|
2606
2632
|
|
|
2607
|
-
|
|
2633
|
+
|
|
2608
2634
|
|
|
2635
|
+
|
|
2609
2636
|
|
|
2610
2637
|
|
|
2611
2638
|
class Meeting {
|
|
@@ -2616,9 +2643,10 @@ class Meeting {
|
|
|
2616
2643
|
|
|
2617
2644
|
|
|
2618
2645
|
|
|
2619
|
-
|
|
2646
|
+
|
|
2620
2647
|
|
|
2621
2648
|
|
|
2649
|
+
|
|
2622
2650
|
|
|
2623
2651
|
static parse(plain ) {
|
|
2624
2652
|
return new Meeting({
|
|
@@ -2628,24 +2656,43 @@ class Meeting {
|
|
|
2628
2656
|
ownerUuids: plain.owner_uuids,
|
|
2629
2657
|
port: plain.port,
|
|
2630
2658
|
uuid: plain.uuid,
|
|
2631
|
-
|
|
2659
|
+
extension: plain.exten,
|
|
2632
2660
|
persistent: plain.persistent,
|
|
2661
|
+
creationTime: moment(plain.creation_time).toDate(),
|
|
2633
2662
|
});
|
|
2634
2663
|
}
|
|
2635
2664
|
|
|
2665
|
+
static parseMany(items ) {
|
|
2666
|
+
if (!items) {
|
|
2667
|
+
return [];
|
|
2668
|
+
}
|
|
2669
|
+
return items.map(plain => Meeting.parse(plain));
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2636
2672
|
static newFrom(meeting ) {
|
|
2637
2673
|
return newFrom(meeting, Meeting);
|
|
2638
2674
|
}
|
|
2639
2675
|
|
|
2640
|
-
constructor({
|
|
2676
|
+
constructor({
|
|
2677
|
+
uuid,
|
|
2678
|
+
name,
|
|
2679
|
+
guestSipAuthorization,
|
|
2680
|
+
ownerUuids,
|
|
2681
|
+
port,
|
|
2682
|
+
uri,
|
|
2683
|
+
extension,
|
|
2684
|
+
persistent,
|
|
2685
|
+
creationTime,
|
|
2686
|
+
} = {}) {
|
|
2641
2687
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2642
2688
|
this.uri = uri;
|
|
2643
2689
|
this.name = name;
|
|
2644
2690
|
this.ownerUuids = ownerUuids;
|
|
2645
2691
|
this.port = port;
|
|
2646
2692
|
this.uuid = uuid;
|
|
2647
|
-
this.
|
|
2693
|
+
this.extension = extension;
|
|
2648
2694
|
this.persistent = persistent;
|
|
2695
|
+
this.creationTime = creationTime;
|
|
2649
2696
|
|
|
2650
2697
|
// Useful to compare instead of instanceof with minified code
|
|
2651
2698
|
this.type = 'Meeting';
|
|
@@ -2723,8 +2770,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2723
2770
|
}
|
|
2724
2771
|
},
|
|
2725
2772
|
|
|
2726
|
-
|
|
2727
|
-
client.
|
|
2773
|
+
getMyMeetings: () =>
|
|
2774
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2775
|
+
|
|
2776
|
+
createMyMeeting: (name , persistent ) =>
|
|
2777
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
2728
2778
|
|
|
2729
2779
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2730
2780
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2820,6 +2870,10 @@ class ChatMessage {
|
|
|
2820
2870
|
|
|
2821
2871
|
|
|
2822
2872
|
static parseMany(plain ) {
|
|
2873
|
+
if (!plain || !plain.items) {
|
|
2874
|
+
return [];
|
|
2875
|
+
}
|
|
2876
|
+
|
|
2823
2877
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2824
2878
|
}
|
|
2825
2879
|
|
|
@@ -2929,6 +2983,9 @@ class Voicemail {
|
|
|
2929
2983
|
}
|
|
2930
2984
|
|
|
2931
2985
|
static parseMany(plain ) {
|
|
2986
|
+
if (!plain) {
|
|
2987
|
+
return [];
|
|
2988
|
+
}
|
|
2932
2989
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2933
2990
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2934
2991
|
|
|
@@ -3038,6 +3095,9 @@ class Call {
|
|
|
3038
3095
|
|
|
3039
3096
|
|
|
3040
3097
|
static parseMany(plain ) {
|
|
3098
|
+
if (!plain) {
|
|
3099
|
+
return [];
|
|
3100
|
+
}
|
|
3041
3101
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3042
3102
|
}
|
|
3043
3103
|
|
|
@@ -3581,6 +3641,9 @@ class Recording {
|
|
|
3581
3641
|
|
|
3582
3642
|
|
|
3583
3643
|
static parseMany(recordings = []) {
|
|
3644
|
+
if (!recordings) {
|
|
3645
|
+
return [];
|
|
3646
|
+
}
|
|
3584
3647
|
return recordings.map(item => Recording.parse(item));
|
|
3585
3648
|
}
|
|
3586
3649
|
|
|
@@ -3682,6 +3745,10 @@ class CallLog {
|
|
|
3682
3745
|
}
|
|
3683
3746
|
|
|
3684
3747
|
static parseMany(plain ) {
|
|
3748
|
+
if (!plain || !plain.items) {
|
|
3749
|
+
return [];
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3685
3752
|
return plain.items.map(item => CallLog.parse(item));
|
|
3686
3753
|
}
|
|
3687
3754
|
|
|
@@ -3986,7 +4053,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
3986
4053
|
|
|
3987
4054
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
3988
4055
|
|
|
3989
|
-
const logger$
|
|
4056
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
3990
4057
|
|
|
3991
4058
|
class CTIPhone extends Emitter {
|
|
3992
4059
|
|
|
@@ -3999,7 +4066,7 @@ class CTIPhone extends Emitter {
|
|
|
3999
4066
|
|
|
4000
4067
|
constructor(session , isMobile = false, callbackAllLines = false) {
|
|
4001
4068
|
super();
|
|
4002
|
-
logger$
|
|
4069
|
+
logger$1.info('CTI Phone created');
|
|
4003
4070
|
this.session = session;
|
|
4004
4071
|
this.isMobile = isMobile;
|
|
4005
4072
|
this.callbackAllLines = callbackAllLines;
|
|
@@ -4060,7 +4127,7 @@ class CTIPhone extends Emitter {
|
|
|
4060
4127
|
}
|
|
4061
4128
|
|
|
4062
4129
|
async makeCall(number , line ) {
|
|
4063
|
-
logger$
|
|
4130
|
+
logger$1.info('make CTI call', { number });
|
|
4064
4131
|
|
|
4065
4132
|
if (!number) {
|
|
4066
4133
|
return null;
|
|
@@ -4083,7 +4150,7 @@ class CTIPhone extends Emitter {
|
|
|
4083
4150
|
if (!callSession) {
|
|
4084
4151
|
return Promise.resolve(null);
|
|
4085
4152
|
}
|
|
4086
|
-
logger$
|
|
4153
|
+
logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4087
4154
|
|
|
4088
4155
|
if (!this.currentCall) {
|
|
4089
4156
|
this.currentCall = callSession.call;
|
|
@@ -4096,7 +4163,7 @@ class CTIPhone extends Emitter {
|
|
|
4096
4163
|
if (!callSession) {
|
|
4097
4164
|
return;
|
|
4098
4165
|
}
|
|
4099
|
-
logger$
|
|
4166
|
+
logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4100
4167
|
|
|
4101
4168
|
this.currentCall = undefined;
|
|
4102
4169
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4106,7 +4173,7 @@ class CTIPhone extends Emitter {
|
|
|
4106
4173
|
if (!callSession) {
|
|
4107
4174
|
return Promise.resolve(false);
|
|
4108
4175
|
}
|
|
4109
|
-
logger$
|
|
4176
|
+
logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4110
4177
|
|
|
4111
4178
|
try {
|
|
4112
4179
|
await CallApi.cancelCall(callSession);
|
|
@@ -4117,7 +4184,7 @@ class CTIPhone extends Emitter {
|
|
|
4117
4184
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
4118
4185
|
return true;
|
|
4119
4186
|
} catch (e) {
|
|
4120
|
-
logger$
|
|
4187
|
+
logger$1.error('hangup CTI call, error', e);
|
|
4121
4188
|
|
|
4122
4189
|
this.eventEmitter.emit('onCallFailed', callSession);
|
|
4123
4190
|
return false;
|
|
@@ -4130,7 +4197,7 @@ class CTIPhone extends Emitter {
|
|
|
4130
4197
|
if (!callSession) {
|
|
4131
4198
|
return;
|
|
4132
4199
|
}
|
|
4133
|
-
logger$
|
|
4200
|
+
logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
|
|
4134
4201
|
|
|
4135
4202
|
await CallApi.cancelCall(callSession);
|
|
4136
4203
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
@@ -4140,7 +4207,7 @@ class CTIPhone extends Emitter {
|
|
|
4140
4207
|
if (!callSession) {
|
|
4141
4208
|
return;
|
|
4142
4209
|
}
|
|
4143
|
-
logger$
|
|
4210
|
+
logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4144
4211
|
|
|
4145
4212
|
await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
|
|
4146
4213
|
}
|
|
@@ -4153,19 +4220,19 @@ class CTIPhone extends Emitter {
|
|
|
4153
4220
|
if (!callSession) {
|
|
4154
4221
|
return;
|
|
4155
4222
|
}
|
|
4156
|
-
logger$
|
|
4223
|
+
logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
|
|
4157
4224
|
|
|
4158
4225
|
return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
|
|
4159
4226
|
}
|
|
4160
4227
|
|
|
4161
4228
|
async cancelCTIIndirectTransfer(transferId ) {
|
|
4162
|
-
logger$
|
|
4229
|
+
logger$1.info('cancel CTI transfer', { transferId });
|
|
4163
4230
|
|
|
4164
4231
|
return CallApi.cancelCallTransfer(transferId);
|
|
4165
4232
|
}
|
|
4166
4233
|
|
|
4167
4234
|
async confirmCTIIndirectTransfer(transferId ) {
|
|
4168
|
-
logger$
|
|
4235
|
+
logger$1.info('confirm CTI transfer', { transferId });
|
|
4169
4236
|
|
|
4170
4237
|
return CallApi.confirmCallTransfer(transferId);
|
|
4171
4238
|
}
|
|
@@ -4174,19 +4241,19 @@ class CTIPhone extends Emitter {
|
|
|
4174
4241
|
if (!callSession) {
|
|
4175
4242
|
return;
|
|
4176
4243
|
}
|
|
4177
|
-
logger$
|
|
4244
|
+
logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
|
|
4178
4245
|
|
|
4179
4246
|
return CallApi.sendDTMF(callSession.callId, digits);
|
|
4180
4247
|
}
|
|
4181
4248
|
|
|
4182
4249
|
onConnectionMade() {
|
|
4183
|
-
logger$
|
|
4250
|
+
logger$1.info('on CTI connection made');
|
|
4184
4251
|
|
|
4185
4252
|
this.eventEmitter.emit('onCallAccepted');
|
|
4186
4253
|
}
|
|
4187
4254
|
|
|
4188
4255
|
async close() {
|
|
4189
|
-
logger$
|
|
4256
|
+
logger$1.info('CTI close');
|
|
4190
4257
|
|
|
4191
4258
|
return Promise.resolve();
|
|
4192
4259
|
}
|
|
@@ -4195,7 +4262,7 @@ class CTIPhone extends Emitter {
|
|
|
4195
4262
|
if (!callSession) {
|
|
4196
4263
|
return;
|
|
4197
4264
|
}
|
|
4198
|
-
logger$
|
|
4265
|
+
logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
|
|
4199
4266
|
|
|
4200
4267
|
return CallApi.hold(callSession.callId);
|
|
4201
4268
|
}
|
|
@@ -4204,7 +4271,7 @@ class CTIPhone extends Emitter {
|
|
|
4204
4271
|
if (!callSession) {
|
|
4205
4272
|
return;
|
|
4206
4273
|
}
|
|
4207
|
-
logger$
|
|
4274
|
+
logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
|
|
4208
4275
|
|
|
4209
4276
|
return CallApi.resume(callSession.callId);
|
|
4210
4277
|
}
|
|
@@ -4213,7 +4280,7 @@ class CTIPhone extends Emitter {
|
|
|
4213
4280
|
if (!callSession) {
|
|
4214
4281
|
return;
|
|
4215
4282
|
}
|
|
4216
|
-
logger$
|
|
4283
|
+
logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
|
|
4217
4284
|
|
|
4218
4285
|
return CallApi.mute(callSession.callId);
|
|
4219
4286
|
}
|
|
@@ -4222,7 +4289,7 @@ class CTIPhone extends Emitter {
|
|
|
4222
4289
|
if (!callSession) {
|
|
4223
4290
|
return;
|
|
4224
4291
|
}
|
|
4225
|
-
logger$
|
|
4292
|
+
logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
|
|
4226
4293
|
|
|
4227
4294
|
return CallApi.unmute(callSession.callId);
|
|
4228
4295
|
}
|
|
@@ -4251,6 +4318,10 @@ class CTIPhone extends Emitter {
|
|
|
4251
4318
|
return false;
|
|
4252
4319
|
}
|
|
4253
4320
|
|
|
4321
|
+
hasAVideoTrack() {
|
|
4322
|
+
return false;
|
|
4323
|
+
}
|
|
4324
|
+
|
|
4254
4325
|
getLocalStreamForCall() {
|
|
4255
4326
|
return null;
|
|
4256
4327
|
}
|
|
@@ -4644,6 +4715,9 @@ class ChatRoom {
|
|
|
4644
4715
|
|
|
4645
4716
|
|
|
4646
4717
|
static parseMany(plain ) {
|
|
4718
|
+
if (!plain || !plain.items) {
|
|
4719
|
+
return [];
|
|
4720
|
+
}
|
|
4647
4721
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4648
4722
|
}
|
|
4649
4723
|
|
|
@@ -5224,7 +5298,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5224
5298
|
const WEBHOOKD_VERSION = '1.0';
|
|
5225
5299
|
const AMID_VERSION = '1.0';
|
|
5226
5300
|
|
|
5227
|
-
const logger$
|
|
5301
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5228
5302
|
|
|
5229
5303
|
class ApiClient {
|
|
5230
5304
|
|
|
@@ -5276,12 +5350,12 @@ class ApiClient {
|
|
|
5276
5350
|
}
|
|
5277
5351
|
|
|
5278
5352
|
async forceRefreshToken() {
|
|
5279
|
-
logger$
|
|
5353
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5280
5354
|
return this.refreshTokenCallback();
|
|
5281
5355
|
}
|
|
5282
5356
|
|
|
5283
5357
|
async refreshTokenCallback() {
|
|
5284
|
-
logger$
|
|
5358
|
+
logger$2.info('refresh token callback called', {
|
|
5285
5359
|
refreshToken: this.refreshToken,
|
|
5286
5360
|
refreshBackend: this.refreshBackend,
|
|
5287
5361
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5299,7 +5373,7 @@ class ApiClient {
|
|
|
5299
5373
|
this.isMobile,
|
|
5300
5374
|
);
|
|
5301
5375
|
|
|
5302
|
-
logger$
|
|
5376
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5303
5377
|
|
|
5304
5378
|
if (this.onRefreshToken) {
|
|
5305
5379
|
this.onRefreshToken(session.token, session);
|
|
@@ -5612,7 +5686,7 @@ class AdHocAPIConference {
|
|
|
5612
5686
|
|
|
5613
5687
|
/* */
|
|
5614
5688
|
|
|
5615
|
-
const parseCandidate
|
|
5689
|
+
const parseCandidate = (candidate ) => {
|
|
5616
5690
|
if (!candidate) {
|
|
5617
5691
|
return null;
|
|
5618
5692
|
}
|
|
@@ -5625,10 +5699,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5625
5699
|
candidates
|
|
5626
5700
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5627
5701
|
|
|
5628
|
-
const areCandidateValid = (candidates ) =>
|
|
5629
|
-
getSrflxOrRelay(candidates)
|
|
5630
|
-
.length > 0;
|
|
5631
|
-
|
|
5632
5702
|
const getVideoDirection = (sdp ) => {
|
|
5633
5703
|
const parsedSdp = sdpParser.parse(sdp);
|
|
5634
5704
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5681,8 +5751,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5681
5751
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5682
5752
|
|
|
5683
5753
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5684
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5685
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5686
5754
|
|
|
5687
5755
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5688
5756
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -5772,7 +5840,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5772
5840
|
this.peerConnectionDelegate.onicecandidate = event => {
|
|
5773
5841
|
wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
|
|
5774
5842
|
if (event.candidate) {
|
|
5775
|
-
this.gatheredCandidates.push(parseCandidate
|
|
5843
|
+
this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
|
|
5776
5844
|
}
|
|
5777
5845
|
};
|
|
5778
5846
|
|
|
@@ -5872,38 +5940,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
5872
5940
|
this._peerConnection = undefined;
|
|
5873
5941
|
}
|
|
5874
5942
|
|
|
5875
|
-
async _waitForValidGatheredIce() {
|
|
5876
|
-
let tries = 0;
|
|
5877
|
-
|
|
5878
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
5879
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
5880
|
-
tries,
|
|
5881
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
5882
|
-
});
|
|
5883
|
-
|
|
5884
|
-
tries++;
|
|
5885
|
-
|
|
5886
|
-
// eslint-disable-next-line no-await-in-loop
|
|
5887
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
5888
|
-
}
|
|
5889
|
-
|
|
5890
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
5891
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
5892
|
-
const error = new Error(errorMsg);
|
|
5893
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
5894
|
-
|
|
5895
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
5896
|
-
this.eventEmitter.emit('error', error);
|
|
5897
|
-
|
|
5898
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5899
|
-
}
|
|
5900
|
-
|
|
5901
|
-
// eslint-disable-next-line
|
|
5902
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5903
|
-
|
|
5904
|
-
return this.getLocalSessionDescription();
|
|
5905
|
-
}
|
|
5906
|
-
|
|
5907
5943
|
// Overridden to send `inactive` in conference
|
|
5908
5944
|
updateDirection(options , isConference = false,
|
|
5909
5945
|
audioOnly = false) {
|
|
@@ -6268,7 +6304,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
6268
6304
|
const SEND_STATS_DELAY = 5000;
|
|
6269
6305
|
|
|
6270
6306
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
6271
|
-
const logger$
|
|
6307
|
+
const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
6272
6308
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
6273
6309
|
|
|
6274
6310
|
// events
|
|
@@ -6282,14 +6318,14 @@ const TRANSPORT_ERROR = 'transportError';
|
|
|
6282
6318
|
const MESSAGE = 'message';
|
|
6283
6319
|
const ACCEPTED = 'accepted';
|
|
6284
6320
|
const REJECTED = 'rejected';
|
|
6285
|
-
const ON_TRACK
|
|
6286
|
-
const ON_REINVITE
|
|
6321
|
+
const ON_TRACK = 'onTrack';
|
|
6322
|
+
const ON_REINVITE = 'reinvite';
|
|
6287
6323
|
const ON_ERROR = 'onError';
|
|
6288
6324
|
const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
6289
|
-
const ON_NETWORK_STATS
|
|
6290
|
-
const ON_DISCONNECTED
|
|
6325
|
+
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
6326
|
+
const ON_DISCONNECTED = 'onDisconnected';
|
|
6291
6327
|
|
|
6292
|
-
const events
|
|
6328
|
+
const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
6293
6329
|
const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
6294
6330
|
class CanceledCallError extends Error {}
|
|
6295
6331
|
|
|
@@ -6425,12 +6461,12 @@ class WebRTCClient extends Emitter {
|
|
|
6425
6461
|
this.MESSAGE = MESSAGE;
|
|
6426
6462
|
this.ACCEPTED = ACCEPTED;
|
|
6427
6463
|
this.REJECTED = REJECTED;
|
|
6428
|
-
this.ON_TRACK = ON_TRACK
|
|
6429
|
-
this.ON_REINVITE = ON_REINVITE
|
|
6464
|
+
this.ON_TRACK = ON_TRACK;
|
|
6465
|
+
this.ON_REINVITE = ON_REINVITE;
|
|
6430
6466
|
this.ON_ERROR = ON_ERROR;
|
|
6431
6467
|
this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
|
|
6432
|
-
this.ON_NETWORK_STATS = ON_NETWORK_STATS
|
|
6433
|
-
this.ON_DISCONNECTED = ON_DISCONNECTED
|
|
6468
|
+
this.ON_NETWORK_STATS = ON_NETWORK_STATS;
|
|
6469
|
+
this.ON_DISCONNECTED = ON_DISCONNECTED;
|
|
6434
6470
|
}
|
|
6435
6471
|
|
|
6436
6472
|
configureMedia(media ) {
|
|
@@ -6447,13 +6483,13 @@ class WebRTCClient extends Emitter {
|
|
|
6447
6483
|
|
|
6448
6484
|
createUserAgent(configOverrides ) {
|
|
6449
6485
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
6450
|
-
logger$
|
|
6486
|
+
logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
6451
6487
|
|
|
6452
6488
|
webRTCConfiguration.delegate = {
|
|
6453
6489
|
onConnect: this.onConnect.bind(this),
|
|
6454
6490
|
onDisconnect: this.onDisconnect.bind(this),
|
|
6455
6491
|
onInvite: (invitation ) => {
|
|
6456
|
-
logger$
|
|
6492
|
+
logger$3.info('sdk webrtc on invite', {
|
|
6457
6493
|
method: 'delegate.onInvite',
|
|
6458
6494
|
id: invitation.id,
|
|
6459
6495
|
remoteURI: invitation.remoteURI,
|
|
@@ -6496,7 +6532,7 @@ class WebRTCClient extends Emitter {
|
|
|
6496
6532
|
}
|
|
6497
6533
|
|
|
6498
6534
|
onConnect() {
|
|
6499
|
-
logger$
|
|
6535
|
+
logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
6500
6536
|
this.eventEmitter.emit(CONNECTED);
|
|
6501
6537
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
6502
6538
|
this.registerer.waitingToggle(false);
|
|
@@ -6505,7 +6541,7 @@ class WebRTCClient extends Emitter {
|
|
|
6505
6541
|
}
|
|
6506
6542
|
|
|
6507
6543
|
async onDisconnect(error ) {
|
|
6508
|
-
logger$
|
|
6544
|
+
logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
6509
6545
|
this.connectionPromise = null;
|
|
6510
6546
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
6511
6547
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -6530,37 +6566,37 @@ class WebRTCClient extends Emitter {
|
|
|
6530
6566
|
};
|
|
6531
6567
|
|
|
6532
6568
|
if (this.skipRegister) {
|
|
6533
|
-
logger$
|
|
6569
|
+
logger$3.info('sdk webrtc skip register...', logInfo);
|
|
6534
6570
|
return Promise.resolve();
|
|
6535
6571
|
}
|
|
6536
6572
|
|
|
6537
|
-
logger$
|
|
6573
|
+
logger$3.info('sdk webrtc registering...', logInfo);
|
|
6538
6574
|
|
|
6539
6575
|
if (!this.userAgent) {
|
|
6540
|
-
logger$
|
|
6576
|
+
logger$3.info('sdk webrtc recreating User Agent');
|
|
6541
6577
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6542
6578
|
}
|
|
6543
6579
|
if (!this.userAgent || this.isRegistered()) {
|
|
6544
|
-
logger$
|
|
6580
|
+
logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
6545
6581
|
return Promise.resolve();
|
|
6546
6582
|
}
|
|
6547
6583
|
|
|
6548
6584
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
6549
|
-
logger$
|
|
6585
|
+
logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
6550
6586
|
return Promise.resolve();
|
|
6551
6587
|
}
|
|
6552
6588
|
|
|
6553
6589
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
6554
6590
|
|
|
6555
6591
|
const onRegisterFailed = () => {
|
|
6556
|
-
logger$
|
|
6592
|
+
logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
6557
6593
|
this.connectionPromise = null;
|
|
6558
6594
|
if (this.registerer && this.registerer.waiting) {
|
|
6559
6595
|
this.registerer.waitingToggle(false);
|
|
6560
6596
|
}
|
|
6561
6597
|
|
|
6562
6598
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
6563
|
-
logger$
|
|
6599
|
+
logger$3.info('sdk webrtc registering, retrying...', { tries });
|
|
6564
6600
|
setTimeout(() => this.register(tries + 1), 300);
|
|
6565
6601
|
}
|
|
6566
6602
|
};
|
|
@@ -6569,18 +6605,18 @@ class WebRTCClient extends Emitter {
|
|
|
6569
6605
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
6570
6606
|
// during the resolution of the primise.
|
|
6571
6607
|
if (!this.userAgent) {
|
|
6572
|
-
logger$
|
|
6608
|
+
logger$3.info('sdk webrtc recreating User Agent after connection');
|
|
6573
6609
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6574
6610
|
}
|
|
6575
6611
|
|
|
6576
|
-
logger$
|
|
6612
|
+
logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
6577
6613
|
this.registerer = new Registerer(this.userAgent, registerOptions);
|
|
6578
6614
|
this.connectionPromise = null;
|
|
6579
6615
|
this._monkeyPatchRegisterer(this.registerer);
|
|
6580
6616
|
|
|
6581
6617
|
// Bind registerer events
|
|
6582
6618
|
this.registerer.stateChange.addListener(newState => {
|
|
6583
|
-
logger$
|
|
6619
|
+
logger$3.info('sdk webrtc registering, state changed', { newState });
|
|
6584
6620
|
|
|
6585
6621
|
if (newState === RegistererState.Registered && this.registerer
|
|
6586
6622
|
&& this.registerer.state === RegistererState.Registered) {
|
|
@@ -6593,7 +6629,7 @@ class WebRTCClient extends Emitter {
|
|
|
6593
6629
|
const options = {
|
|
6594
6630
|
requestDelegate: {
|
|
6595
6631
|
onReject: response => {
|
|
6596
|
-
logger$
|
|
6632
|
+
logger$3.error('sdk webrtc registering, rejected', { response });
|
|
6597
6633
|
|
|
6598
6634
|
onRegisterFailed();
|
|
6599
6635
|
},
|
|
@@ -6601,13 +6637,13 @@ class WebRTCClient extends Emitter {
|
|
|
6601
6637
|
};
|
|
6602
6638
|
|
|
6603
6639
|
return this.registerer.register(options).catch((e) => {
|
|
6604
|
-
logger$
|
|
6640
|
+
logger$3.error('sdk webrtc registering, error', e);
|
|
6605
6641
|
|
|
6606
6642
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
6607
6643
|
return e;
|
|
6608
6644
|
});
|
|
6609
6645
|
}).catch(error => {
|
|
6610
|
-
logger$
|
|
6646
|
+
logger$3.error('sdk webrtc registering, transport error', error);
|
|
6611
6647
|
onRegisterFailed();
|
|
6612
6648
|
});
|
|
6613
6649
|
}
|
|
@@ -6636,21 +6672,21 @@ class WebRTCClient extends Emitter {
|
|
|
6636
6672
|
}
|
|
6637
6673
|
|
|
6638
6674
|
unregister() {
|
|
6639
|
-
logger$
|
|
6675
|
+
logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
6640
6676
|
if (!this.registerer) {
|
|
6641
6677
|
return Promise.resolve();
|
|
6642
6678
|
}
|
|
6643
6679
|
|
|
6644
6680
|
try {
|
|
6645
6681
|
return this.registerer.unregister().then(() => {
|
|
6646
|
-
logger$
|
|
6682
|
+
logger$3.info('sdk webrtc unregistered');
|
|
6647
6683
|
this._cleanupRegister();
|
|
6648
6684
|
}).catch(e => {
|
|
6649
|
-
logger$
|
|
6685
|
+
logger$3.error('sdk webrtc unregistering, promise error', e);
|
|
6650
6686
|
this._cleanupRegister();
|
|
6651
6687
|
});
|
|
6652
6688
|
} catch (e) {
|
|
6653
|
-
logger$
|
|
6689
|
+
logger$3.error('sdk webrtc unregistering, error', e);
|
|
6654
6690
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
6655
6691
|
// error when the registerer is in a bad state
|
|
6656
6692
|
this._cleanupRegister();
|
|
@@ -6658,7 +6694,7 @@ class WebRTCClient extends Emitter {
|
|
|
6658
6694
|
}
|
|
6659
6695
|
|
|
6660
6696
|
stop() {
|
|
6661
|
-
logger$
|
|
6697
|
+
logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
6662
6698
|
if (!this.userAgent) {
|
|
6663
6699
|
return Promise.resolve();
|
|
6664
6700
|
}
|
|
@@ -6666,12 +6702,12 @@ class WebRTCClient extends Emitter {
|
|
|
6666
6702
|
return this.userAgent.stop().then(() => {
|
|
6667
6703
|
return this._cleanupRegister();
|
|
6668
6704
|
}).catch(e => {
|
|
6669
|
-
logger$
|
|
6705
|
+
logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
6670
6706
|
});
|
|
6671
6707
|
}
|
|
6672
6708
|
|
|
6673
6709
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6674
|
-
logger$
|
|
6710
|
+
logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6675
6711
|
const inviterOptions = {
|
|
6676
6712
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6677
6713
|
conference,
|
|
@@ -6696,11 +6732,13 @@ class WebRTCClient extends Emitter {
|
|
|
6696
6732
|
const inviteOptions = {
|
|
6697
6733
|
requestDelegate: {
|
|
6698
6734
|
onAccept: (response ) => {
|
|
6699
|
-
session.sessionDescriptionHandler.peerConnection
|
|
6735
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
6736
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
6737
|
+
}
|
|
6700
6738
|
this._onAccepted(session, response.session, true);
|
|
6701
6739
|
},
|
|
6702
6740
|
onReject: (response ) => {
|
|
6703
|
-
logger$
|
|
6741
|
+
logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
6704
6742
|
this._stopSendingStats(session);
|
|
6705
6743
|
this.stopNetworkMonitoring(session);
|
|
6706
6744
|
|
|
@@ -6723,11 +6761,11 @@ class WebRTCClient extends Emitter {
|
|
|
6723
6761
|
}
|
|
6724
6762
|
|
|
6725
6763
|
answer(session , enableVideo ) {
|
|
6726
|
-
logger$
|
|
6764
|
+
logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
6727
6765
|
|
|
6728
6766
|
if (!session || !session.accept) {
|
|
6729
6767
|
const error = 'No session to answer, or not an invitation';
|
|
6730
|
-
logger$
|
|
6768
|
+
logger$3.warn(error);
|
|
6731
6769
|
return Promise.reject(new Error(error));
|
|
6732
6770
|
}
|
|
6733
6771
|
const options = {
|
|
@@ -6737,15 +6775,15 @@ class WebRTCClient extends Emitter {
|
|
|
6737
6775
|
return session.accept(options).then(() => {
|
|
6738
6776
|
if (session.isCanceled) {
|
|
6739
6777
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
6740
|
-
logger$
|
|
6778
|
+
logger$3.error(message, { id: session.id });
|
|
6741
6779
|
this.onCallEnded(session);
|
|
6742
6780
|
|
|
6743
6781
|
throw new CanceledCallError(message);
|
|
6744
6782
|
}
|
|
6745
|
-
logger$
|
|
6783
|
+
logger$3.info('sdk webrtc answer, accepted.');
|
|
6746
6784
|
this._onAccepted(session);
|
|
6747
6785
|
}).catch(e => {
|
|
6748
|
-
logger$
|
|
6786
|
+
logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
6749
6787
|
|
|
6750
6788
|
throw e;
|
|
6751
6789
|
});
|
|
@@ -6753,7 +6791,7 @@ class WebRTCClient extends Emitter {
|
|
|
6753
6791
|
|
|
6754
6792
|
hangup(session ) {
|
|
6755
6793
|
const { state, id } = session;
|
|
6756
|
-
logger$
|
|
6794
|
+
logger$3.info('sdk webrtc hangup call', { id, state });
|
|
6757
6795
|
|
|
6758
6796
|
try {
|
|
6759
6797
|
this._stopSendingStats(session);
|
|
@@ -6782,7 +6820,7 @@ class WebRTCClient extends Emitter {
|
|
|
6782
6820
|
|
|
6783
6821
|
return bye();
|
|
6784
6822
|
} catch (error) {
|
|
6785
|
-
logger$
|
|
6823
|
+
logger$3.warn('sdk webrtc hangup, error', error);
|
|
6786
6824
|
}
|
|
6787
6825
|
|
|
6788
6826
|
return null;
|
|
@@ -6800,7 +6838,7 @@ class WebRTCClient extends Emitter {
|
|
|
6800
6838
|
// Fetch and emit an event at `interval` with session network stats
|
|
6801
6839
|
startNetworkMonitoring(session , interval = 1000) {
|
|
6802
6840
|
const sessionId = this.getSipSessionId(session);
|
|
6803
|
-
logger$
|
|
6841
|
+
logger$3.info('starting network inspection', { id: sessionId });
|
|
6804
6842
|
|
|
6805
6843
|
this.sessionNetworkStats[sessionId] = [];
|
|
6806
6844
|
|
|
@@ -6810,7 +6848,7 @@ class WebRTCClient extends Emitter {
|
|
|
6810
6848
|
stopNetworkMonitoring(session ) {
|
|
6811
6849
|
const sessionId = this.getSipSessionId(session);
|
|
6812
6850
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
6813
|
-
logger$
|
|
6851
|
+
logger$3.info('stopping network inspection', { id: sessionId, exists });
|
|
6814
6852
|
|
|
6815
6853
|
if (exists) {
|
|
6816
6854
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -6820,17 +6858,17 @@ class WebRTCClient extends Emitter {
|
|
|
6820
6858
|
}
|
|
6821
6859
|
|
|
6822
6860
|
reject(session ) {
|
|
6823
|
-
logger$
|
|
6861
|
+
logger$3.info('sdk webrtc reject call', { id: session.id });
|
|
6824
6862
|
|
|
6825
6863
|
try {
|
|
6826
6864
|
return session.reject ? session.reject() : session.cancel();
|
|
6827
6865
|
} catch (e) {
|
|
6828
|
-
logger$
|
|
6866
|
+
logger$3.warn('Error when rejecting call', e.message, e.stack);
|
|
6829
6867
|
}
|
|
6830
6868
|
}
|
|
6831
6869
|
|
|
6832
6870
|
async close() {
|
|
6833
|
-
logger$
|
|
6871
|
+
logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
6834
6872
|
this._cleanupMedia();
|
|
6835
6873
|
this.connectionPromise = null;
|
|
6836
6874
|
|
|
@@ -6861,7 +6899,7 @@ class WebRTCClient extends Emitter {
|
|
|
6861
6899
|
// eg: "INVITE not rejectable in state Completed"
|
|
6862
6900
|
}
|
|
6863
6901
|
this.userAgent = null;
|
|
6864
|
-
logger$
|
|
6902
|
+
logger$3.info('sdk webrtc client closed');
|
|
6865
6903
|
}
|
|
6866
6904
|
|
|
6867
6905
|
getNumber(session ) {
|
|
@@ -6874,13 +6912,13 @@ class WebRTCClient extends Emitter {
|
|
|
6874
6912
|
}
|
|
6875
6913
|
|
|
6876
6914
|
mute(session ) {
|
|
6877
|
-
logger$
|
|
6915
|
+
logger$3.info('sdk webrtc mute', { id: session.id });
|
|
6878
6916
|
|
|
6879
6917
|
this._toggleAudio(session, true);
|
|
6880
6918
|
}
|
|
6881
6919
|
|
|
6882
6920
|
unmute(session ) {
|
|
6883
|
-
logger$
|
|
6921
|
+
logger$3.info('sdk webrtc unmute', { id: session.id });
|
|
6884
6922
|
|
|
6885
6923
|
this._toggleAudio(session, false);
|
|
6886
6924
|
}
|
|
@@ -6920,13 +6958,13 @@ class WebRTCClient extends Emitter {
|
|
|
6920
6958
|
}
|
|
6921
6959
|
|
|
6922
6960
|
toggleCameraOn(session ) {
|
|
6923
|
-
logger$
|
|
6961
|
+
logger$3.info('sdk webrtc toggle camera on', { id: session.id });
|
|
6924
6962
|
|
|
6925
6963
|
this._toggleVideo(session, false);
|
|
6926
6964
|
}
|
|
6927
6965
|
|
|
6928
6966
|
toggleCameraOff(session ) {
|
|
6929
|
-
logger$
|
|
6967
|
+
logger$3.info('sdk webrtc toggle camera off', { id: session.id });
|
|
6930
6968
|
|
|
6931
6969
|
this._toggleVideo(session, true);
|
|
6932
6970
|
}
|
|
@@ -6935,7 +6973,7 @@ class WebRTCClient extends Emitter {
|
|
|
6935
6973
|
const sessionId = this.getSipSessionId(session);
|
|
6936
6974
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
6937
6975
|
|
|
6938
|
-
logger$
|
|
6976
|
+
logger$3.info('sdk webrtc hold', {
|
|
6939
6977
|
sessionId,
|
|
6940
6978
|
keys: Object.keys(this.heldSessions),
|
|
6941
6979
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6984,7 +7022,7 @@ class WebRTCClient extends Emitter {
|
|
|
6984
7022
|
const sessionId = this.getSipSessionId(session);
|
|
6985
7023
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
6986
7024
|
|
|
6987
|
-
logger$
|
|
7025
|
+
logger$3.info('sdk webrtc unhold', {
|
|
6988
7026
|
sessionId,
|
|
6989
7027
|
keys: Object.keys(this.heldSessions),
|
|
6990
7028
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -7132,7 +7170,7 @@ class WebRTCClient extends Emitter {
|
|
|
7132
7170
|
if (!session.sessionDescriptionHandler) {
|
|
7133
7171
|
return;
|
|
7134
7172
|
}
|
|
7135
|
-
logger$
|
|
7173
|
+
logger$3.info('Sending DTMF', {
|
|
7136
7174
|
id: this.getSipSessionId(session),
|
|
7137
7175
|
tone,
|
|
7138
7176
|
});
|
|
@@ -7148,7 +7186,7 @@ class WebRTCClient extends Emitter {
|
|
|
7148
7186
|
transfer(session , target ) {
|
|
7149
7187
|
this.hold(session);
|
|
7150
7188
|
|
|
7151
|
-
logger$
|
|
7189
|
+
logger$3.info('Transfering a session', {
|
|
7152
7190
|
id: this.getSipSessionId(session),
|
|
7153
7191
|
target,
|
|
7154
7192
|
});
|
|
@@ -7170,17 +7208,17 @@ class WebRTCClient extends Emitter {
|
|
|
7170
7208
|
atxfer(session ) {
|
|
7171
7209
|
this.hold(session);
|
|
7172
7210
|
|
|
7173
|
-
logger$
|
|
7211
|
+
logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
7174
7212
|
|
|
7175
7213
|
const result = {
|
|
7176
7214
|
newSession: null,
|
|
7177
7215
|
init: async (target ) => {
|
|
7178
|
-
logger$
|
|
7216
|
+
logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
7179
7217
|
|
|
7180
7218
|
result.newSession = await this.call(target);
|
|
7181
7219
|
},
|
|
7182
7220
|
complete: () => {
|
|
7183
|
-
logger$
|
|
7221
|
+
logger$3.info('webrtc transfer completed', {
|
|
7184
7222
|
id: this.getSipSessionId(session),
|
|
7185
7223
|
referId: this.getSipSessionId(result.newSession),
|
|
7186
7224
|
});
|
|
@@ -7201,7 +7239,7 @@ class WebRTCClient extends Emitter {
|
|
|
7201
7239
|
return;
|
|
7202
7240
|
}
|
|
7203
7241
|
|
|
7204
|
-
logger$
|
|
7242
|
+
logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
7205
7243
|
|
|
7206
7244
|
try {
|
|
7207
7245
|
sipSession.message({
|
|
@@ -7243,7 +7281,7 @@ class WebRTCClient extends Emitter {
|
|
|
7243
7281
|
}
|
|
7244
7282
|
|
|
7245
7283
|
changeAudioOutputVolume(volume ) {
|
|
7246
|
-
logger$
|
|
7284
|
+
logger$3.info('Changing audio output volume', { volume });
|
|
7247
7285
|
|
|
7248
7286
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7249
7287
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -7255,7 +7293,7 @@ class WebRTCClient extends Emitter {
|
|
|
7255
7293
|
}
|
|
7256
7294
|
|
|
7257
7295
|
changeAudioOutputDevice(id ) {
|
|
7258
|
-
logger$
|
|
7296
|
+
logger$3.info('Changing audio output device', { id });
|
|
7259
7297
|
|
|
7260
7298
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
7261
7299
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -7272,7 +7310,7 @@ class WebRTCClient extends Emitter {
|
|
|
7272
7310
|
|
|
7273
7311
|
changeAudioInputDevice(id , session ) {
|
|
7274
7312
|
const currentId = this.getAudioDeviceId();
|
|
7275
|
-
logger$
|
|
7313
|
+
logger$3.info('setting audio input device', { id, currentId, session: !!session });
|
|
7276
7314
|
|
|
7277
7315
|
if (id === currentId) {
|
|
7278
7316
|
return null;
|
|
@@ -7318,7 +7356,7 @@ class WebRTCClient extends Emitter {
|
|
|
7318
7356
|
|
|
7319
7357
|
setVideoInputDevice(id ) {
|
|
7320
7358
|
const currentId = this.getVideoDeviceId();
|
|
7321
|
-
logger$
|
|
7359
|
+
logger$3.info('setting video input device', { id, currentId });
|
|
7322
7360
|
|
|
7323
7361
|
if (id === currentId) {
|
|
7324
7362
|
return null;
|
|
@@ -7343,7 +7381,7 @@ class WebRTCClient extends Emitter {
|
|
|
7343
7381
|
const sessionId = this.getSipSessionId(session);
|
|
7344
7382
|
const localStream = this.getLocalStream(sessionId);
|
|
7345
7383
|
|
|
7346
|
-
logger$
|
|
7384
|
+
logger$3.info('changing video input device', { id, sessionId });
|
|
7347
7385
|
|
|
7348
7386
|
// Release old video stream
|
|
7349
7387
|
if (localStream) {
|
|
@@ -7411,7 +7449,7 @@ class WebRTCClient extends Emitter {
|
|
|
7411
7449
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
7412
7450
|
const desktop = newConstraints && newConstraints.desktop;
|
|
7413
7451
|
|
|
7414
|
-
logger$
|
|
7452
|
+
logger$3.info('Sending reinvite', {
|
|
7415
7453
|
id: this.getSipSessionId(sipSession),
|
|
7416
7454
|
newConstraints,
|
|
7417
7455
|
conference,
|
|
@@ -7449,7 +7487,7 @@ class WebRTCClient extends Emitter {
|
|
|
7449
7487
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
7450
7488
|
}
|
|
7451
7489
|
|
|
7452
|
-
logger$
|
|
7490
|
+
logger$3.info('on re-INVITE accepted', {
|
|
7453
7491
|
id: this.getSipSessionId(sipSession),
|
|
7454
7492
|
wasMuted,
|
|
7455
7493
|
shouldDoScreenSharing,
|
|
@@ -7467,7 +7505,7 @@ class WebRTCClient extends Emitter {
|
|
|
7467
7505
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
7468
7506
|
}
|
|
7469
7507
|
|
|
7470
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
7508
|
+
return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
|
|
7471
7509
|
},
|
|
7472
7510
|
},
|
|
7473
7511
|
sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
|
|
@@ -7568,6 +7606,16 @@ class WebRTCClient extends Emitter {
|
|
|
7568
7606
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
7569
7607
|
}
|
|
7570
7608
|
|
|
7609
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
7610
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
7611
|
+
const pc = this.getPeerConnection(sessionId);
|
|
7612
|
+
if (!pc) {
|
|
7613
|
+
return null;
|
|
7614
|
+
}
|
|
7615
|
+
|
|
7616
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
7617
|
+
}
|
|
7618
|
+
|
|
7571
7619
|
hasVideo(sessionId ) {
|
|
7572
7620
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
7573
7621
|
}
|
|
@@ -7614,7 +7662,7 @@ class WebRTCClient extends Emitter {
|
|
|
7614
7662
|
}
|
|
7615
7663
|
|
|
7616
7664
|
startHeartbeat() {
|
|
7617
|
-
logger$
|
|
7665
|
+
logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
7618
7666
|
if (!this.userAgent) {
|
|
7619
7667
|
this.heartbeat.stop();
|
|
7620
7668
|
return;
|
|
@@ -7627,7 +7675,7 @@ class WebRTCClient extends Emitter {
|
|
|
7627
7675
|
}
|
|
7628
7676
|
|
|
7629
7677
|
stopHeartbeat() {
|
|
7630
|
-
logger$
|
|
7678
|
+
logger$3.info('sdk webrtc stop heartbeat');
|
|
7631
7679
|
this.heartbeat.stop();
|
|
7632
7680
|
}
|
|
7633
7681
|
|
|
@@ -7648,7 +7696,7 @@ class WebRTCClient extends Emitter {
|
|
|
7648
7696
|
}
|
|
7649
7697
|
|
|
7650
7698
|
attemptReconnection() {
|
|
7651
|
-
logger$
|
|
7699
|
+
logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
7652
7700
|
if (!this.userAgent) {
|
|
7653
7701
|
return;
|
|
7654
7702
|
}
|
|
@@ -7673,7 +7721,7 @@ class WebRTCClient extends Emitter {
|
|
|
7673
7721
|
return;
|
|
7674
7722
|
}
|
|
7675
7723
|
|
|
7676
|
-
logger$
|
|
7724
|
+
logger$3.info('setting local media stream', {
|
|
7677
7725
|
sipSessionId,
|
|
7678
7726
|
tracks: newStream ? newStream.getTracks() : null,
|
|
7679
7727
|
});
|
|
@@ -7690,7 +7738,7 @@ class WebRTCClient extends Emitter {
|
|
|
7690
7738
|
|
|
7691
7739
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
7692
7740
|
|
|
7693
|
-
logger$
|
|
7741
|
+
logger$3.info('updating local stream', {
|
|
7694
7742
|
sipSessionId,
|
|
7695
7743
|
oldStream: !!oldStream,
|
|
7696
7744
|
tracks: newStream.getTracks(),
|
|
@@ -7710,7 +7758,7 @@ class WebRTCClient extends Emitter {
|
|
|
7710
7758
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
7711
7759
|
const pc = this.getPeerConnection(sessionId);
|
|
7712
7760
|
|
|
7713
|
-
logger$
|
|
7761
|
+
logger$3.info('Updating remote stream', {
|
|
7714
7762
|
sessionId,
|
|
7715
7763
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
7716
7764
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -7736,7 +7784,7 @@ class WebRTCClient extends Emitter {
|
|
|
7736
7784
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
7737
7785
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
7738
7786
|
|
|
7739
|
-
logger$
|
|
7787
|
+
logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7740
7788
|
|
|
7741
7789
|
return {
|
|
7742
7790
|
constraints: {
|
|
@@ -7785,7 +7833,7 @@ class WebRTCClient extends Emitter {
|
|
|
7785
7833
|
}
|
|
7786
7834
|
|
|
7787
7835
|
_onTransportError() {
|
|
7788
|
-
logger$
|
|
7836
|
+
logger$3.error('on transport error');
|
|
7789
7837
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
7790
7838
|
this.attemptReconnection();
|
|
7791
7839
|
}
|
|
@@ -7794,7 +7842,7 @@ class WebRTCClient extends Emitter {
|
|
|
7794
7842
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
7795
7843
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
7796
7844
|
if (this.hasHeartbeat()) {
|
|
7797
|
-
logger$
|
|
7845
|
+
logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
7798
7846
|
|
|
7799
7847
|
this.heartbeat.onHeartbeat();
|
|
7800
7848
|
if (this.heartbeatCb) {
|
|
@@ -7805,7 +7853,7 @@ class WebRTCClient extends Emitter {
|
|
|
7805
7853
|
}
|
|
7806
7854
|
|
|
7807
7855
|
async _onHeartbeatTimeout() {
|
|
7808
|
-
logger$
|
|
7856
|
+
logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
7809
7857
|
|
|
7810
7858
|
if (this.heartbeatTimeoutCb) {
|
|
7811
7859
|
this.heartbeatTimeoutCb();
|
|
@@ -7817,7 +7865,7 @@ class WebRTCClient extends Emitter {
|
|
|
7817
7865
|
try {
|
|
7818
7866
|
await this.userAgent.transport.disconnect();
|
|
7819
7867
|
} catch (e) {
|
|
7820
|
-
logger$
|
|
7868
|
+
logger$3.error('Transport disconnection after heartbeat timeout, error', e);
|
|
7821
7869
|
}
|
|
7822
7870
|
}
|
|
7823
7871
|
|
|
@@ -7850,31 +7898,31 @@ class WebRTCClient extends Emitter {
|
|
|
7850
7898
|
}
|
|
7851
7899
|
|
|
7852
7900
|
_connectIfNeeded() {
|
|
7853
|
-
logger$
|
|
7901
|
+
logger$3.info('connect if needed, checking', { connected: this.isConnected() });
|
|
7854
7902
|
if (!this.userAgent) {
|
|
7855
|
-
logger$
|
|
7903
|
+
logger$3.info('need to recreate User Agent');
|
|
7856
7904
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
7857
7905
|
}
|
|
7858
7906
|
|
|
7859
7907
|
if (this.isConnected()) {
|
|
7860
|
-
logger$
|
|
7908
|
+
logger$3.info('webrtc sdk, already connected');
|
|
7861
7909
|
return Promise.resolve();
|
|
7862
7910
|
}
|
|
7863
7911
|
|
|
7864
7912
|
if (this.isConnecting()) {
|
|
7865
|
-
logger$
|
|
7913
|
+
logger$3.info('webrtc sdk, already connecting...');
|
|
7866
7914
|
|
|
7867
7915
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
7868
7916
|
return this.connectionPromise;
|
|
7869
7917
|
}
|
|
7870
7918
|
|
|
7871
7919
|
if (this.connectionPromise) {
|
|
7872
|
-
logger$
|
|
7920
|
+
logger$3.info('webrtc sdk, connection promise connecting...');
|
|
7873
7921
|
// $FlowFixMe
|
|
7874
7922
|
return this.connectionPromise;
|
|
7875
7923
|
}
|
|
7876
7924
|
|
|
7877
|
-
logger$
|
|
7925
|
+
logger$3.info('WebRTC UA needs to connect');
|
|
7878
7926
|
|
|
7879
7927
|
// Force UA to reconnect
|
|
7880
7928
|
if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
|
|
@@ -7999,7 +8047,7 @@ class WebRTCClient extends Emitter {
|
|
|
7999
8047
|
|
|
8000
8048
|
sdh.peerConnectionDelegate = {
|
|
8001
8049
|
onicecandidateerror: (error ) => {
|
|
8002
|
-
logger$
|
|
8050
|
+
logger$3.error('on icecandidate error', {
|
|
8003
8051
|
address: error.address,
|
|
8004
8052
|
port: error.port,
|
|
8005
8053
|
errorCode: error.errorCode,
|
|
@@ -8028,7 +8076,7 @@ class WebRTCClient extends Emitter {
|
|
|
8028
8076
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
8029
8077
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
8030
8078
|
}
|
|
8031
|
-
logger$
|
|
8079
|
+
logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
8032
8080
|
|
|
8033
8081
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
8034
8082
|
|
|
@@ -8044,12 +8092,12 @@ class WebRTCClient extends Emitter {
|
|
|
8044
8092
|
|
|
8045
8093
|
this._setupMedias(session);
|
|
8046
8094
|
|
|
8047
|
-
return this.eventEmitter.emit(ON_REINVITE
|
|
8095
|
+
return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
|
|
8048
8096
|
};
|
|
8049
8097
|
}
|
|
8050
8098
|
|
|
8051
8099
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
8052
|
-
logger$
|
|
8100
|
+
logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
8053
8101
|
|
|
8054
8102
|
this.storeSipSession(session);
|
|
8055
8103
|
|
|
@@ -8061,14 +8109,14 @@ class WebRTCClient extends Emitter {
|
|
|
8061
8109
|
const onTrack = (event ) => {
|
|
8062
8110
|
const isAudioOnly = this._isAudioOnly(session);
|
|
8063
8111
|
const { kind, label, readyState, id, muted } = event.track;
|
|
8064
|
-
logger$
|
|
8112
|
+
logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
8065
8113
|
|
|
8066
8114
|
// Stop video track in audio only mode
|
|
8067
8115
|
if (isAudioOnly && kind === 'video') {
|
|
8068
8116
|
event.track.stop();
|
|
8069
8117
|
}
|
|
8070
8118
|
|
|
8071
|
-
this.eventEmitter.emit(ON_TRACK
|
|
8119
|
+
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
8072
8120
|
};
|
|
8073
8121
|
|
|
8074
8122
|
if (session.sessionDescriptionHandler.peerConnection) {
|
|
@@ -8078,8 +8126,9 @@ class WebRTCClient extends Emitter {
|
|
|
8078
8126
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8079
8127
|
|
|
8080
8128
|
pc.oniceconnectionstatechange = () => {
|
|
8129
|
+
logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8081
8130
|
if (pc.iceConnectionState === 'disconnected') {
|
|
8082
|
-
this.eventEmitter.emit(ON_DISCONNECTED
|
|
8131
|
+
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
8083
8132
|
}
|
|
8084
8133
|
};
|
|
8085
8134
|
|
|
@@ -8250,10 +8299,10 @@ class WebRTCClient extends Emitter {
|
|
|
8250
8299
|
|
|
8251
8300
|
_stopSendingStats(session ) {
|
|
8252
8301
|
const sessionId = this.getSipSessionId(session);
|
|
8253
|
-
logger$
|
|
8302
|
+
logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
8254
8303
|
|
|
8255
8304
|
if (sessionId in this.statsIntervals) {
|
|
8256
|
-
logger$
|
|
8305
|
+
logger$3.trace('Stop sending stats for call', { sessionId });
|
|
8257
8306
|
this.statsIntervals[sessionId]();
|
|
8258
8307
|
delete this.statsIntervals[sessionId];
|
|
8259
8308
|
}
|
|
@@ -8269,7 +8318,7 @@ class WebRTCClient extends Emitter {
|
|
|
8269
8318
|
try {
|
|
8270
8319
|
await this.userAgent.transport.disconnect();
|
|
8271
8320
|
} catch (e) {
|
|
8272
|
-
logger$
|
|
8321
|
+
logger$3.error('WebRTC transport disconnect, error', e);
|
|
8273
8322
|
}
|
|
8274
8323
|
}
|
|
8275
8324
|
}
|
|
@@ -8306,25 +8355,25 @@ class WebRTCClient extends Emitter {
|
|
|
8306
8355
|
|
|
8307
8356
|
stats.forEach(report => {
|
|
8308
8357
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8309
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8358
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8310
8359
|
}
|
|
8311
8360
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8312
|
-
audioBytesSent += report.bytesSent;
|
|
8361
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8313
8362
|
}
|
|
8314
8363
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8315
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8364
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8316
8365
|
}
|
|
8317
8366
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8318
|
-
packetsLost += report.packetsLost;
|
|
8319
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8320
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8367
|
+
packetsLost += Number(report.packetsLost);
|
|
8368
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8369
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8321
8370
|
}
|
|
8322
8371
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8323
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8372
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8324
8373
|
}
|
|
8325
8374
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8326
8375
|
if ('framesPerSecond' in report) {
|
|
8327
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8376
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8328
8377
|
}
|
|
8329
8378
|
if ('framerateMean' in report) {
|
|
8330
8379
|
// framerateMean is only available in FF
|
|
@@ -8332,34 +8381,38 @@ class WebRTCClient extends Emitter {
|
|
|
8332
8381
|
}
|
|
8333
8382
|
}
|
|
8334
8383
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8335
|
-
packetsLost += report.packetsLost;
|
|
8336
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8337
|
-
networkStats.jitter = report.jitter;
|
|
8384
|
+
packetsLost += Number(report.packetsLost);
|
|
8385
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8386
|
+
networkStats.jitter = Number(report.jitter);
|
|
8338
8387
|
}
|
|
8339
8388
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8340
|
-
packetsLost += report.packetsLost;
|
|
8389
|
+
packetsLost += Number(report.packetsLost);
|
|
8341
8390
|
}
|
|
8342
8391
|
if (report.type === 'transport') {
|
|
8343
|
-
transportSent += report.bytesSent;
|
|
8344
|
-
transportReceived += report.bytesReceived;
|
|
8392
|
+
transportSent += Number(report.bytesSent);
|
|
8393
|
+
transportReceived += Number(report.bytesReceived);
|
|
8345
8394
|
}
|
|
8346
8395
|
});
|
|
8347
8396
|
|
|
8348
8397
|
networkStats.packetsLost = packetsLost;
|
|
8349
|
-
networkStats.
|
|
8398
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8399
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8400
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8350
8401
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8351
|
-
networkStats.
|
|
8352
|
-
networkStats.
|
|
8402
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8403
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8404
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
8405
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
8406
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
8353
8407
|
networkStats.transportSent = transportSent;
|
|
8354
|
-
networkStats.
|
|
8355
|
-
|
|
8356
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
8357
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
8358
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
8408
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
8409
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
8359
8410
|
|
|
8360
|
-
networkStats.bandwidth =
|
|
8411
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
8412
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8413
|
+
+ networkStats.transportSent;
|
|
8361
8414
|
|
|
8362
|
-
this.eventEmitter.emit(ON_NETWORK_STATS
|
|
8415
|
+
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8363
8416
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
8364
8417
|
}
|
|
8365
8418
|
|
|
@@ -8387,8 +8440,8 @@ const ON_CALL_FAILED = 'onCallFailed';
|
|
|
8387
8440
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8388
8441
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8389
8442
|
const ON_MESSAGE = 'onMessage';
|
|
8390
|
-
const ON_REINVITE = 'reinvite';
|
|
8391
|
-
const ON_TRACK = 'onTrack';
|
|
8443
|
+
const ON_REINVITE$1 = 'reinvite';
|
|
8444
|
+
const ON_TRACK$1 = 'onTrack';
|
|
8392
8445
|
const ON_AUDIO_STREAM = 'onAudioStream';
|
|
8393
8446
|
const ON_VIDEO_STREAM = 'onVideoStream';
|
|
8394
8447
|
const ON_REMOVE_STREAM = 'onRemoveStream';
|
|
@@ -8403,15 +8456,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
|
|
|
8403
8456
|
const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
|
|
8404
8457
|
const ON_CALL_ERROR = 'onCallError';
|
|
8405
8458
|
const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
|
|
8406
|
-
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
8459
|
+
const ON_NETWORK_STATS$1 = 'onNetworkStats';
|
|
8407
8460
|
const ON_CHAT = 'phone/ON_CHAT';
|
|
8408
8461
|
const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
8409
|
-
const ON_DISCONNECTED = 'onDisconnected';
|
|
8462
|
+
const ON_DISCONNECTED$1 = 'onDisconnected';
|
|
8410
8463
|
|
|
8411
8464
|
const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
8412
8465
|
const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
8413
8466
|
|
|
8414
|
-
const events = [
|
|
8467
|
+
const events$1 = [
|
|
8415
8468
|
ON_USER_AGENT,
|
|
8416
8469
|
ON_REGISTERED,
|
|
8417
8470
|
ON_UNREGISTERED,
|
|
@@ -8429,8 +8482,8 @@ const events = [
|
|
|
8429
8482
|
ON_CALL_FAILED,
|
|
8430
8483
|
ON_CALL_ENDED,
|
|
8431
8484
|
ON_MESSAGE,
|
|
8432
|
-
ON_REINVITE,
|
|
8433
|
-
ON_TRACK,
|
|
8485
|
+
ON_REINVITE$1,
|
|
8486
|
+
ON_TRACK$1,
|
|
8434
8487
|
ON_AUDIO_STREAM,
|
|
8435
8488
|
ON_VIDEO_STREAM,
|
|
8436
8489
|
ON_REMOVE_STREAM,
|
|
@@ -8445,11 +8498,11 @@ const events = [
|
|
|
8445
8498
|
ON_CALL_ERROR,
|
|
8446
8499
|
ON_CHAT,
|
|
8447
8500
|
ON_SIGNAL,
|
|
8448
|
-
ON_NETWORK_STATS,
|
|
8449
|
-
ON_DISCONNECTED,
|
|
8501
|
+
ON_NETWORK_STATS$1,
|
|
8502
|
+
ON_DISCONNECTED$1,
|
|
8450
8503
|
];
|
|
8451
8504
|
|
|
8452
|
-
const logger$
|
|
8505
|
+
const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
8453
8506
|
|
|
8454
8507
|
class WebRTCPhone extends Emitter {
|
|
8455
8508
|
|
|
@@ -8522,7 +8575,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8522
8575
|
}).catch(error => {
|
|
8523
8576
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
8524
8577
|
console.error('register error', error, error.message, error.stack);
|
|
8525
|
-
logger$
|
|
8578
|
+
logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
8526
8579
|
});
|
|
8527
8580
|
}
|
|
8528
8581
|
|
|
@@ -8537,7 +8590,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8537
8590
|
if (!this.client) {
|
|
8538
8591
|
return;
|
|
8539
8592
|
}
|
|
8540
|
-
logger$
|
|
8593
|
+
logger$4.info('WebRTC phone stop');
|
|
8541
8594
|
this.client.stop();
|
|
8542
8595
|
}
|
|
8543
8596
|
|
|
@@ -8552,7 +8605,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8552
8605
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
8553
8606
|
audioOnly = false, iceRestart = false) {
|
|
8554
8607
|
const sipSession = this.findSipSession(callSession);
|
|
8555
|
-
logger$
|
|
8608
|
+
logger$4.info('WebRTC phone - send reinvite', {
|
|
8556
8609
|
sessionId: sipSession ? sipSession.id : null,
|
|
8557
8610
|
constraints,
|
|
8558
8611
|
audioOnly,
|
|
@@ -8589,7 +8642,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8589
8642
|
}
|
|
8590
8643
|
|
|
8591
8644
|
startHeartbeat() {
|
|
8592
|
-
logger$
|
|
8645
|
+
logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
8593
8646
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
8594
8647
|
return;
|
|
8595
8648
|
}
|
|
@@ -8598,7 +8651,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8598
8651
|
}
|
|
8599
8652
|
|
|
8600
8653
|
stopHeartbeat() {
|
|
8601
|
-
logger$
|
|
8654
|
+
logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
8602
8655
|
if (!this.client) {
|
|
8603
8656
|
return;
|
|
8604
8657
|
}
|
|
@@ -8615,7 +8668,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8615
8668
|
}
|
|
8616
8669
|
|
|
8617
8670
|
reconnect() {
|
|
8618
|
-
logger$
|
|
8671
|
+
logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
8619
8672
|
if (!this.client) {
|
|
8620
8673
|
return;
|
|
8621
8674
|
}
|
|
@@ -8656,10 +8709,15 @@ class WebRTCPhone extends Emitter {
|
|
|
8656
8709
|
return false;
|
|
8657
8710
|
}
|
|
8658
8711
|
|
|
8659
|
-
logger$
|
|
8712
|
+
logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
8660
8713
|
|
|
8661
8714
|
this.client.downgradeToAudio(sipSession);
|
|
8662
8715
|
|
|
8716
|
+
if (callSession) {
|
|
8717
|
+
callSession.cameraEnabled = false;
|
|
8718
|
+
this._updateCallSession(callSession);
|
|
8719
|
+
}
|
|
8720
|
+
|
|
8663
8721
|
if (withMessage) {
|
|
8664
8722
|
this._sendReinviteMessage(callSession, false);
|
|
8665
8723
|
}
|
|
@@ -8674,7 +8732,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8674
8732
|
return Promise.resolve(false);
|
|
8675
8733
|
}
|
|
8676
8734
|
|
|
8677
|
-
logger$
|
|
8735
|
+
logger$4.info('Upgrade to video', {
|
|
8678
8736
|
id: callSession ? callSession.getId() : null,
|
|
8679
8737
|
constraints,
|
|
8680
8738
|
isConference,
|
|
@@ -8687,6 +8745,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8687
8745
|
|
|
8688
8746
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8689
8747
|
|
|
8748
|
+
if (callSession) {
|
|
8749
|
+
callSession.cameraEnabled = true;
|
|
8750
|
+
this._updateCallSession(callSession);
|
|
8751
|
+
}
|
|
8752
|
+
|
|
8690
8753
|
// If no stream is returned, it means we have to reinvite
|
|
8691
8754
|
if (!newStream) {
|
|
8692
8755
|
return true;
|
|
@@ -8709,7 +8772,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8709
8772
|
|
|
8710
8773
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
8711
8774
|
const sipSession = this.findSipSession(callSession);
|
|
8712
|
-
logger$
|
|
8775
|
+
logger$4.info('Sending reinvite message', {
|
|
8713
8776
|
id: callSession ? callSession.getId() : null,
|
|
8714
8777
|
isUpgrade,
|
|
8715
8778
|
});
|
|
@@ -8735,11 +8798,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8735
8798
|
// Monkey patch to know when canceled with the CANCEL message
|
|
8736
8799
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
8737
8800
|
sipSession._onCancel = (message ) => {
|
|
8738
|
-
logger$
|
|
8801
|
+
logger$4.trace('on sip session canceled', { callId: message.callId });
|
|
8739
8802
|
|
|
8740
8803
|
onCancel(message);
|
|
8741
8804
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
8742
|
-
|
|
8805
|
+
const callSession = this._createCallSession(sipSession);
|
|
8806
|
+
delete this.callSessions[callSession.getId()];
|
|
8807
|
+
|
|
8808
|
+
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
8743
8809
|
};
|
|
8744
8810
|
} else if (sipSession instanceof Invitation) {
|
|
8745
8811
|
console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
|
|
@@ -8760,17 +8826,19 @@ class WebRTCPhone extends Emitter {
|
|
|
8760
8826
|
this.audioOutputVolume,
|
|
8761
8827
|
);
|
|
8762
8828
|
case SessionState.Terminating:
|
|
8763
|
-
logger$
|
|
8829
|
+
logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
8764
8830
|
|
|
8765
8831
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
8766
8832
|
|
|
8767
8833
|
break;
|
|
8768
8834
|
case SessionState.Terminated: {
|
|
8769
|
-
logger$
|
|
8835
|
+
logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
8770
8836
|
|
|
8837
|
+
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
8838
|
+
const callSession = this._createCallSession(sipSession);
|
|
8771
8839
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
8772
8840
|
|
|
8773
|
-
return this.eventEmitter.emit(ON_CALL_ENDED,
|
|
8841
|
+
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
8774
8842
|
}
|
|
8775
8843
|
}
|
|
8776
8844
|
});
|
|
@@ -8786,7 +8854,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8786
8854
|
const [stream] = event.streams;
|
|
8787
8855
|
const kind = event && event.track && event.track.kind;
|
|
8788
8856
|
|
|
8789
|
-
logger$
|
|
8857
|
+
logger$4.info('on track stream called on the peer connection', {
|
|
8790
8858
|
callId: this.getSipSessionId(sipSession),
|
|
8791
8859
|
streamId: stream ? stream.id : null,
|
|
8792
8860
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -8806,7 +8874,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8806
8874
|
};
|
|
8807
8875
|
|
|
8808
8876
|
peerConnection.onremovestream = event => {
|
|
8809
|
-
logger$
|
|
8877
|
+
logger$4.info('on remove stream called on the peer connection', {
|
|
8810
8878
|
id: event.stream.id,
|
|
8811
8879
|
tracks: event.stream.getTracks(),
|
|
8812
8880
|
});
|
|
@@ -8816,7 +8884,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8816
8884
|
}
|
|
8817
8885
|
|
|
8818
8886
|
async startScreenSharing(constraints , callSession ) {
|
|
8819
|
-
logger$
|
|
8887
|
+
logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
8820
8888
|
|
|
8821
8889
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
8822
8890
|
if (!screenShareStream) {
|
|
@@ -8856,7 +8924,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8856
8924
|
return;
|
|
8857
8925
|
}
|
|
8858
8926
|
|
|
8859
|
-
logger$
|
|
8927
|
+
logger$4.info('WebRTC phone - stop screen sharing', {
|
|
8860
8928
|
restoreLocalStream,
|
|
8861
8929
|
});
|
|
8862
8930
|
|
|
@@ -8912,24 +8980,26 @@ class WebRTCPhone extends Emitter {
|
|
|
8912
8980
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
8913
8981
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
8914
8982
|
|
|
8915
|
-
logger$
|
|
8983
|
+
logger$4.info('WebRTC phone - on screensharing', {
|
|
8916
8984
|
hadVideo,
|
|
8917
8985
|
id: this.getSipSessionId(sipSession),
|
|
8918
8986
|
screenTrack,
|
|
8919
8987
|
});
|
|
8920
8988
|
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8989
|
+
if (screenTrack) {
|
|
8990
|
+
screenTrack.onended = () => {
|
|
8991
|
+
logger$4.info('WebRTC phone - on screenshare ended', {
|
|
8992
|
+
hadVideo,
|
|
8993
|
+
id: this.getSipSessionId(sipSession),
|
|
8994
|
+
screenTrack,
|
|
8995
|
+
});
|
|
8927
8996
|
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8997
|
+
this.eventEmitter.emit(
|
|
8998
|
+
ON_SHARE_SCREEN_ENDING,
|
|
8999
|
+
this._createCallSession(sipSession, callSession),
|
|
9000
|
+
);
|
|
9001
|
+
};
|
|
9002
|
+
}
|
|
8933
9003
|
|
|
8934
9004
|
this.currentScreenShare = {
|
|
8935
9005
|
stream: screenStream,
|
|
@@ -8949,7 +9019,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8949
9019
|
}
|
|
8950
9020
|
|
|
8951
9021
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
8952
|
-
logger$
|
|
9022
|
+
logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
8953
9023
|
|
|
8954
9024
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
8955
9025
|
this.currentSipSession = sipSession;
|
|
@@ -8967,7 +9037,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8967
9037
|
}
|
|
8968
9038
|
|
|
8969
9039
|
changeAudioDevice(id ) {
|
|
8970
|
-
logger$
|
|
9040
|
+
logger$4.info('WebRTC phone - change audio device', { deviceId: id });
|
|
8971
9041
|
this.audioOutputDeviceId = id;
|
|
8972
9042
|
this.client.changeAudioOutputDevice(id);
|
|
8973
9043
|
}
|
|
@@ -8977,14 +9047,14 @@ class WebRTCPhone extends Emitter {
|
|
|
8977
9047
|
}
|
|
8978
9048
|
|
|
8979
9049
|
changeRingDevice(id ) {
|
|
8980
|
-
logger$
|
|
9050
|
+
logger$4.info('WebRTC phone - changing ring device', { id });
|
|
8981
9051
|
|
|
8982
9052
|
this.audioRingDeviceId = id;
|
|
8983
9053
|
}
|
|
8984
9054
|
|
|
8985
9055
|
// volume is a value between 0 and 1
|
|
8986
9056
|
changeAudioVolume(volume ) {
|
|
8987
|
-
logger$
|
|
9057
|
+
logger$4.info('WebRTC phone - changing audio volume', { volume });
|
|
8988
9058
|
|
|
8989
9059
|
this.audioOutputVolume = volume;
|
|
8990
9060
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -8992,31 +9062,31 @@ class WebRTCPhone extends Emitter {
|
|
|
8992
9062
|
|
|
8993
9063
|
// volume is a value between 0 and 1
|
|
8994
9064
|
changeRingVolume(volume ) {
|
|
8995
|
-
logger$
|
|
9065
|
+
logger$4.info('WebRTC phone - changing ring volume', { volume });
|
|
8996
9066
|
|
|
8997
9067
|
this.audioRingVolume = volume;
|
|
8998
9068
|
}
|
|
8999
9069
|
|
|
9000
9070
|
changeAudioInputDevice(id ) {
|
|
9001
|
-
logger$
|
|
9071
|
+
logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
9002
9072
|
|
|
9003
9073
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
9004
9074
|
}
|
|
9005
9075
|
|
|
9006
9076
|
changeVideoInputDevice(id ) {
|
|
9007
|
-
logger$
|
|
9077
|
+
logger$4.info('WebRTC phone - change video input device', { deviceId: id });
|
|
9008
9078
|
|
|
9009
9079
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
9010
9080
|
}
|
|
9011
9081
|
|
|
9012
9082
|
changeSessionVideoInputDevice(id ) {
|
|
9013
|
-
logger$
|
|
9083
|
+
logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
9014
9084
|
|
|
9015
9085
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
9016
9086
|
}
|
|
9017
9087
|
|
|
9018
9088
|
_onCallTerminated(sipSession ) {
|
|
9019
|
-
logger$
|
|
9089
|
+
logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9020
9090
|
|
|
9021
9091
|
const callSession = this._createCallSession(sipSession);
|
|
9022
9092
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -9050,7 +9120,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9050
9120
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
9051
9121
|
|
|
9052
9122
|
// Re-trigger incoming call event for remaining incoming calls
|
|
9053
|
-
logger$
|
|
9123
|
+
logger$4.info('WebRTC phone - check to re-trigger incoming call', {
|
|
9054
9124
|
sipId: sipSession.id,
|
|
9055
9125
|
shouldRetrigger,
|
|
9056
9126
|
hasIncomingCallSession,
|
|
@@ -9141,37 +9211,37 @@ class WebRTCPhone extends Emitter {
|
|
|
9141
9211
|
|
|
9142
9212
|
// Deprecated
|
|
9143
9213
|
getLocalStreamForCall(callSession ) {
|
|
9144
|
-
logger$
|
|
9214
|
+
logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9145
9215
|
|
|
9146
9216
|
return this.getLocalStream(callSession);
|
|
9147
9217
|
}
|
|
9148
9218
|
|
|
9149
9219
|
// Deprecated
|
|
9150
9220
|
getRemoteStreamForCall(callSession ) {
|
|
9151
|
-
logger$
|
|
9221
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
9152
9222
|
|
|
9153
9223
|
return this.getRemoteVideoStream(callSession);
|
|
9154
9224
|
}
|
|
9155
9225
|
|
|
9156
9226
|
getRemoteStreamsForCall(callSession ) {
|
|
9157
|
-
logger$
|
|
9227
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
9158
9228
|
|
|
9159
9229
|
return this.getRemoteStream(callSession);
|
|
9160
9230
|
}
|
|
9161
9231
|
|
|
9162
9232
|
accept(callSession , cameraEnabled ) {
|
|
9163
|
-
logger$
|
|
9233
|
+
logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
9164
9234
|
if (this.currentSipSession) {
|
|
9165
9235
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
9166
9236
|
}
|
|
9167
9237
|
|
|
9168
9238
|
if (!callSession) {
|
|
9169
|
-
logger$
|
|
9239
|
+
logger$4.warn('no CallSession to accept.');
|
|
9170
9240
|
return Promise.resolve(null);
|
|
9171
9241
|
}
|
|
9172
9242
|
|
|
9173
9243
|
if (callSession.getId() in this.acceptedSessions) {
|
|
9174
|
-
logger$
|
|
9244
|
+
logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9175
9245
|
return Promise.resolve(callSession.sipCallId);
|
|
9176
9246
|
}
|
|
9177
9247
|
|
|
@@ -9183,24 +9253,24 @@ class WebRTCPhone extends Emitter {
|
|
|
9183
9253
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
9184
9254
|
if (sipSession) {
|
|
9185
9255
|
if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
|
|
9186
|
-
logger$
|
|
9256
|
+
logger$4.warn('Trying to answer a terminated sipSession.');
|
|
9187
9257
|
|
|
9188
9258
|
return Promise.resolve(null);
|
|
9189
9259
|
}
|
|
9190
9260
|
|
|
9191
|
-
logger$
|
|
9261
|
+
logger$4.info('accept call, session found', { sipId: sipSession.id });
|
|
9192
9262
|
|
|
9193
9263
|
// $FlowFixMe
|
|
9194
9264
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
9195
9265
|
return callSession.sipCallId;
|
|
9196
9266
|
}).catch(e => {
|
|
9197
|
-
logger$
|
|
9267
|
+
logger$4.error(e);
|
|
9198
9268
|
this.endCurrentCall(callSession);
|
|
9199
9269
|
throw e;
|
|
9200
9270
|
});
|
|
9201
9271
|
}
|
|
9202
9272
|
|
|
9203
|
-
logger$
|
|
9273
|
+
logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
9204
9274
|
|
|
9205
9275
|
return Promise.resolve(null);
|
|
9206
9276
|
}
|
|
@@ -9210,7 +9280,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9210
9280
|
}
|
|
9211
9281
|
|
|
9212
9282
|
async reject(callSession ) {
|
|
9213
|
-
logger$
|
|
9283
|
+
logger$4.info('reject WebRTC called', { id: callSession.getId() });
|
|
9214
9284
|
|
|
9215
9285
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
9216
9286
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -9222,14 +9292,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9222
9292
|
|
|
9223
9293
|
const sipSession = this.findSipSession(callSession);
|
|
9224
9294
|
if (sipSession) {
|
|
9225
|
-
logger$
|
|
9295
|
+
logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
9226
9296
|
|
|
9227
9297
|
this.client.hangup(sipSession);
|
|
9228
9298
|
}
|
|
9229
9299
|
}
|
|
9230
9300
|
|
|
9231
9301
|
async ignore(callSession ) {
|
|
9232
|
-
logger$
|
|
9302
|
+
logger$4.info('WebRTC ignore', { id: callSession.getId() });
|
|
9233
9303
|
|
|
9234
9304
|
// kill the ring
|
|
9235
9305
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -9241,14 +9311,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9241
9311
|
const sipSession = this.findSipSession(callSession);
|
|
9242
9312
|
|
|
9243
9313
|
if (sipSession) {
|
|
9244
|
-
logger$
|
|
9314
|
+
logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
9245
9315
|
|
|
9246
9316
|
return this.client.atxfer(sipSession);
|
|
9247
9317
|
}
|
|
9248
9318
|
}
|
|
9249
9319
|
|
|
9250
9320
|
hold(callSession , withEvent = true, isConference = false) {
|
|
9251
|
-
logger$
|
|
9321
|
+
logger$4.info('WebRTC hold', { id: callSession.getId() });
|
|
9252
9322
|
|
|
9253
9323
|
const sipSession = this.findSipSession(callSession);
|
|
9254
9324
|
|
|
@@ -9263,18 +9333,18 @@ class WebRTCPhone extends Emitter {
|
|
|
9263
9333
|
}
|
|
9264
9334
|
|
|
9265
9335
|
resume(callSession , isConference = false, withEvent = true) {
|
|
9266
|
-
logger$
|
|
9336
|
+
logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
9267
9337
|
|
|
9268
9338
|
const sipSession = this.findSipSession(callSession);
|
|
9269
9339
|
if (!sipSession) {
|
|
9270
9340
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
9271
9341
|
}
|
|
9272
9342
|
|
|
9273
|
-
logger$
|
|
9343
|
+
logger$4.info('WebRTC resuming', { sipId: sipSession.id });
|
|
9274
9344
|
|
|
9275
9345
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
9276
9346
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
9277
|
-
logger$
|
|
9347
|
+
logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
9278
9348
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
9279
9349
|
}
|
|
9280
9350
|
|
|
@@ -9299,7 +9369,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9299
9369
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9300
9370
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
9301
9371
|
|
|
9302
|
-
logger$
|
|
9372
|
+
logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
9303
9373
|
|
|
9304
9374
|
// Stop screenshre if needed
|
|
9305
9375
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -9330,7 +9400,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9330
9400
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
9331
9401
|
}
|
|
9332
9402
|
const sessionId = this.getSipSessionId(sipSession);
|
|
9333
|
-
logger$
|
|
9403
|
+
logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
9334
9404
|
|
|
9335
9405
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
9336
9406
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -9374,14 +9444,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9374
9444
|
}
|
|
9375
9445
|
|
|
9376
9446
|
mute(callSession , withEvent = true) {
|
|
9377
|
-
logger$
|
|
9447
|
+
logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
9378
9448
|
|
|
9379
9449
|
const sipSession = this.findSipSession(callSession);
|
|
9380
9450
|
if (!sipSession) {
|
|
9381
9451
|
return;
|
|
9382
9452
|
}
|
|
9383
9453
|
|
|
9384
|
-
logger$
|
|
9454
|
+
logger$4.info('WebRTC muting', { sipId: sipSession.id });
|
|
9385
9455
|
this.client.mute(sipSession);
|
|
9386
9456
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
9387
9457
|
|
|
@@ -9395,14 +9465,14 @@ class WebRTCPhone extends Emitter {
|
|
|
9395
9465
|
}
|
|
9396
9466
|
|
|
9397
9467
|
unmute(callSession , withEvent = true) {
|
|
9398
|
-
logger$
|
|
9468
|
+
logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
9399
9469
|
|
|
9400
9470
|
const sipSession = this.findSipSession(callSession);
|
|
9401
9471
|
if (!sipSession) {
|
|
9402
9472
|
return;
|
|
9403
9473
|
}
|
|
9404
9474
|
|
|
9405
|
-
logger$
|
|
9475
|
+
logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
9406
9476
|
this.client.unmute(sipSession);
|
|
9407
9477
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
9408
9478
|
|
|
@@ -9429,7 +9499,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9429
9499
|
if (!sipSession) {
|
|
9430
9500
|
return;
|
|
9431
9501
|
}
|
|
9432
|
-
logger$
|
|
9502
|
+
logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
9433
9503
|
|
|
9434
9504
|
this.client.toggleCameraOn(sipSession);
|
|
9435
9505
|
|
|
@@ -9441,7 +9511,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9441
9511
|
if (!sipSession) {
|
|
9442
9512
|
return;
|
|
9443
9513
|
}
|
|
9444
|
-
logger$
|
|
9514
|
+
logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
9445
9515
|
|
|
9446
9516
|
this.client.toggleCameraOff(sipSession);
|
|
9447
9517
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -9453,7 +9523,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9453
9523
|
return;
|
|
9454
9524
|
}
|
|
9455
9525
|
|
|
9456
|
-
logger$
|
|
9526
|
+
logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
9457
9527
|
this.client.sendDTMF(sipSession, tone);
|
|
9458
9528
|
}
|
|
9459
9529
|
|
|
@@ -9461,7 +9531,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9461
9531
|
// @TODO: line is not used here
|
|
9462
9532
|
async makeCall(number , line , cameraEnabled ,
|
|
9463
9533
|
audioOnly = false, conference = false) {
|
|
9464
|
-
logger$
|
|
9534
|
+
logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9465
9535
|
if (!number) {
|
|
9466
9536
|
return Promise.resolve(null);
|
|
9467
9537
|
}
|
|
@@ -9471,7 +9541,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9471
9541
|
}
|
|
9472
9542
|
if (this.currentSipSession) {
|
|
9473
9543
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
9474
|
-
logger$
|
|
9544
|
+
logger$4.warn('Unable to hold current session when making another call', e);
|
|
9475
9545
|
});
|
|
9476
9546
|
}
|
|
9477
9547
|
|
|
@@ -9481,7 +9551,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9481
9551
|
this._bindEvents(sipSession);
|
|
9482
9552
|
} catch (error) {
|
|
9483
9553
|
console.warn(error);
|
|
9484
|
-
logger$
|
|
9554
|
+
logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
9485
9555
|
return Promise.resolve(null);
|
|
9486
9556
|
}
|
|
9487
9557
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -9509,7 +9579,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9509
9579
|
return;
|
|
9510
9580
|
}
|
|
9511
9581
|
|
|
9512
|
-
logger$
|
|
9582
|
+
logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
9513
9583
|
|
|
9514
9584
|
this.client.transfer(sipSession, target);
|
|
9515
9585
|
}
|
|
@@ -9518,7 +9588,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9518
9588
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
9519
9589
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
9520
9590
|
|
|
9521
|
-
logger$
|
|
9591
|
+
logger$4.info('WebRTC indirect transfer', {
|
|
9522
9592
|
sipId: sipSession ? sipSession.id : null,
|
|
9523
9593
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
9524
9594
|
});
|
|
@@ -9557,7 +9627,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9557
9627
|
return false;
|
|
9558
9628
|
}
|
|
9559
9629
|
|
|
9560
|
-
logger$
|
|
9630
|
+
logger$4.info('WebRTC hangup', { sipId: sipSession.id });
|
|
9561
9631
|
|
|
9562
9632
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9563
9633
|
|
|
@@ -9603,7 +9673,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9603
9673
|
endCurrentCall(callSession ) {
|
|
9604
9674
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
9605
9675
|
|
|
9606
|
-
logger$
|
|
9676
|
+
logger$4.info('Ending current call', {
|
|
9607
9677
|
id: callSession ? callSession.getId() : null,
|
|
9608
9678
|
isCurrent,
|
|
9609
9679
|
});
|
|
@@ -9627,7 +9697,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9627
9697
|
}
|
|
9628
9698
|
|
|
9629
9699
|
async close() {
|
|
9630
|
-
logger$
|
|
9700
|
+
logger$4.info('WebRTC close');
|
|
9631
9701
|
|
|
9632
9702
|
try {
|
|
9633
9703
|
await Promise.race([
|
|
@@ -9635,7 +9705,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9635
9705
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
9636
9706
|
]);
|
|
9637
9707
|
} catch (e) {
|
|
9638
|
-
logger$
|
|
9708
|
+
logger$4.error('WebRTC close, unregister error', e);
|
|
9639
9709
|
}
|
|
9640
9710
|
|
|
9641
9711
|
this.client.close();
|
|
@@ -9653,12 +9723,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9653
9723
|
}
|
|
9654
9724
|
|
|
9655
9725
|
enableRinging() {
|
|
9656
|
-
logger$
|
|
9726
|
+
logger$4.info('WebRTC enable ringing');
|
|
9657
9727
|
this.ringingEnabled = true;
|
|
9658
9728
|
}
|
|
9659
9729
|
|
|
9660
9730
|
disableRinging() {
|
|
9661
|
-
logger$
|
|
9731
|
+
logger$4.info('WebRTC disable ringing');
|
|
9662
9732
|
this.ringingEnabled = false;
|
|
9663
9733
|
}
|
|
9664
9734
|
|
|
@@ -9698,7 +9768,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9698
9768
|
|
|
9699
9769
|
// Deprecated
|
|
9700
9770
|
getLocalMediaStream(callSession ) {
|
|
9701
|
-
logger$
|
|
9771
|
+
logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
9702
9772
|
return this.getLocalStream(callSession);
|
|
9703
9773
|
}
|
|
9704
9774
|
|
|
@@ -9718,6 +9788,10 @@ class WebRTCPhone extends Emitter {
|
|
|
9718
9788
|
return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
|
|
9719
9789
|
}
|
|
9720
9790
|
|
|
9791
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
9792
|
+
return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
|
|
9793
|
+
}
|
|
9794
|
+
|
|
9721
9795
|
hasRemoteVideo(callSession ) {
|
|
9722
9796
|
return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
|
|
9723
9797
|
}
|
|
@@ -9736,7 +9810,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9736
9810
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
9737
9811
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
9738
9812
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
9739
|
-
logger$
|
|
9813
|
+
logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
9740
9814
|
|
|
9741
9815
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
9742
9816
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -9759,7 +9833,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9759
9833
|
});
|
|
9760
9834
|
|
|
9761
9835
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
9762
|
-
logger$
|
|
9836
|
+
logger$4.info('WebRTC on reinvite', {
|
|
9763
9837
|
sessionId: args[0].id,
|
|
9764
9838
|
inviteId: args[1].id,
|
|
9765
9839
|
updatedCalleeName: args[2],
|
|
@@ -9779,7 +9853,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9779
9853
|
});
|
|
9780
9854
|
|
|
9781
9855
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
9782
|
-
logger$
|
|
9856
|
+
logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
9783
9857
|
|
|
9784
9858
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
9785
9859
|
|
|
@@ -9790,22 +9864,22 @@ class WebRTCPhone extends Emitter {
|
|
|
9790
9864
|
this.client.on('ended', () => {});
|
|
9791
9865
|
|
|
9792
9866
|
this.client.on(this.client.ON_ERROR, e => {
|
|
9793
|
-
logger$
|
|
9867
|
+
logger$4.error('WebRTC error', e);
|
|
9794
9868
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
9795
9869
|
});
|
|
9796
9870
|
|
|
9797
9871
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
9798
|
-
logger$
|
|
9872
|
+
logger$4.info('WebRTC unregistered');
|
|
9799
9873
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9800
9874
|
});
|
|
9801
9875
|
|
|
9802
9876
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
9803
|
-
logger$
|
|
9804
|
-
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
9877
|
+
logger$4.info('WebRTC disconnected');
|
|
9878
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
9805
9879
|
});
|
|
9806
9880
|
|
|
9807
9881
|
this.client.on(this.client.REGISTERED, () => {
|
|
9808
|
-
logger$
|
|
9882
|
+
logger$4.info('WebRTC registered', {
|
|
9809
9883
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
9810
9884
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
9811
9885
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -9818,23 +9892,27 @@ class WebRTCPhone extends Emitter {
|
|
|
9818
9892
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
9819
9893
|
&& this.currentSipSession.state === SessionState.Established) {
|
|
9820
9894
|
this.shouldSendReinvite = false;
|
|
9895
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
9896
|
+
const isConference = pc ? pc.sfu : false;
|
|
9897
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
9898
|
+
|
|
9821
9899
|
try {
|
|
9822
9900
|
// Send reinvite with iceRestart
|
|
9823
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
9901
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
9824
9902
|
} catch (e) {
|
|
9825
|
-
logger$
|
|
9903
|
+
logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
9826
9904
|
}
|
|
9827
9905
|
}
|
|
9828
9906
|
});
|
|
9829
9907
|
|
|
9830
9908
|
this.client.on(this.client.CONNECTED, () => {
|
|
9831
|
-
logger$
|
|
9909
|
+
logger$4.info('WebRTC client connected');
|
|
9832
9910
|
|
|
9833
9911
|
this.stopHeartbeat();
|
|
9834
9912
|
});
|
|
9835
9913
|
|
|
9836
9914
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
9837
|
-
logger$
|
|
9915
|
+
logger$4.info('WebRTC client disconnected');
|
|
9838
9916
|
|
|
9839
9917
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
9840
9918
|
|
|
@@ -9848,7 +9926,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9848
9926
|
});
|
|
9849
9927
|
|
|
9850
9928
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
9851
|
-
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
9929
|
+
this.eventEmitter.emit(ON_TRACK$1, session, event);
|
|
9852
9930
|
});
|
|
9853
9931
|
|
|
9854
9932
|
this.client.on('onVideoInputChange', stream => {
|
|
@@ -9863,7 +9941,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9863
9941
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
9864
9942
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
9865
9943
|
|
|
9866
|
-
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
9944
|
+
this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
|
|
9867
9945
|
});
|
|
9868
9946
|
|
|
9869
9947
|
// Used when upgrading directly in screenshare mode
|
|
@@ -9872,7 +9950,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9872
9950
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
9873
9951
|
const callSession = this.callSessions[sipSessionId];
|
|
9874
9952
|
|
|
9875
|
-
logger$
|
|
9953
|
+
logger$4.info('Updrading directly in screensharing mode', {
|
|
9876
9954
|
sipSessionId,
|
|
9877
9955
|
tracks: localStream ? localStream.getTracks() : null,
|
|
9878
9956
|
});
|
|
@@ -9904,6 +9982,15 @@ class WebRTCPhone extends Emitter {
|
|
|
9904
9982
|
return this.client.getSipSessionId(sipSession);
|
|
9905
9983
|
}
|
|
9906
9984
|
|
|
9985
|
+
_updateCallSession(callSession ) {
|
|
9986
|
+
const sipSession = this.findSipSession(callSession);
|
|
9987
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
9988
|
+
|
|
9989
|
+
if (sipSessionId) {
|
|
9990
|
+
this.callSessions[sipSessionId] = callSession;
|
|
9991
|
+
}
|
|
9992
|
+
}
|
|
9993
|
+
|
|
9907
9994
|
_onMessage(message ) {
|
|
9908
9995
|
if (!message || message.method !== 'MESSAGE') {
|
|
9909
9996
|
return;
|
|
@@ -10041,8 +10128,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10041
10128
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10042
10129
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10043
10130
|
ON_MESSAGE: ON_MESSAGE,
|
|
10044
|
-
ON_REINVITE: ON_REINVITE,
|
|
10045
|
-
ON_TRACK: ON_TRACK,
|
|
10131
|
+
ON_REINVITE: ON_REINVITE$1,
|
|
10132
|
+
ON_TRACK: ON_TRACK$1,
|
|
10046
10133
|
ON_AUDIO_STREAM: ON_AUDIO_STREAM,
|
|
10047
10134
|
ON_VIDEO_STREAM: ON_VIDEO_STREAM,
|
|
10048
10135
|
ON_REMOVE_STREAM: ON_REMOVE_STREAM,
|
|
@@ -10057,19 +10144,19 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10057
10144
|
ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
|
|
10058
10145
|
ON_CALL_ERROR: ON_CALL_ERROR,
|
|
10059
10146
|
ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
|
|
10060
|
-
ON_NETWORK_STATS: ON_NETWORK_STATS,
|
|
10147
|
+
ON_NETWORK_STATS: ON_NETWORK_STATS$1,
|
|
10061
10148
|
ON_CHAT: ON_CHAT,
|
|
10062
10149
|
ON_SIGNAL: ON_SIGNAL,
|
|
10063
|
-
ON_DISCONNECTED: ON_DISCONNECTED,
|
|
10150
|
+
ON_DISCONNECTED: ON_DISCONNECTED$1,
|
|
10064
10151
|
MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
|
|
10065
10152
|
MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
|
|
10066
|
-
events: events,
|
|
10153
|
+
events: events$1,
|
|
10067
10154
|
'default': WebRTCPhone
|
|
10068
10155
|
});
|
|
10069
10156
|
|
|
10070
10157
|
//
|
|
10071
10158
|
|
|
10072
|
-
const logger$
|
|
10159
|
+
const logger$5 = IssueReporter$1.loggerFor('simple-phone');
|
|
10073
10160
|
const sipLogger = IssueReporter$1.loggerFor('sip.js');
|
|
10074
10161
|
const protocolLogger = IssueReporter$1.loggerFor('sip');
|
|
10075
10162
|
|
|
@@ -10176,7 +10263,7 @@ class Phone extends Emitter {
|
|
|
10176
10263
|
async disconnect() {
|
|
10177
10264
|
if (this.phone) {
|
|
10178
10265
|
if (this.phone.hasAnActiveCall()) {
|
|
10179
|
-
logger$
|
|
10266
|
+
logger$5.info('hangup call on disconnect');
|
|
10180
10267
|
// $FlowFixMe
|
|
10181
10268
|
await this.phone.hangup();
|
|
10182
10269
|
}
|
|
@@ -10199,13 +10286,13 @@ class Phone extends Emitter {
|
|
|
10199
10286
|
}
|
|
10200
10287
|
|
|
10201
10288
|
async hangup(callSession ) {
|
|
10202
|
-
logger$
|
|
10289
|
+
logger$5.info('hangup via simple phone', { callId: callSession.getId() });
|
|
10203
10290
|
|
|
10204
10291
|
return this.phone && this.phone.hangup(callSession);
|
|
10205
10292
|
}
|
|
10206
10293
|
|
|
10207
10294
|
async accept(callSession , cameraEnabled ) {
|
|
10208
|
-
logger$
|
|
10295
|
+
logger$5.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
|
|
10209
10296
|
|
|
10210
10297
|
return this.phone && this.phone.accept(callSession, cameraEnabled);
|
|
10211
10298
|
}
|
|
@@ -10244,7 +10331,7 @@ class Phone extends Emitter {
|
|
|
10244
10331
|
muteViaAPI(callSession ) {
|
|
10245
10332
|
if (callSession && callSession.callId) {
|
|
10246
10333
|
Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
|
|
10247
|
-
logger$
|
|
10334
|
+
logger$5.error('Mute via API, error', e);
|
|
10248
10335
|
});
|
|
10249
10336
|
}
|
|
10250
10337
|
}
|
|
@@ -10252,7 +10339,7 @@ class Phone extends Emitter {
|
|
|
10252
10339
|
unmuteViaAPI(callSession ) {
|
|
10253
10340
|
if (callSession && callSession.callId) {
|
|
10254
10341
|
Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
|
|
10255
|
-
logger$
|
|
10342
|
+
logger$5.error('Unmute via API, error', e);
|
|
10256
10343
|
});
|
|
10257
10344
|
}
|
|
10258
10345
|
}
|
|
@@ -10360,7 +10447,7 @@ class Phone extends Emitter {
|
|
|
10360
10447
|
|
|
10361
10448
|
// @Deprecated
|
|
10362
10449
|
getLocalMediaStream(callSession ) {
|
|
10363
|
-
logger$
|
|
10450
|
+
logger$5.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
|
|
10364
10451
|
|
|
10365
10452
|
return this.phone && this.phone.getLocalStream(callSession);
|
|
10366
10453
|
}
|
|
@@ -10383,24 +10470,29 @@ class Phone extends Emitter {
|
|
|
10383
10470
|
|
|
10384
10471
|
// @Deprecated
|
|
10385
10472
|
getRemoteStreamForCall(callSession ) {
|
|
10386
|
-
logger$
|
|
10473
|
+
logger$5.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
|
|
10387
10474
|
return this.getRemoteStream(callSession);
|
|
10388
10475
|
}
|
|
10389
10476
|
|
|
10390
10477
|
// Returns remote streams directly from the peerConnection
|
|
10391
10478
|
// @Deprecated
|
|
10392
10479
|
getRemoteStreamsForCall(callSession ) {
|
|
10393
|
-
logger$
|
|
10480
|
+
logger$5.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
|
|
10394
10481
|
return this.getLocalStream(callSession);
|
|
10395
10482
|
}
|
|
10396
10483
|
|
|
10397
10484
|
// @Deprecated
|
|
10398
10485
|
getRemoteVideoStreamForCall(callSession ) {
|
|
10399
|
-
logger$
|
|
10486
|
+
logger$5.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
|
|
10400
10487
|
|
|
10401
10488
|
return this.getRemoteVideoStream(callSession);
|
|
10402
10489
|
}
|
|
10403
10490
|
|
|
10491
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
10492
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
10493
|
+
return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
|
|
10494
|
+
}
|
|
10495
|
+
|
|
10404
10496
|
hasVideo(callSession ) {
|
|
10405
10497
|
return this.phone ? this.phone.hasVideo(callSession) : false;
|
|
10406
10498
|
}
|
|
@@ -10452,7 +10544,7 @@ class Phone extends Emitter {
|
|
|
10452
10544
|
|
|
10453
10545
|
_transferEvents() {
|
|
10454
10546
|
this.unbind();
|
|
10455
|
-
[...events
|
|
10547
|
+
[...events, ...transportEvents].forEach(event => {
|
|
10456
10548
|
this.client.on(event, (...args) =>
|
|
10457
10549
|
this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
|
|
10458
10550
|
});
|
|
@@ -10474,7 +10566,7 @@ var Phone$1 = global.wazoTelephonyInstance;
|
|
|
10474
10566
|
|
|
10475
10567
|
//
|
|
10476
10568
|
|
|
10477
|
-
const SOCKET_EVENTS
|
|
10569
|
+
const SOCKET_EVENTS = {
|
|
10478
10570
|
ON_OPEN: 'onopen',
|
|
10479
10571
|
ON_MESSAGE: 'onmessage',
|
|
10480
10572
|
ON_ERROR: 'onerror',
|
|
@@ -10560,6 +10652,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
10560
10652
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
10561
10653
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
10562
10654
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
10655
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
10563
10656
|
|
|
10564
10657
|
const BLACKLIST_EVENTS = [
|
|
10565
10658
|
CHAT_MESSAGE_SENT,
|
|
@@ -10626,16 +10719,16 @@ class WebSocketClient extends Emitter {
|
|
|
10626
10719
|
|
|
10627
10720
|
this.socket.onopen = () => {
|
|
10628
10721
|
logger$6.info('on Wazo WS open', { method: 'connect', host: this.host });
|
|
10629
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10722
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
|
|
10630
10723
|
};
|
|
10631
10724
|
|
|
10632
10725
|
this.socket.onerror = event => {
|
|
10633
10726
|
logger$6.error('on Wazo WS error', event.target);
|
|
10634
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10727
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
|
|
10635
10728
|
};
|
|
10636
10729
|
|
|
10637
10730
|
this.socket.onmessage = (event ) => {
|
|
10638
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10731
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
|
|
10639
10732
|
|
|
10640
10733
|
const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
|
|
10641
10734
|
let { name } = message;
|
|
@@ -10668,11 +10761,11 @@ class WebSocketClient extends Emitter {
|
|
|
10668
10761
|
token: this.token,
|
|
10669
10762
|
});
|
|
10670
10763
|
this.initialized = false;
|
|
10671
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10764
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
|
|
10672
10765
|
|
|
10673
10766
|
switch (event.code) {
|
|
10674
10767
|
case 4002:
|
|
10675
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10768
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
|
|
10676
10769
|
break;
|
|
10677
10770
|
}
|
|
10678
10771
|
};
|
|
@@ -10788,7 +10881,7 @@ class WebSocketClient extends Emitter {
|
|
|
10788
10881
|
break;
|
|
10789
10882
|
case 'start':
|
|
10790
10883
|
this.initialized = true;
|
|
10791
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10884
|
+
this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
|
|
10792
10885
|
break;
|
|
10793
10886
|
default:
|
|
10794
10887
|
this.eventEmitter.emit('message', message);
|
|
@@ -10835,7 +10928,7 @@ class WebSocketClient extends Emitter {
|
|
|
10835
10928
|
logger$6.log('heartbeat timed out', { host: this.host, token: this.token });
|
|
10836
10929
|
|
|
10837
10930
|
this.close();
|
|
10838
|
-
this.eventEmitter.emit(SOCKET_EVENTS
|
|
10931
|
+
this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
|
|
10839
10932
|
|
|
10840
10933
|
if (this.onHeartBeatTimeout) {
|
|
10841
10934
|
this.onHeartBeatTimeout();
|
|
@@ -10910,11 +11003,12 @@ WebSocketClient.eventLists = [
|
|
|
10910
11003
|
AGENT_UNPAUSED,
|
|
10911
11004
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
10912
11005
|
CONFERENCE_ADHOC_DELETED,
|
|
11006
|
+
MEETING_USER_PROGRESS,
|
|
10913
11007
|
];
|
|
10914
11008
|
|
|
10915
11009
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
10916
11010
|
__proto__: null,
|
|
10917
|
-
SOCKET_EVENTS: SOCKET_EVENTS
|
|
11011
|
+
SOCKET_EVENTS: SOCKET_EVENTS,
|
|
10918
11012
|
AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
|
|
10919
11013
|
FAVORITE_ADDED: FAVORITE_ADDED,
|
|
10920
11014
|
FAVORITE_DELETED: FAVORITE_DELETED,
|
|
@@ -10980,16 +11074,17 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
10980
11074
|
AGENT_UNPAUSED: AGENT_UNPAUSED,
|
|
10981
11075
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
10982
11076
|
CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
|
|
11077
|
+
MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
|
|
10983
11078
|
HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
|
|
10984
11079
|
'default': WebSocketClient
|
|
10985
11080
|
});
|
|
10986
11081
|
|
|
10987
11082
|
//
|
|
10988
11083
|
|
|
10989
|
-
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
10990
|
-
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
11084
|
+
const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
|
|
11085
|
+
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
|
|
10991
11086
|
|
|
10992
|
-
const logger$
|
|
11087
|
+
const logger$7 = IssueReporter$1.loggerFor('simple-ws-client');
|
|
10993
11088
|
|
|
10994
11089
|
class Websocket extends Emitter {
|
|
10995
11090
|
|
|
@@ -11003,9 +11098,9 @@ class Websocket extends Emitter {
|
|
|
11003
11098
|
// $FlowFixMe
|
|
11004
11099
|
this[key] = OTHER_EVENTS[key];
|
|
11005
11100
|
});
|
|
11006
|
-
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
11101
|
+
Object.keys(SOCKET_EVENTS$1).forEach(key => {
|
|
11007
11102
|
// $FlowFixMe
|
|
11008
|
-
this[key] = SOCKET_EVENTS[key];
|
|
11103
|
+
this[key] = SOCKET_EVENTS$1[key];
|
|
11009
11104
|
});
|
|
11010
11105
|
this.eventLists = WebSocketClient.eventLists;
|
|
11011
11106
|
|
|
@@ -11013,7 +11108,7 @@ class Websocket extends Emitter {
|
|
|
11013
11108
|
}
|
|
11014
11109
|
|
|
11015
11110
|
open(host , session ) {
|
|
11016
|
-
logger$
|
|
11111
|
+
logger$7.info('open simple WebSocket', { host, token: session.token });
|
|
11017
11112
|
this.ws = new WebSocketClient(
|
|
11018
11113
|
{
|
|
11019
11114
|
host,
|
|
@@ -11041,7 +11136,7 @@ class Websocket extends Emitter {
|
|
|
11041
11136
|
}
|
|
11042
11137
|
|
|
11043
11138
|
updateToken(token ) {
|
|
11044
|
-
logger$
|
|
11139
|
+
logger$7.info('update token via simple Websocket', { token, ws: !!this.ws });
|
|
11045
11140
|
|
|
11046
11141
|
if (!this.ws) {
|
|
11047
11142
|
return;
|
|
@@ -11069,7 +11164,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
|
|
|
11069
11164
|
|
|
11070
11165
|
//
|
|
11071
11166
|
|
|
11072
|
-
const logger$
|
|
11167
|
+
const logger$8 = IssueReporter$1.loggerFor('room');
|
|
11073
11168
|
|
|
11074
11169
|
class Participant extends Emitter {
|
|
11075
11170
|
|
|
@@ -11191,7 +11286,7 @@ class Participant extends Emitter {
|
|
|
11191
11286
|
}
|
|
11192
11287
|
|
|
11193
11288
|
onTalking(isTalking ) {
|
|
11194
|
-
logger$
|
|
11289
|
+
logger$8.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
|
|
11195
11290
|
this.isTalking = isTalking;
|
|
11196
11291
|
// you may notice we're not broadcasting: since all participants are getting this info
|
|
11197
11292
|
// directly from asterisk, there's no need to do so
|
|
@@ -11294,7 +11389,7 @@ class Participant extends Emitter {
|
|
|
11294
11389
|
}
|
|
11295
11390
|
|
|
11296
11391
|
updateStatus(status , broadcast = true) {
|
|
11297
|
-
logger$
|
|
11392
|
+
logger$8.info('updating participant status', { name: this.name, status });
|
|
11298
11393
|
|
|
11299
11394
|
if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
|
|
11300
11395
|
if (status.audioMuted) {
|
|
@@ -11342,7 +11437,7 @@ class Participant extends Emitter {
|
|
|
11342
11437
|
|
|
11343
11438
|
broadcastStatus(inboundStatus = null) {
|
|
11344
11439
|
const status = inboundStatus || this.getStatus();
|
|
11345
|
-
logger$
|
|
11440
|
+
logger$8.info('broadcasting participant status', { callId: this.callId, status });
|
|
11346
11441
|
|
|
11347
11442
|
this.room.sendSignal({
|
|
11348
11443
|
type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
|
|
@@ -11378,9 +11473,9 @@ class LocalParticipant extends Participant {
|
|
|
11378
11473
|
const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
11379
11474
|
const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
11380
11475
|
|
|
11381
|
-
const logger$
|
|
11476
|
+
const logger$9 = IssueReporter$1.loggerFor('sdk-room');
|
|
11382
11477
|
|
|
11383
|
-
class Room
|
|
11478
|
+
class Room extends Emitter {
|
|
11384
11479
|
|
|
11385
11480
|
|
|
11386
11481
|
|
|
@@ -11438,7 +11533,7 @@ class Room$1 extends Emitter {
|
|
|
11438
11533
|
extra = {},
|
|
11439
11534
|
) {
|
|
11440
11535
|
super();
|
|
11441
|
-
logger$
|
|
11536
|
+
logger$9.info('room initialized', { callId, extension, sourceId, meetingUuid });
|
|
11442
11537
|
|
|
11443
11538
|
// Represents the room callSession
|
|
11444
11539
|
this.callSession = callSession;
|
|
@@ -11504,7 +11599,7 @@ class Room$1 extends Emitter {
|
|
|
11504
11599
|
* @returns {Promise<Room>}
|
|
11505
11600
|
*/
|
|
11506
11601
|
static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
|
|
11507
|
-
logger$
|
|
11602
|
+
logger$9.info('connecting to room', { extension, audioOnly, room: !!room });
|
|
11508
11603
|
|
|
11509
11604
|
if (!room) {
|
|
11510
11605
|
await Wazo.Phone.connect();
|
|
@@ -11517,7 +11612,7 @@ class Room$1 extends Emitter {
|
|
|
11517
11612
|
|
|
11518
11613
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
11519
11614
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
|
|
11520
|
-
logger$
|
|
11615
|
+
logger$9.info('room call received via WS', { callId: data.call_id });
|
|
11521
11616
|
if (room) {
|
|
11522
11617
|
room.setCallId(data.call_id);
|
|
11523
11618
|
}
|
|
@@ -11525,7 +11620,7 @@ class Room$1 extends Emitter {
|
|
|
11525
11620
|
|
|
11526
11621
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
11527
11622
|
// eslint-disable-next-line no-param-reassign
|
|
11528
|
-
room = new Room
|
|
11623
|
+
room = new Room(callSession, extension, null, null, extra);
|
|
11529
11624
|
|
|
11530
11625
|
// Wait for the call to be accepted
|
|
11531
11626
|
await new Promise((resolve, reject) => {
|
|
@@ -11546,7 +11641,7 @@ class Room$1 extends Emitter {
|
|
|
11546
11641
|
// Retrieve conference
|
|
11547
11642
|
const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
|
|
11548
11643
|
|
|
11549
|
-
logger$
|
|
11644
|
+
logger$9.info('connected to room', {
|
|
11550
11645
|
sourceId: conference ? conference.sourceId : null,
|
|
11551
11646
|
name: conference ? conference.name : null,
|
|
11552
11647
|
});
|
|
@@ -11556,7 +11651,7 @@ class Room$1 extends Emitter {
|
|
|
11556
11651
|
room.setName(conference.name);
|
|
11557
11652
|
}
|
|
11558
11653
|
} else if (meeting) {
|
|
11559
|
-
logger$
|
|
11654
|
+
logger$9.info('Already connected to meeting', {
|
|
11560
11655
|
uuid: meeting.uuid,
|
|
11561
11656
|
name: meeting.name,
|
|
11562
11657
|
});
|
|
@@ -11569,13 +11664,13 @@ class Room$1 extends Emitter {
|
|
|
11569
11664
|
}
|
|
11570
11665
|
|
|
11571
11666
|
static disconnect() {
|
|
11572
|
-
logger$
|
|
11667
|
+
logger$9.info('static disconnection to room');
|
|
11573
11668
|
|
|
11574
11669
|
Wazo.Phone.disconnect();
|
|
11575
11670
|
}
|
|
11576
11671
|
|
|
11577
11672
|
async disconnect() {
|
|
11578
|
-
logger$
|
|
11673
|
+
logger$9.info('disconnection to room called');
|
|
11579
11674
|
|
|
11580
11675
|
await Wazo.Phone.hangup(this.callSession);
|
|
11581
11676
|
this.callSession = null;
|
|
@@ -11595,19 +11690,19 @@ class Room$1 extends Emitter {
|
|
|
11595
11690
|
}
|
|
11596
11691
|
|
|
11597
11692
|
setSourceId(sourceId ) {
|
|
11598
|
-
logger$
|
|
11693
|
+
logger$9.info('set room source id', { sourceId });
|
|
11599
11694
|
|
|
11600
11695
|
this.sourceId = sourceId;
|
|
11601
11696
|
}
|
|
11602
11697
|
|
|
11603
11698
|
setMeetingUuid(meetingUuid ) {
|
|
11604
|
-
logger$
|
|
11699
|
+
logger$9.info('set meeting uuid', { meetingUuid });
|
|
11605
11700
|
|
|
11606
11701
|
this.meetingUuid = meetingUuid;
|
|
11607
11702
|
}
|
|
11608
11703
|
|
|
11609
11704
|
setCallId(callId ) {
|
|
11610
|
-
logger$
|
|
11705
|
+
logger$9.info('set room call id', { callId });
|
|
11611
11706
|
|
|
11612
11707
|
if (callId) {
|
|
11613
11708
|
this.callId = callId;
|
|
@@ -11615,7 +11710,7 @@ class Room$1 extends Emitter {
|
|
|
11615
11710
|
}
|
|
11616
11711
|
|
|
11617
11712
|
setName(name ) {
|
|
11618
|
-
logger$
|
|
11713
|
+
logger$9.info('set room name', { name });
|
|
11619
11714
|
|
|
11620
11715
|
this.name = name;
|
|
11621
11716
|
}
|
|
@@ -11634,7 +11729,7 @@ class Room$1 extends Emitter {
|
|
|
11634
11729
|
}
|
|
11635
11730
|
|
|
11636
11731
|
async startScreenSharing(constraints ) {
|
|
11637
|
-
logger$
|
|
11732
|
+
logger$9.info('start room screen sharing', { constraints });
|
|
11638
11733
|
|
|
11639
11734
|
const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
|
|
11640
11735
|
if (!screensharingStream) {
|
|
@@ -11648,7 +11743,7 @@ class Room$1 extends Emitter {
|
|
|
11648
11743
|
}
|
|
11649
11744
|
|
|
11650
11745
|
async stopScreenSharing(restoreLocalStream = true) {
|
|
11651
|
-
logger$
|
|
11746
|
+
logger$9.info('stop room screen sharing');
|
|
11652
11747
|
|
|
11653
11748
|
await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
|
|
11654
11749
|
|
|
@@ -11660,7 +11755,7 @@ class Room$1 extends Emitter {
|
|
|
11660
11755
|
}
|
|
11661
11756
|
|
|
11662
11757
|
turnCameraOff() {
|
|
11663
|
-
logger$
|
|
11758
|
+
logger$9.info('turn room camera off');
|
|
11664
11759
|
|
|
11665
11760
|
Wazo.Phone.turnCameraOff(this.callSession);
|
|
11666
11761
|
|
|
@@ -11670,7 +11765,7 @@ class Room$1 extends Emitter {
|
|
|
11670
11765
|
}
|
|
11671
11766
|
|
|
11672
11767
|
turnCameraOn() {
|
|
11673
|
-
logger$
|
|
11768
|
+
logger$9.info('turn room camera on');
|
|
11674
11769
|
|
|
11675
11770
|
Wazo.Phone.turnCameraOn(this.callSession);
|
|
11676
11771
|
|
|
@@ -11680,7 +11775,7 @@ class Room$1 extends Emitter {
|
|
|
11680
11775
|
}
|
|
11681
11776
|
|
|
11682
11777
|
mute() {
|
|
11683
|
-
logger$
|
|
11778
|
+
logger$9.info('mute room');
|
|
11684
11779
|
|
|
11685
11780
|
Wazo.Phone.mute(this.callSession);
|
|
11686
11781
|
|
|
@@ -11688,7 +11783,7 @@ class Room$1 extends Emitter {
|
|
|
11688
11783
|
}
|
|
11689
11784
|
|
|
11690
11785
|
unmute() {
|
|
11691
|
-
logger$
|
|
11786
|
+
logger$9.info('unmute room');
|
|
11692
11787
|
|
|
11693
11788
|
Wazo.Phone.unmute(this.callSession);
|
|
11694
11789
|
|
|
@@ -11708,7 +11803,7 @@ class Room$1 extends Emitter {
|
|
|
11708
11803
|
}
|
|
11709
11804
|
|
|
11710
11805
|
hold() {
|
|
11711
|
-
logger$
|
|
11806
|
+
logger$9.info('hold room');
|
|
11712
11807
|
|
|
11713
11808
|
Wazo.Phone.hold(this.callSession, true);
|
|
11714
11809
|
|
|
@@ -11718,7 +11813,7 @@ class Room$1 extends Emitter {
|
|
|
11718
11813
|
}
|
|
11719
11814
|
|
|
11720
11815
|
async resume() {
|
|
11721
|
-
logger$
|
|
11816
|
+
logger$9.info('resume room');
|
|
11722
11817
|
|
|
11723
11818
|
const newStream = await Wazo.Phone.resume(this.callSession, true);
|
|
11724
11819
|
|
|
@@ -11746,13 +11841,13 @@ class Room$1 extends Emitter {
|
|
|
11746
11841
|
}
|
|
11747
11842
|
|
|
11748
11843
|
sendDTMF(tone ) {
|
|
11749
|
-
logger$
|
|
11844
|
+
logger$9.info('send room DTMF', { tone });
|
|
11750
11845
|
|
|
11751
11846
|
Wazo.Phone.sendDTMF(tone, this.callSession);
|
|
11752
11847
|
}
|
|
11753
11848
|
|
|
11754
11849
|
async sendReinvite(newConstraints = null) {
|
|
11755
|
-
logger$
|
|
11850
|
+
logger$9.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
|
|
11756
11851
|
const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
|
|
11757
11852
|
|
|
11758
11853
|
Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
|
|
@@ -11811,7 +11906,7 @@ class Room$1 extends Emitter {
|
|
|
11811
11906
|
Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
|
|
11812
11907
|
|
|
11813
11908
|
this.on(this.ON_AUDIO_STREAM, stream => {
|
|
11814
|
-
logger$
|
|
11909
|
+
logger$9.info('on room audio stream');
|
|
11815
11910
|
|
|
11816
11911
|
this.audioStream = stream;
|
|
11817
11912
|
if (!this.roomAudioElement) {
|
|
@@ -11824,7 +11919,7 @@ class Room$1 extends Emitter {
|
|
|
11824
11919
|
});
|
|
11825
11920
|
|
|
11826
11921
|
this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
|
|
11827
|
-
logger$
|
|
11922
|
+
logger$9.info('on room video stream', { streamId });
|
|
11828
11923
|
|
|
11829
11924
|
this._mapMsid(sipSession.body.body);
|
|
11830
11925
|
|
|
@@ -11839,7 +11934,7 @@ class Room$1 extends Emitter {
|
|
|
11839
11934
|
});
|
|
11840
11935
|
|
|
11841
11936
|
this.on(this.ON_REMOVE_STREAM, stream => {
|
|
11842
|
-
logger$
|
|
11937
|
+
logger$9.info('on room remove stream');
|
|
11843
11938
|
|
|
11844
11939
|
const participant = this.participants.find(someParticipant =>
|
|
11845
11940
|
someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
|
|
@@ -11971,7 +12066,7 @@ class Room$1 extends Emitter {
|
|
|
11971
12066
|
const requester = this._getParticipantFromCallId(origin.callId);
|
|
11972
12067
|
if (requester) {
|
|
11973
12068
|
// @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
|
|
11974
|
-
logger$
|
|
12069
|
+
logger$9.info('trigger room requester status', { origin });
|
|
11975
12070
|
requester.triggerUpdate('REQUESTER_UPDATE');
|
|
11976
12071
|
}
|
|
11977
12072
|
break;
|
|
@@ -12002,24 +12097,24 @@ class Room$1 extends Emitter {
|
|
|
12002
12097
|
|
|
12003
12098
|
// When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
|
|
12004
12099
|
if (participant.user_uuid === session.uuid) {
|
|
12005
|
-
logger$
|
|
12100
|
+
logger$9.info('room current user joined');
|
|
12006
12101
|
|
|
12007
12102
|
// Retrieve participants via an API calls
|
|
12008
12103
|
const conferenceId = this.sourceId || payload.data.conference_id;
|
|
12009
12104
|
let response;
|
|
12010
12105
|
try {
|
|
12011
12106
|
if (this.meetingUuid) {
|
|
12012
|
-
logger$
|
|
12107
|
+
logger$9.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
|
|
12013
12108
|
response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
|
|
12014
12109
|
} else {
|
|
12015
|
-
logger$
|
|
12110
|
+
logger$9.info('fetching conference participants', { conferenceId });
|
|
12016
12111
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
12017
12112
|
}
|
|
12018
12113
|
} catch (e) {
|
|
12019
|
-
logger$
|
|
12114
|
+
logger$9.error('room participants fetching, error', e);
|
|
12020
12115
|
}
|
|
12021
12116
|
if (response) {
|
|
12022
|
-
logger$
|
|
12117
|
+
logger$9.info('conference participants fetched', { nb: response.items.length });
|
|
12023
12118
|
participants = response.items.map(item => {
|
|
12024
12119
|
const isMe = item.call_id === this.callId;
|
|
12025
12120
|
|
|
@@ -12046,7 +12141,7 @@ class Room$1 extends Emitter {
|
|
|
12046
12141
|
? new Wazo.RemoteParticipant(this, participant)
|
|
12047
12142
|
: null;
|
|
12048
12143
|
|
|
12049
|
-
logger$
|
|
12144
|
+
logger$9.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
|
|
12050
12145
|
|
|
12051
12146
|
if (remoteParticipant) {
|
|
12052
12147
|
this.participants.push(remoteParticipant);
|
|
@@ -12211,12 +12306,12 @@ class Room$1 extends Emitter {
|
|
|
12211
12306
|
|
|
12212
12307
|
//
|
|
12213
12308
|
|
|
12214
|
-
const logger$
|
|
12309
|
+
const logger$a = IssueReporter$1.loggerFor('sdk-sip-room');
|
|
12215
12310
|
|
|
12216
|
-
class SipRoom extends Room
|
|
12311
|
+
class SipRoom extends Room {
|
|
12217
12312
|
|
|
12218
12313
|
static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
|
|
12219
|
-
logger$
|
|
12314
|
+
logger$a.info('connecting to sip room', { extension, audioOnly, room: !!room });
|
|
12220
12315
|
|
|
12221
12316
|
if (!room) {
|
|
12222
12317
|
await Wazo.Phone.connect();
|
|
@@ -12232,7 +12327,7 @@ class SipRoom extends Room$1 {
|
|
|
12232
12327
|
room.setCallId(room.callSession.call.id);
|
|
12233
12328
|
}
|
|
12234
12329
|
|
|
12235
|
-
logger$
|
|
12330
|
+
logger$a.info('connected to room', {
|
|
12236
12331
|
extension: room.extension,
|
|
12237
12332
|
});
|
|
12238
12333
|
|
|
@@ -12240,7 +12335,7 @@ class SipRoom extends Room$1 {
|
|
|
12240
12335
|
}
|
|
12241
12336
|
|
|
12242
12337
|
mute() {
|
|
12243
|
-
logger$
|
|
12338
|
+
logger$a.info('mute sip room');
|
|
12244
12339
|
|
|
12245
12340
|
Wazo.Phone.mute(this.callSession, false);
|
|
12246
12341
|
|
|
@@ -12248,7 +12343,7 @@ class SipRoom extends Room$1 {
|
|
|
12248
12343
|
}
|
|
12249
12344
|
|
|
12250
12345
|
unmute() {
|
|
12251
|
-
logger$
|
|
12346
|
+
logger$a.info('unmute sip room');
|
|
12252
12347
|
|
|
12253
12348
|
Wazo.Phone.unmute(this.callSession, false);
|
|
12254
12349
|
|
|
@@ -12532,7 +12627,7 @@ class NotificationOptions {
|
|
|
12532
12627
|
|
|
12533
12628
|
|
|
12534
12629
|
// Represents a conference room, like `9000`.
|
|
12535
|
-
class Room {
|
|
12630
|
+
class Room$1 {
|
|
12536
12631
|
|
|
12537
12632
|
|
|
12538
12633
|
|
|
@@ -12553,7 +12648,7 @@ class Room {
|
|
|
12553
12648
|
}
|
|
12554
12649
|
|
|
12555
12650
|
connect(callSession ) {
|
|
12556
|
-
return new Room({ ...this, connectedCallSession: callSession });
|
|
12651
|
+
return new Room$1({ ...this, connectedCallSession: callSession });
|
|
12557
12652
|
}
|
|
12558
12653
|
|
|
12559
12654
|
has(callSession ) {
|
|
@@ -12562,7 +12657,7 @@ class Room {
|
|
|
12562
12657
|
|
|
12563
12658
|
addParticipant(uuid , extension , talking = null) {
|
|
12564
12659
|
if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
|
|
12565
|
-
return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12660
|
+
return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
|
|
12566
12661
|
}
|
|
12567
12662
|
|
|
12568
12663
|
return this;
|
|
@@ -12581,7 +12676,7 @@ class Room {
|
|
|
12581
12676
|
updatedParticipants.push(participant);
|
|
12582
12677
|
}
|
|
12583
12678
|
|
|
12584
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12679
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12585
12680
|
}
|
|
12586
12681
|
|
|
12587
12682
|
updateParticipantByExtension(extension , participant , shouldAdd = false) {
|
|
@@ -12597,7 +12692,7 @@ class Room {
|
|
|
12597
12692
|
updatedParticipants.push(participant);
|
|
12598
12693
|
}
|
|
12599
12694
|
|
|
12600
|
-
return new Room({ ...this, participants: updatedParticipants });
|
|
12695
|
+
return new Room$1({ ...this, participants: updatedParticipants });
|
|
12601
12696
|
}
|
|
12602
12697
|
|
|
12603
12698
|
hasCallWithId(id ) {
|
|
@@ -12605,18 +12700,18 @@ class Room {
|
|
|
12605
12700
|
}
|
|
12606
12701
|
|
|
12607
12702
|
disconnect() {
|
|
12608
|
-
return new Room({ ...this, connectedCallSession: null });
|
|
12703
|
+
return new Room$1({ ...this, connectedCallSession: null });
|
|
12609
12704
|
}
|
|
12610
12705
|
|
|
12611
12706
|
removeParticipantWithUUID(uuid ) {
|
|
12612
|
-
return new Room({
|
|
12707
|
+
return new Room$1({
|
|
12613
12708
|
...this,
|
|
12614
12709
|
participants: this.participants.filter(participant => participant.uuid !== uuid),
|
|
12615
12710
|
});
|
|
12616
12711
|
}
|
|
12617
12712
|
|
|
12618
12713
|
removeParticipantWithExtension(extension ) {
|
|
12619
|
-
return new Room({
|
|
12714
|
+
return new Room$1({
|
|
12620
12715
|
...this,
|
|
12621
12716
|
participants: this.participants.filter(participant => participant.extension !== extension),
|
|
12622
12717
|
});
|
|
@@ -12627,7 +12722,7 @@ class Room {
|
|
|
12627
12722
|
}
|
|
12628
12723
|
|
|
12629
12724
|
static newFrom(room ) {
|
|
12630
|
-
return newFrom(room, Room);
|
|
12725
|
+
return newFrom(room, Room$1);
|
|
12631
12726
|
}
|
|
12632
12727
|
}
|
|
12633
12728
|
|
|
@@ -12934,11 +13029,11 @@ var wazoWebsocket = {
|
|
|
12934
13029
|
resolve();
|
|
12935
13030
|
};
|
|
12936
13031
|
|
|
12937
|
-
client.on(SOCKET_EVENTS
|
|
13032
|
+
client.on(SOCKET_EVENTS.ON_ERROR, error => {
|
|
12938
13033
|
handleError(`Connection error : ${error}`);
|
|
12939
13034
|
});
|
|
12940
13035
|
|
|
12941
|
-
client.on(SOCKET_EVENTS
|
|
13036
|
+
client.on(SOCKET_EVENTS.ON_OPEN, () => {
|
|
12942
13037
|
if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
|
|
12943
13038
|
client.setOnHeartbeatTimeout(() => {
|
|
12944
13039
|
handleError('No response to heartbeat');
|
|
@@ -13039,7 +13134,7 @@ var webrtc = {
|
|
|
13039
13134
|
}),
|
|
13040
13135
|
};
|
|
13041
13136
|
|
|
13042
|
-
const parseCandidate = line => {
|
|
13137
|
+
const parseCandidate$1 = line => {
|
|
13043
13138
|
let parts;
|
|
13044
13139
|
// Parse both variants.
|
|
13045
13140
|
if (line.indexOf('a=candidate:') === 0) {
|
|
@@ -13130,7 +13225,7 @@ var SymmetricNat = {
|
|
|
13130
13225
|
}
|
|
13131
13226
|
|
|
13132
13227
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
13133
|
-
const cand = parseCandidate(e.candidate.candidate);
|
|
13228
|
+
const cand = parseCandidate$1(e.candidate.candidate);
|
|
13134
13229
|
if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
|
|
13135
13230
|
candidates[cand.relatedPort].push(cand.port);
|
|
13136
13231
|
} else if (!e.candidate) {
|
|
@@ -13198,7 +13293,7 @@ var iceIpv4 = {
|
|
|
13198
13293
|
const rawCandidate = e.candidate.candidate;
|
|
13199
13294
|
if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
|
|
13200
13295
|
hasSrflxOrRelay = true;
|
|
13201
|
-
const candidate = parseCandidate(e.candidate.candidate);
|
|
13296
|
+
const candidate = parseCandidate$1(e.candidate.candidate);
|
|
13202
13297
|
ips.push(candidate.ip);
|
|
13203
13298
|
}
|
|
13204
13299
|
} else if (!e.candidate) {
|
|
@@ -13235,7 +13330,7 @@ var checks = [
|
|
|
13235
13330
|
|
|
13236
13331
|
//
|
|
13237
13332
|
|
|
13238
|
-
const logger$
|
|
13333
|
+
const logger$b = IssueReporter$1.loggerFor('engine-check');
|
|
13239
13334
|
|
|
13240
13335
|
class Checker {
|
|
13241
13336
|
|
|
@@ -13253,28 +13348,28 @@ class Checker {
|
|
|
13253
13348
|
async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
|
|
13254
13349
|
await this._addEngineVersion();
|
|
13255
13350
|
|
|
13256
|
-
logger$
|
|
13351
|
+
logger$b.info('Engine check starting');
|
|
13257
13352
|
|
|
13258
13353
|
for (let i = 0; i < this.checks.length; i++) {
|
|
13259
13354
|
const { name, check } = this.checks[i];
|
|
13260
13355
|
|
|
13261
|
-
logger$
|
|
13356
|
+
logger$b.info(`Checking ${name} ...`);
|
|
13262
13357
|
|
|
13263
13358
|
onCheckBegin(name);
|
|
13264
13359
|
try {
|
|
13265
13360
|
// eslint-disable-next-line no-await-in-loop
|
|
13266
13361
|
const result = await check(this.server, this.session, this.externalAppConfig);
|
|
13267
|
-
logger$
|
|
13362
|
+
logger$b.info(`Checking ${name} success.`, { result });
|
|
13268
13363
|
|
|
13269
13364
|
onCheckResult(name, result);
|
|
13270
13365
|
} catch (e) {
|
|
13271
|
-
logger$
|
|
13366
|
+
logger$b.info(`Checking ${name} failure`, { message: e.message });
|
|
13272
13367
|
|
|
13273
13368
|
onCheckResult(name, e);
|
|
13274
13369
|
}
|
|
13275
13370
|
}
|
|
13276
13371
|
|
|
13277
|
-
logger$
|
|
13372
|
+
logger$b.info('Engine check done.');
|
|
13278
13373
|
}
|
|
13279
13374
|
|
|
13280
13375
|
addCheck(check ) {
|
|
@@ -13298,7 +13393,7 @@ const Wazo = {
|
|
|
13298
13393
|
Auth: Auth$1,
|
|
13299
13394
|
Phone: Phone$1,
|
|
13300
13395
|
Websocket: Websocket$1,
|
|
13301
|
-
Room
|
|
13396
|
+
Room,
|
|
13302
13397
|
SipRoom,
|
|
13303
13398
|
RemoteParticipant,
|
|
13304
13399
|
LocalParticipant,
|
|
@@ -13331,7 +13426,7 @@ const Wazo = {
|
|
|
13331
13426
|
Session,
|
|
13332
13427
|
Voicemail,
|
|
13333
13428
|
Relocation,
|
|
13334
|
-
ConferenceRoom: Room,
|
|
13429
|
+
ConferenceRoom: Room$1,
|
|
13335
13430
|
CallSession,
|
|
13336
13431
|
IndirectTransfer,
|
|
13337
13432
|
SwitchboardCall,
|
|
@@ -13370,7 +13465,7 @@ if (global) {
|
|
|
13370
13465
|
class InvalidSubscription extends Error {}
|
|
13371
13466
|
class InvalidAuthorization extends Error {}
|
|
13372
13467
|
|
|
13373
|
-
const logger = IssueReporter$1.loggerFor('simple-auth');
|
|
13468
|
+
const logger$c = IssueReporter$1.loggerFor('simple-auth');
|
|
13374
13469
|
|
|
13375
13470
|
class Auth {
|
|
13376
13471
|
|
|
@@ -13405,7 +13500,7 @@ class Auth {
|
|
|
13405
13500
|
setApiClientId(this.clientId);
|
|
13406
13501
|
setRefreshExpiration(this.expiration);
|
|
13407
13502
|
setOnRefreshToken((token , session ) => {
|
|
13408
|
-
logger.info('on refresh token done', { token });
|
|
13503
|
+
logger$c.info('on refresh token done', { token });
|
|
13409
13504
|
setApiToken(token);
|
|
13410
13505
|
Wazo.Websocket.updateToken(token);
|
|
13411
13506
|
|
|
@@ -13450,7 +13545,7 @@ class Auth {
|
|
|
13450
13545
|
const rawSession = await getApiClient().auth.authenticate(token);
|
|
13451
13546
|
return this._onAuthenticated(rawSession);
|
|
13452
13547
|
} catch (e) {
|
|
13453
|
-
logger.error('on validate token error', e);
|
|
13548
|
+
logger$c.error('on validate token error', e);
|
|
13454
13549
|
console.warn(e);
|
|
13455
13550
|
return false;
|
|
13456
13551
|
}
|