@wazo/sdk 0.43.8 → 0.43.10
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/domain/Phone/WebRTCPhone.js +32 -27
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +1 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts +1 -1
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/web-rtc-client.js +35 -28
- package/lib/domain/Phone/WebRTCPhone.js +32 -27
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +1 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts +1 -1
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/web-rtc-client.js +35 -28
- package/package.json +1 -1
- package/src/domain/Phone/WebRTCPhone.ts +34 -29
- package/src/web-rtc-client.ts +37 -30
|
@@ -159,7 +159,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
159
159
|
async sendReinvite(callSession?: CallSession, constraints: Record<string, any> | null | undefined = null, conference = false, audioOnly = false, iceRestart = false): Promise<OutgoingInviteRequest | void> {
|
|
160
160
|
const sipSession = this.findSipSession(callSession);
|
|
161
161
|
logger.info('WebRTC phone - send reinvite', {
|
|
162
|
-
sessionId: sipSession
|
|
162
|
+
sessionId: this.getSipSessionId(sipSession),
|
|
163
163
|
constraints,
|
|
164
164
|
audioOnly,
|
|
165
165
|
conference,
|
|
@@ -380,7 +380,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
380
380
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
381
381
|
const callSession = this._createCallSession(sipSession);
|
|
382
382
|
|
|
383
|
-
|
|
383
|
+
if (sipSessionId) {
|
|
384
|
+
delete this.callSessions[sipSessionId];
|
|
385
|
+
}
|
|
384
386
|
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
385
387
|
};
|
|
386
388
|
}
|
|
@@ -389,7 +391,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
389
391
|
switch (newState) {
|
|
390
392
|
case SessionState.Terminating:
|
|
391
393
|
logger.info('WebRTC phone - call terminating', {
|
|
392
|
-
sipId: sipSession
|
|
394
|
+
sipId: this.getSipSessionId(sipSession),
|
|
393
395
|
});
|
|
394
396
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
395
397
|
break;
|
|
@@ -397,7 +399,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
397
399
|
case SessionState.Terminated:
|
|
398
400
|
{
|
|
399
401
|
logger.info('WebRTC phone - call terminated', {
|
|
400
|
-
sipId: sipSession
|
|
402
|
+
sipId: this.getSipSessionId(sipSession),
|
|
401
403
|
});
|
|
402
404
|
|
|
403
405
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
@@ -580,7 +582,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
580
582
|
|
|
581
583
|
_onCallAccepted(sipSession: WazoSession, cameraEnabled: boolean): CallSession {
|
|
582
584
|
logger.info('WebRTC phone - on call accepted', {
|
|
583
|
-
sipId: sipSession
|
|
585
|
+
sipId: this.getSipSessionId(sipSession),
|
|
584
586
|
cameraEnabled,
|
|
585
587
|
});
|
|
586
588
|
|
|
@@ -588,7 +590,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
588
590
|
|
|
589
591
|
if (this.currentSipSession && !this.isCurrentCallSipSession(callSession)) {
|
|
590
592
|
logger.info('WebRTC phone - on call accepted with another ongoing call, holding it', {
|
|
591
|
-
sipId: sipSession
|
|
593
|
+
sipId: this.getSipSessionId(sipSession),
|
|
592
594
|
cameraEnabled,
|
|
593
595
|
});
|
|
594
596
|
|
|
@@ -673,7 +675,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
673
675
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
674
676
|
|
|
675
677
|
logger.info('WebRTC phone - on call terminated', {
|
|
676
|
-
sipId: sipSession
|
|
678
|
+
sipId: this.getSipSessionId(sipSession),
|
|
677
679
|
sipSessionId,
|
|
678
680
|
ids: Object.keys(this.callSessions),
|
|
679
681
|
});
|
|
@@ -697,9 +699,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
697
699
|
|
|
698
700
|
if (sipSessionId) {
|
|
699
701
|
this.removeIncomingSessions(sipSessionId);
|
|
700
|
-
}
|
|
701
702
|
|
|
702
|
-
|
|
703
|
+
delete this.callSessions[sipSessionId];
|
|
704
|
+
}
|
|
703
705
|
|
|
704
706
|
if (isCurrentSession) {
|
|
705
707
|
this.currentSipSession = undefined;
|
|
@@ -709,7 +711,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
709
711
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
710
712
|
// Re-trigger incoming call event for remaining incoming calls
|
|
711
713
|
logger.info('WebRTC phone - check to re-trigger incoming call', {
|
|
712
|
-
sipId: sipSession
|
|
714
|
+
sipId: this.getSipSessionId(sipSession),
|
|
713
715
|
shouldRetrigger,
|
|
714
716
|
hasIncomingCallSession,
|
|
715
717
|
});
|
|
@@ -853,7 +855,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
853
855
|
const sipSession = this.client.getSipSession(callSession.getId()) as Invitation;
|
|
854
856
|
|
|
855
857
|
if (sipSession) {
|
|
856
|
-
logger.info('accept call, session found', { sipId: sipSession
|
|
858
|
+
logger.info('accept call, session found', { sipId: this.getSipSessionId(sipSession) });
|
|
857
859
|
|
|
858
860
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
859
861
|
return callSession.sipCallId;
|
|
@@ -898,7 +900,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
898
900
|
|
|
899
901
|
if (sipSession) {
|
|
900
902
|
logger.info('WebRTC rejecting', {
|
|
901
|
-
sipId: sipSession
|
|
903
|
+
sipId: this.getSipSessionId(sipSession),
|
|
902
904
|
});
|
|
903
905
|
this.client.hangup(sipSession);
|
|
904
906
|
}
|
|
@@ -919,7 +921,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
919
921
|
|
|
920
922
|
if (sipSession) {
|
|
921
923
|
logger.info('WebRTC atxfer', {
|
|
922
|
-
sipId: sipSession
|
|
924
|
+
sipId: this.getSipSessionId(sipSession),
|
|
923
925
|
});
|
|
924
926
|
return this.client.atxfer(sipSession);
|
|
925
927
|
}
|
|
@@ -950,13 +952,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
950
952
|
}
|
|
951
953
|
|
|
952
954
|
logger.info('WebRTC resuming', {
|
|
953
|
-
sipId: sipSession
|
|
955
|
+
sipId: this.getSipSessionId(sipSession),
|
|
954
956
|
});
|
|
955
957
|
|
|
956
958
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
957
|
-
if (this.currentSipSession && this.currentSipSession
|
|
959
|
+
if (this.currentSipSession && this.getSipSessionId(this.currentSipSession) !== this.getSipSessionId(sipSession)) {
|
|
958
960
|
logger.info('WebRTC hold call after resume', {
|
|
959
|
-
id: this.currentSipSession
|
|
961
|
+
id: this.getSipSessionId(this.currentSipSession),
|
|
960
962
|
});
|
|
961
963
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, withEvent);
|
|
962
964
|
}
|
|
@@ -979,7 +981,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
979
981
|
const sessionId = this.getSipSessionId(sipSession);
|
|
980
982
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
981
983
|
logger.info('WebRTC hold sip session', {
|
|
982
|
-
sipId: sipSession
|
|
984
|
+
sipId: this.getSipSessionId(sipSession),
|
|
983
985
|
hasVideo,
|
|
984
986
|
});
|
|
985
987
|
|
|
@@ -1076,7 +1078,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1076
1078
|
}
|
|
1077
1079
|
|
|
1078
1080
|
logger.info('WebRTC muting', {
|
|
1079
|
-
sipId: sipSession
|
|
1081
|
+
sipId: this.getSipSessionId(sipSession),
|
|
1080
1082
|
});
|
|
1081
1083
|
this.client.mute(sipSession);
|
|
1082
1084
|
|
|
@@ -1104,7 +1106,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1104
1106
|
}
|
|
1105
1107
|
|
|
1106
1108
|
logger.info('WebRTC unmuting', {
|
|
1107
|
-
sipId: sipSession
|
|
1109
|
+
sipId: this.getSipSessionId(sipSession),
|
|
1108
1110
|
});
|
|
1109
1111
|
this.client.unmute(sipSession);
|
|
1110
1112
|
|
|
@@ -1139,7 +1141,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1139
1141
|
}
|
|
1140
1142
|
|
|
1141
1143
|
logger.info('WebRTC turn camera on', {
|
|
1142
|
-
sipId: sipSession
|
|
1144
|
+
sipId: this.getSipSessionId(sipSession),
|
|
1143
1145
|
});
|
|
1144
1146
|
this.client.toggleCameraOn(sipSession);
|
|
1145
1147
|
this.eventEmitter.emit(ON_CAMERA_RESUMED, this._createCameraResumedCallSession(sipSession, callSession));
|
|
@@ -1153,7 +1155,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1153
1155
|
}
|
|
1154
1156
|
|
|
1155
1157
|
logger.info('WebRTC turn camera off', {
|
|
1156
|
-
sipId: sipSession
|
|
1158
|
+
sipId: this.getSipSessionId(sipSession),
|
|
1157
1159
|
});
|
|
1158
1160
|
this.client.toggleCameraOff(sipSession);
|
|
1159
1161
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -1167,7 +1169,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1167
1169
|
}
|
|
1168
1170
|
|
|
1169
1171
|
logger.info('WebRTC send key', {
|
|
1170
|
-
sipId: sipSession
|
|
1172
|
+
sipId: this.getSipSessionId(sipSession),
|
|
1171
1173
|
tone,
|
|
1172
1174
|
});
|
|
1173
1175
|
this.client.sendDTMF(sipSession, tone);
|
|
@@ -1245,7 +1247,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1245
1247
|
}
|
|
1246
1248
|
|
|
1247
1249
|
logger.info('WebRTC transfer', {
|
|
1248
|
-
sipId: sipSession
|
|
1250
|
+
sipId: this.getSipSessionId(sipSession),
|
|
1249
1251
|
target,
|
|
1250
1252
|
});
|
|
1251
1253
|
this.client.transfer(sipSession, target);
|
|
@@ -1255,8 +1257,8 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1255
1257
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
1256
1258
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
1257
1259
|
logger.info('WebRTC indirect transfer', {
|
|
1258
|
-
sipId: sipSession ? sipSession
|
|
1259
|
-
target: sipSessionTarget ? sipSessionTarget
|
|
1260
|
+
sipId: sipSession ? this.getSipSessionId(sipSession) : null,
|
|
1261
|
+
target: sipSessionTarget ? this.getSipSessionId(sipSessionTarget) : null,
|
|
1260
1262
|
});
|
|
1261
1263
|
|
|
1262
1264
|
if (!sipSessionTarget) {
|
|
@@ -1295,7 +1297,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1295
1297
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
1296
1298
|
|
|
1297
1299
|
logger.info('WebRTC hangup', {
|
|
1298
|
-
sipId: sipSession
|
|
1300
|
+
sipId: this.getSipSessionId(sipSession),
|
|
1299
1301
|
sipSessionId,
|
|
1300
1302
|
});
|
|
1301
1303
|
await this.client.hangup(sipSession);
|
|
@@ -1484,7 +1486,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1484
1486
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
1485
1487
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
1486
1488
|
logger.info('WebRTC invite received', {
|
|
1487
|
-
sipId: sipSession
|
|
1489
|
+
sipId: this.getSipSessionId(sipSession),
|
|
1488
1490
|
withVideo,
|
|
1489
1491
|
autoAnswer,
|
|
1490
1492
|
});
|
|
@@ -1555,7 +1557,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1555
1557
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
1556
1558
|
});
|
|
1557
1559
|
this.client.on(this.client.REJECTED, session => {
|
|
1558
|
-
logger.info('WebRTC call rejected', session
|
|
1560
|
+
logger.info('WebRTC call rejected', { id: this.getSipSessionId(session) });
|
|
1559
1561
|
|
|
1560
1562
|
const callSession = this._createCallSession(session);
|
|
1561
1563
|
|
|
@@ -1687,7 +1689,10 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1687
1689
|
return this.callSessions[sipSessionId];
|
|
1688
1690
|
}
|
|
1689
1691
|
|
|
1690
|
-
getSipSessionId(sipSession: WazoSession): string {
|
|
1692
|
+
getSipSessionId(sipSession: WazoSession | null | undefined): string {
|
|
1693
|
+
if (!sipSession) {
|
|
1694
|
+
return '';
|
|
1695
|
+
}
|
|
1691
1696
|
return this.client.getSipSessionId(sipSession);
|
|
1692
1697
|
}
|
|
1693
1698
|
|
package/src/web-rtc-client.ts
CHANGED
|
@@ -7,7 +7,6 @@ import type { InvitationRejectOptions } from 'sip.js/lib/api/invitation-reject-o
|
|
|
7
7
|
import type { InviterCancelOptions } from 'sip.js/lib/api/inviter-cancel-options';
|
|
8
8
|
import type { SessionByeOptions } from 'sip.js/lib/api/session-bye-options';
|
|
9
9
|
import type { InvitationAcceptOptions } from 'sip.js/lib/api/invitation-accept-options';
|
|
10
|
-
import type { SessionDialog } from 'sip.js/lib/core/dialogs/session-dialog';
|
|
11
10
|
import type { IncomingRequestMessage } from 'sip.js/lib/core/messages/incoming-request-message';
|
|
12
11
|
import type { SessionDescriptionHandlerFactoryOptions } from 'sip.js/lib/platform/web/session-description-handler/session-description-handler-factory-options';
|
|
13
12
|
import type { SessionDescriptionHandlerConfiguration } from 'sip.js/lib/platform/web/session-description-handler/session-description-handler-configuration';
|
|
@@ -18,6 +17,7 @@ import { C } from 'sip.js/lib/core/messages/methods/constants';
|
|
|
18
17
|
import { URI } from 'sip.js/lib/grammar/uri';
|
|
19
18
|
import { UserAgent } from 'sip.js/lib/api/user-agent';
|
|
20
19
|
import { holdModifier, stripVideo } from 'sip.js/lib/platform/web/modifiers/modifiers';
|
|
20
|
+
import { SessionDialog } from 'sip.js/lib/core/dialogs/session-dialog';
|
|
21
21
|
|
|
22
22
|
import { Messager } from 'sip.js/lib/api/messager';
|
|
23
23
|
import { RegistererState } from 'sip.js/lib/api/registerer-state';
|
|
@@ -42,7 +42,6 @@ export const replaceLocalIpModifier = (description: Record<string, any>) => Prom
|
|
|
42
42
|
...JSON.parse(JSON.stringify(description)),
|
|
43
43
|
sdp: description.sdp.replace('c=IN IP4 0.0.0.0', 'c=IN IP4 127.0.0.1'),
|
|
44
44
|
});
|
|
45
|
-
const SIP_ID_LENGTH = 36;
|
|
46
45
|
const DEFAULT_ICE_TIMEOUT = 3000;
|
|
47
46
|
const SEND_STATS_DELAY = 5000;
|
|
48
47
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
@@ -268,7 +267,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
268
267
|
logger.info('sdk webrtc on invite', {
|
|
269
268
|
method: 'delegate.onInvite',
|
|
270
269
|
clientId: this.clientId,
|
|
271
|
-
id: invitation
|
|
270
|
+
id: this.getSipSessionId(invitation),
|
|
272
271
|
remoteURI: (invitation as any).remoteURI,
|
|
273
272
|
});
|
|
274
273
|
|
|
@@ -604,7 +603,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
604
603
|
},
|
|
605
604
|
onReject: (response: IncomingResponse) => {
|
|
606
605
|
logger.info('on call rejected', {
|
|
607
|
-
id: session
|
|
606
|
+
id: this.getSipSessionId(session),
|
|
608
607
|
// @ts-ignore: fromTag does not exist
|
|
609
608
|
fromTag: session?.fromTag,
|
|
610
609
|
});
|
|
@@ -641,7 +640,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
641
640
|
answer(session: Invitation, enableVideo?: boolean): Promise<void> {
|
|
642
641
|
logger.info('sdk webrtc answer call', {
|
|
643
642
|
clientId: this.clientId,
|
|
644
|
-
id: session
|
|
643
|
+
id: this.getSipSessionId(session),
|
|
645
644
|
enableVideo,
|
|
646
645
|
});
|
|
647
646
|
|
|
@@ -659,7 +658,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
659
658
|
if (session.isCanceled) {
|
|
660
659
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
661
660
|
logger.error(message, {
|
|
662
|
-
id: session
|
|
661
|
+
id: this.getSipSessionId(session),
|
|
663
662
|
});
|
|
664
663
|
this.onCallEnded(session);
|
|
665
664
|
throw new CanceledCallError(message);
|
|
@@ -669,7 +668,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
669
668
|
|
|
670
669
|
this._onAccepted(session);
|
|
671
670
|
}).catch(e => {
|
|
672
|
-
logger.error(`answer call error for ${session
|
|
671
|
+
logger.error(`answer call error for ${this.getSipSessionId(session)}`, e);
|
|
673
672
|
throw e;
|
|
674
673
|
});
|
|
675
674
|
}
|
|
@@ -747,7 +746,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
747
746
|
async reject(session: WazoSession): Promise<void> {
|
|
748
747
|
logger.info('sdk webrtc reject call', {
|
|
749
748
|
clientId: this.clientId,
|
|
750
|
-
id: session
|
|
749
|
+
id: this.getSipSessionId(session),
|
|
751
750
|
});
|
|
752
751
|
|
|
753
752
|
try {
|
|
@@ -819,7 +818,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
819
818
|
|
|
820
819
|
mute(session: WazoSession): void {
|
|
821
820
|
logger.info('sdk webrtc mute', {
|
|
822
|
-
id: session
|
|
821
|
+
id: this.getSipSessionId(session),
|
|
823
822
|
});
|
|
824
823
|
|
|
825
824
|
this._toggleAudio(session, true);
|
|
@@ -827,7 +826,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
827
826
|
|
|
828
827
|
unmute(session: WazoSession): void {
|
|
829
828
|
logger.info('sdk webrtc unmute', {
|
|
830
|
-
id: session
|
|
829
|
+
id: this.getSipSessionId(session),
|
|
831
830
|
});
|
|
832
831
|
|
|
833
832
|
this._toggleAudio(session, false);
|
|
@@ -872,7 +871,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
872
871
|
|
|
873
872
|
toggleCameraOn(session: WazoSession): void {
|
|
874
873
|
logger.info('sdk webrtc toggle camera on', {
|
|
875
|
-
id: session
|
|
874
|
+
id: this.getSipSessionId(session),
|
|
876
875
|
});
|
|
877
876
|
|
|
878
877
|
this._toggleVideo(session, false);
|
|
@@ -880,7 +879,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
880
879
|
|
|
881
880
|
toggleCameraOff(session: WazoSession): void {
|
|
882
881
|
logger.info('sdk webrtc toggle camera off', {
|
|
883
|
-
id: session
|
|
882
|
+
id: this.getSipSessionId(session),
|
|
884
883
|
});
|
|
885
884
|
|
|
886
885
|
this._toggleVideo(session, true);
|
|
@@ -1178,7 +1177,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
1178
1177
|
}
|
|
1179
1178
|
|
|
1180
1179
|
logger.info('send WebRTC message', {
|
|
1181
|
-
sipId: sipSession
|
|
1180
|
+
sipId: this.getSipSessionId(sipSession),
|
|
1182
1181
|
contentType,
|
|
1183
1182
|
});
|
|
1184
1183
|
|
|
@@ -1611,20 +1610,28 @@ export default class WebRTCClient extends Emitter {
|
|
|
1611
1610
|
return '';
|
|
1612
1611
|
}
|
|
1613
1612
|
|
|
1614
|
-
const message = sipSession.message as Partial<{ callId?: string }>;
|
|
1615
|
-
if (message?.callId) {
|
|
1616
|
-
return message.callId.substring(0, SIP_ID_LENGTH);
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
1613
|
// For Inviter
|
|
1620
1614
|
// @ts-ignore: private
|
|
1621
1615
|
if (sipSession instanceof Inviter && sipSession.outgoingRequestMessage) {
|
|
1622
1616
|
// @ts-ignore: private
|
|
1623
|
-
return sipSession.outgoingRequestMessage.callId
|
|
1617
|
+
return sipSession.outgoingRequestMessage.callId;
|
|
1624
1618
|
}
|
|
1625
1619
|
|
|
1626
1620
|
// For Invitation
|
|
1627
|
-
|
|
1621
|
+
// @ts-ignore: private
|
|
1622
|
+
if (sipSession instanceof Invitation && sipSession.incomingInviteRequest.message) {
|
|
1623
|
+
// @ts-ignore: private
|
|
1624
|
+
return sipSession.incomingInviteRequest.message.callId;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
// For EarlyMedia
|
|
1628
|
+
// @ts-ignore: private
|
|
1629
|
+
if (sipSession instanceof SessionDialog) {
|
|
1630
|
+
// @ts-ignore: private
|
|
1631
|
+
return sipSession.dialogState.callId;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
return '';
|
|
1628
1635
|
}
|
|
1629
1636
|
|
|
1630
1637
|
async waitForRegister(): Promise<void> {
|
|
@@ -1704,7 +1711,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
1704
1711
|
}
|
|
1705
1712
|
|
|
1706
1713
|
getSipSession(id: string): WazoSession | null | undefined {
|
|
1707
|
-
return id in this.sipSessions ? this.sipSessions[id
|
|
1714
|
+
return id in this.sipSessions ? this.sipSessions[id] : null;
|
|
1708
1715
|
}
|
|
1709
1716
|
|
|
1710
1717
|
getSipSessionIds(): string[] {
|
|
@@ -2168,7 +2175,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2168
2175
|
async _onProgress(session: WazoSession, early = false): Promise<void> {
|
|
2169
2176
|
await this._setupMedias(session);
|
|
2170
2177
|
|
|
2171
|
-
const sessionId = this.getSipSessionId(session)
|
|
2178
|
+
const sessionId = this.getSipSessionId(session);
|
|
2172
2179
|
this.updateRemoteStream(sessionId);
|
|
2173
2180
|
logger.info('progress received', {
|
|
2174
2181
|
sessionId,
|
|
@@ -2179,7 +2186,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2179
2186
|
|
|
2180
2187
|
async _onAccepted(session: WazoSession, sessionDialog?: SessionDialog, withEvent = true, initAllTracks = true): Promise<void> {
|
|
2181
2188
|
logger.info('on call accepted', {
|
|
2182
|
-
id: session
|
|
2189
|
+
id: this.getSipSessionId(session),
|
|
2183
2190
|
clientId: this.clientId,
|
|
2184
2191
|
remoteTag: session.remoteTag,
|
|
2185
2192
|
});
|
|
@@ -2610,20 +2617,20 @@ export default class WebRTCClient extends Emitter {
|
|
|
2610
2617
|
async _accept(session: Invitation, options: InvitationAcceptOptions = {}) {
|
|
2611
2618
|
if (session.state === SessionState.Terminated || session.state === SessionState.Terminating) {
|
|
2612
2619
|
const error = 'Trying to accept a terminated sipSession.';
|
|
2613
|
-
logger.warn(error, { state: session.state, sessionId: session
|
|
2620
|
+
logger.warn(error, { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2614
2621
|
throw new Error(error);
|
|
2615
2622
|
}
|
|
2616
2623
|
|
|
2617
2624
|
if (session.state !== SessionState.Initial) {
|
|
2618
2625
|
const error = 'Trying to accept a non Initial sipSession.';
|
|
2619
|
-
logger.warn(error, { state: session.state, sessionId: session
|
|
2626
|
+
logger.warn(error, { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2620
2627
|
throw new Error(error);
|
|
2621
2628
|
}
|
|
2622
2629
|
|
|
2623
2630
|
// @ts-ignore: private
|
|
2624
2631
|
if (!session.incomingInviteRequest.acceptable) {
|
|
2625
2632
|
const error = 'Trying to reject a non `acceptable` session';
|
|
2626
|
-
logger.warn(error, { state: session.state, sessionId: session
|
|
2633
|
+
logger.warn(error, { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2627
2634
|
throw new Error(error);
|
|
2628
2635
|
}
|
|
2629
2636
|
|
|
@@ -2636,13 +2643,13 @@ export default class WebRTCClient extends Emitter {
|
|
|
2636
2643
|
|
|
2637
2644
|
async _reject(session: Invitation, options: InvitationRejectOptions = {}) {
|
|
2638
2645
|
if (session.state !== SessionState.Initial && session.state !== SessionState.Establishing) {
|
|
2639
|
-
logger.warn('Trying to reject a session in a wrong state', { state: session.state, sessionId: session
|
|
2646
|
+
logger.warn('Trying to reject a session in a wrong state', { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2640
2647
|
return;
|
|
2641
2648
|
}
|
|
2642
2649
|
|
|
2643
2650
|
// @ts-ignore: private
|
|
2644
2651
|
if (!session.incomingInviteRequest.rejectable) {
|
|
2645
|
-
logger.warn('Trying to reject a non `rejectable` session', { state: session.state, sessionId: session
|
|
2652
|
+
logger.warn('Trying to reject a non `rejectable` session', { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2646
2653
|
return;
|
|
2647
2654
|
}
|
|
2648
2655
|
|
|
@@ -2655,7 +2662,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2655
2662
|
|
|
2656
2663
|
async _cancel(session: Inviter, options: InviterCancelOptions = {}) {
|
|
2657
2664
|
if (session.state !== SessionState.Initial && session.state !== SessionState.Establishing) {
|
|
2658
|
-
logger.warn('Trying to cancel a session in a wrong state', { state: session.state, sessionId: session
|
|
2665
|
+
logger.warn('Trying to cancel a session in a wrong state', { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2659
2666
|
return;
|
|
2660
2667
|
}
|
|
2661
2668
|
|
|
@@ -2668,7 +2675,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
2668
2675
|
|
|
2669
2676
|
async _bye(session: WazoSession, options: SessionByeOptions = {}) {
|
|
2670
2677
|
if (session.state !== SessionState.Established) {
|
|
2671
|
-
logger.warn('Trying to end a session in a wrong state', { state: session.state, sessionId: session
|
|
2678
|
+
logger.warn('Trying to end a session in a wrong state', { state: session.state, sessionId: this.getSipSessionId(session) });
|
|
2672
2679
|
return null;
|
|
2673
2680
|
}
|
|
2674
2681
|
|