@wazo/sdk 1.0.0-alpha.2 → 1.0.0-alpha.20
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/README.md +16 -7
- package/dist/wazo-sdk.js +2 -2
- package/esm/__tests__/__voice__/call.test.js +52 -3
- package/esm/api/auth.js +3 -0
- package/esm/checker/checks/webrtc.js +2 -2
- package/esm/domain/CallLog.js +2 -3
- package/esm/domain/Phone/CTIPhone.js +2 -2
- package/esm/domain/Phone/WebRTCPhone.js +59 -57
- package/esm/index.js +3 -1
- package/esm/service/CallApi.js +4 -4
- package/esm/simple/Auth.js +13 -3
- package/esm/simple/Phone.js +5 -5
- package/esm/simple/index.js +2 -1
- package/esm/simple/room/Room.js +2 -2
- package/esm/simple/room/SipRoom.js +2 -2
- package/esm/state-machine/call-state-machine.js +34 -19
- package/esm/state-machine/softphone-state-machine.js +1 -2
- package/esm/state-machine/utils.js +10 -4
- package/esm/types/api/auth.d.ts +3 -0
- package/esm/types/api/auth.d.ts.map +1 -1
- package/esm/types/checker/checks/index.d.ts +1 -1
- package/esm/types/checker/checks/webrtc-transport.d.ts +2 -2
- package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -1
- package/esm/types/domain/CallLog.d.ts.map +1 -1
- package/esm/types/domain/CallSession.d.ts +3 -3
- package/esm/types/domain/CallSession.d.ts.map +1 -1
- package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +22 -22
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/esm/types/domain/types.d.ts +0 -4
- package/esm/types/domain/types.d.ts.map +1 -1
- package/esm/types/index.d.ts +3 -1
- package/esm/types/index.d.ts.map +1 -1
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +3 -3
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/esm/types/service/CallApi.d.ts +5 -5
- package/esm/types/service/CallApi.d.ts.map +1 -1
- package/esm/types/simple/Auth.d.ts +6 -1
- package/esm/types/simple/Auth.d.ts.map +1 -1
- package/esm/types/simple/Phone.d.ts +8 -8
- package/esm/types/simple/Phone.d.ts.map +1 -1
- package/esm/types/simple/index.d.ts +3 -1
- package/esm/types/simple/index.d.ts.map +1 -1
- package/esm/types/state-machine/call-state-machine.d.ts +12 -1
- package/esm/types/state-machine/call-state-machine.d.ts.map +1 -1
- package/esm/types/state-machine/softphone-state-machine.d.ts +1 -2
- package/esm/types/state-machine/softphone-state-machine.d.ts.map +1 -1
- package/esm/types/state-machine/utils.d.ts +1 -1
- package/esm/types/state-machine/utils.d.ts.map +1 -1
- package/esm/types/utils/sdp.d.ts +1 -2
- package/esm/types/utils/sdp.d.ts.map +1 -1
- package/esm/types/utils/update-from.d.ts +1 -1
- package/esm/types/utils/update-from.d.ts.map +1 -1
- package/esm/types/utils/webrtc.d.ts.map +1 -1
- package/esm/types/voice/call.d.ts +15 -3
- package/esm/types/voice/call.d.ts.map +1 -1
- package/esm/types/voice/softphone.d.ts +7 -0
- package/esm/types/voice/softphone.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts +39 -38
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/utils/sdp.js +16 -9
- package/esm/utils/update-from.js +2 -2
- package/esm/utils/webrtc.js +10 -4
- package/esm/voice/call.js +86 -28
- package/esm/voice/softphone.js +58 -17
- package/esm/web-rtc-client.js +67 -58
- package/lib/__tests__/__voice__/call.test.js +51 -2
- package/lib/api/auth.js +3 -0
- package/lib/checker/checks/webrtc.js +1 -1
- package/lib/domain/CallLog.js +2 -3
- package/lib/domain/Phone/CTIPhone.js +2 -2
- package/lib/domain/Phone/WebRTCPhone.js +58 -56
- package/lib/index.js +7 -3
- package/lib/service/CallApi.js +2 -2
- package/lib/simple/Auth.js +15 -3
- package/lib/simple/Phone.js +2 -2
- package/lib/simple/index.js +2 -1
- package/lib/simple/room/Room.js +1 -1
- package/lib/simple/room/SipRoom.js +1 -1
- package/lib/state-machine/call-state-machine.js +35 -20
- package/lib/state-machine/softphone-state-machine.js +1 -2
- package/lib/state-machine/utils.js +10 -4
- package/lib/types/api/auth.d.ts +3 -0
- package/lib/types/api/auth.d.ts.map +1 -1
- package/lib/types/checker/checks/index.d.ts +1 -1
- package/lib/types/checker/checks/webrtc-transport.d.ts +2 -2
- package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -1
- package/lib/types/domain/CallLog.d.ts.map +1 -1
- package/lib/types/domain/CallSession.d.ts +3 -3
- package/lib/types/domain/CallSession.d.ts.map +1 -1
- package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +22 -22
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/lib/types/domain/types.d.ts +0 -4
- package/lib/types/domain/types.d.ts.map +1 -1
- package/lib/types/index.d.ts +3 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +3 -3
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/lib/types/service/CallApi.d.ts +5 -5
- package/lib/types/service/CallApi.d.ts.map +1 -1
- package/lib/types/simple/Auth.d.ts +6 -1
- package/lib/types/simple/Auth.d.ts.map +1 -1
- package/lib/types/simple/Phone.d.ts +8 -8
- package/lib/types/simple/Phone.d.ts.map +1 -1
- package/lib/types/simple/index.d.ts +3 -1
- package/lib/types/simple/index.d.ts.map +1 -1
- package/lib/types/state-machine/call-state-machine.d.ts +12 -1
- package/lib/types/state-machine/call-state-machine.d.ts.map +1 -1
- package/lib/types/state-machine/softphone-state-machine.d.ts +1 -2
- package/lib/types/state-machine/softphone-state-machine.d.ts.map +1 -1
- package/lib/types/state-machine/utils.d.ts +1 -1
- package/lib/types/state-machine/utils.d.ts.map +1 -1
- package/lib/types/utils/sdp.d.ts +1 -2
- package/lib/types/utils/sdp.d.ts.map +1 -1
- package/lib/types/utils/update-from.d.ts +1 -1
- package/lib/types/utils/update-from.d.ts.map +1 -1
- package/lib/types/utils/webrtc.d.ts.map +1 -1
- package/lib/types/voice/call.d.ts +15 -3
- package/lib/types/voice/call.d.ts.map +1 -1
- package/lib/types/voice/softphone.d.ts +7 -0
- package/lib/types/voice/softphone.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts +39 -38
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/utils/sdp.js +17 -10
- package/lib/utils/update-from.js +2 -2
- package/lib/utils/webrtc.js +11 -4
- package/lib/voice/call.js +89 -27
- package/lib/voice/softphone.js +62 -17
- package/lib/web-rtc-client.js +66 -57
- package/package.json +1 -1
- package/src/__tests__/__voice__/call.test.ts +61 -3
- package/src/api/auth.ts +5 -0
- package/src/checker/checks/webrtc-transport.ts +2 -2
- package/src/checker/checks/webrtc.ts +2 -2
- package/src/domain/CallLog.ts +2 -3
- package/src/domain/CallSession.ts +3 -3
- package/src/domain/Phone/CTIPhone.ts +3 -2
- package/src/domain/Phone/WebRTCPhone.ts +87 -85
- package/src/domain/__tests__/CallSession.test.ts +4 -0
- package/src/domain/types.ts +0 -5
- package/src/index.ts +4 -1
- package/src/lib/WazoSessionDescriptionHandler.ts +3 -3
- package/src/service/CallApi.ts +7 -7
- package/src/simple/Auth.ts +15 -3
- package/src/simple/Phone.ts +11 -11
- package/src/simple/index.ts +2 -1
- package/src/simple/room/Room.ts +3 -3
- package/src/simple/room/SipRoom.ts +3 -3
- package/src/state-machine/call-state-machine.ts +38 -19
- package/src/state-machine/softphone-state-machine.ts +1 -2
- package/src/state-machine/utils.ts +12 -4
- package/src/utils/sdp.ts +18 -11
- package/src/utils/update-from.ts +2 -2
- package/src/utils/webrtc.ts +11 -4
- package/src/voice/call.ts +109 -36
- package/src/voice/softphone.ts +75 -18
- package/src/web-rtc-client.ts +112 -98
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Session from '../Session';
|
|
2
2
|
import Call from '../Call';
|
|
3
|
+
import SoftphoneCall from '../../voice/call';
|
|
3
4
|
import Line from '../Line';
|
|
4
5
|
import CallSession from '../CallSession';
|
|
5
6
|
import type { Phone, AvailablePhoneOptions } from './Phone';
|
|
@@ -141,7 +142,7 @@ export default class CTIPhone extends Emitter implements Phone {
|
|
|
141
142
|
});
|
|
142
143
|
|
|
143
144
|
try {
|
|
144
|
-
await CallApi.cancelCall(callSession);
|
|
145
|
+
await CallApi.cancelCall({ apiId: callSession.getId() } as SoftphoneCall);
|
|
145
146
|
|
|
146
147
|
if (this.currentCall && callSession.callId === this.currentCall.id) {
|
|
147
148
|
this.endCurrentCall(callSession);
|
|
@@ -167,7 +168,7 @@ export default class CTIPhone extends Emitter implements Phone {
|
|
|
167
168
|
callId: callSession.getId(),
|
|
168
169
|
number: callSession.number,
|
|
169
170
|
});
|
|
170
|
-
await CallApi.cancelCall(callSession);
|
|
171
|
+
await CallApi.cancelCall({ id: callSession.getId() } as SoftphoneCall);
|
|
171
172
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
172
173
|
}
|
|
173
174
|
|
|
@@ -8,11 +8,11 @@ import { Inviter, Invitation, Session, SessionDescriptionHandlerOptions } from '
|
|
|
8
8
|
import { SessionDescriptionHandler } from 'sip.js/lib/platform/web';
|
|
9
9
|
import CallSession from '../CallSession';
|
|
10
10
|
import type { Phone, AvailablePhoneOptions } from './Phone';
|
|
11
|
-
import
|
|
11
|
+
import WebRTCClient from '../../web-rtc-client';
|
|
12
12
|
import Emitter from '../../utils/Emitter';
|
|
13
13
|
import IssueReporter from '../../service/IssueReporter';
|
|
14
|
-
import { PeerConnection,
|
|
15
|
-
import { getCallDisplayName, getCallNumber,
|
|
14
|
+
import { PeerConnection, SipCall } from '../types';
|
|
15
|
+
import { getCallDisplayName, getCallNumber, getSipCallId } from '../../utils/sdp';
|
|
16
16
|
import { downgradeToAudio, getStreamFromConstraints, getWebRtcStats, setLocalMediaStream, upgradeToVideo } from '../../utils/webrtc';
|
|
17
17
|
|
|
18
18
|
export const ON_USER_AGENT = 'onUserAgent';
|
|
@@ -64,7 +64,7 @@ const logger = IssueReporter.loggerFor('webrtc-phone');
|
|
|
64
64
|
|
|
65
65
|
// @deprecated: Use Wazo.Voice.Softphone instead
|
|
66
66
|
export default class WebRTCPhone extends Emitter implements Phone {
|
|
67
|
-
client:
|
|
67
|
+
client: WebRTCClient;
|
|
68
68
|
|
|
69
69
|
allowVideo: boolean;
|
|
70
70
|
|
|
@@ -72,7 +72,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
72
72
|
|
|
73
73
|
incomingSessions: string[];
|
|
74
74
|
|
|
75
|
-
currentSipSession?:
|
|
75
|
+
currentSipSession?: SipCall;
|
|
76
76
|
|
|
77
77
|
currentCallSession?: CallSession;
|
|
78
78
|
|
|
@@ -98,7 +98,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
98
98
|
|
|
99
99
|
shouldSendReinvite: boolean;
|
|
100
100
|
|
|
101
|
-
constructor(client:
|
|
101
|
+
constructor(client: WebRTCClient, audioOutputDeviceId: string | undefined, allowVideo = false, audioRingDeviceId?: string) {
|
|
102
102
|
super();
|
|
103
103
|
this.client = client;
|
|
104
104
|
this.allowVideo = allowVideo;
|
|
@@ -163,7 +163,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
163
163
|
async sendReinvite(callSession?: CallSession, constraints: Record<string, any> | null | undefined = null, conference = false, audioOnly = false, iceRestart = false): Promise<OutgoingInviteRequest | void> {
|
|
164
164
|
const sipSession = this.findSipSession(callSession);
|
|
165
165
|
logger.info('WebRTC phone - send reinvite', {
|
|
166
|
-
sessionId: sipSession
|
|
166
|
+
sessionId: getSipCallId(sipSession),
|
|
167
167
|
constraints,
|
|
168
168
|
audioOnly,
|
|
169
169
|
conference,
|
|
@@ -360,7 +360,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
360
360
|
content: {
|
|
361
361
|
type: ON_MESSAGE_TRACK_UPDATED,
|
|
362
362
|
update: isUpgrade ? 'upgrade' : 'downgrade',
|
|
363
|
-
sipCallId: sipSession &&
|
|
363
|
+
sipCallId: sipSession && getSipCallId(sipSession),
|
|
364
364
|
callId: callSession ? callSession.callId : null,
|
|
365
365
|
number: callSession ? callSession.number : null,
|
|
366
366
|
},
|
|
@@ -368,8 +368,8 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
368
368
|
}, 2500);
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
-
_bindEvents(sipSession:
|
|
372
|
-
const sipSessionId =
|
|
371
|
+
_bindEvents(sipSession: SipCall) {
|
|
372
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
373
373
|
|
|
374
374
|
if (sipSession instanceof Invitation) {
|
|
375
375
|
// Monkey patch to know when canceled with the CANCEL message
|
|
@@ -384,7 +384,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
384
384
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
385
385
|
const callSession = this._createCallSession(sipSession);
|
|
386
386
|
|
|
387
|
-
|
|
387
|
+
if (sipSessionId) {
|
|
388
|
+
delete this.callSessions[sipSessionId];
|
|
389
|
+
}
|
|
388
390
|
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
389
391
|
};
|
|
390
392
|
}
|
|
@@ -393,7 +395,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
393
395
|
switch (newState) {
|
|
394
396
|
case SessionState.Terminating:
|
|
395
397
|
logger.info('WebRTC phone - call terminating', {
|
|
396
|
-
sipId: sipSession
|
|
398
|
+
sipId: getSipCallId(sipSession),
|
|
397
399
|
});
|
|
398
400
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
399
401
|
break;
|
|
@@ -401,7 +403,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
401
403
|
case SessionState.Terminated:
|
|
402
404
|
{
|
|
403
405
|
logger.info('WebRTC phone - call terminated', {
|
|
404
|
-
sipId: sipSession
|
|
406
|
+
sipId: getSipCallId(sipSession),
|
|
405
407
|
});
|
|
406
408
|
|
|
407
409
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
@@ -437,7 +439,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
437
439
|
const [stream] = event.streams;
|
|
438
440
|
const kind = event && event.track && event.track.kind;
|
|
439
441
|
logger.info('on track stream called on the peer connection', {
|
|
440
|
-
callId:
|
|
442
|
+
callId: getSipCallId(sipSession),
|
|
441
443
|
streamId: stream ? stream.id : null,
|
|
442
444
|
tracks: stream ? stream.getTracks() : null,
|
|
443
445
|
kind,
|
|
@@ -472,9 +474,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
472
474
|
|
|
473
475
|
const screenTrack = screenShareStream.getVideoTracks()[0];
|
|
474
476
|
const sipSession = this.currentSipSession;
|
|
475
|
-
const pc = sipSession && this.client.getPeerConnection(
|
|
477
|
+
const pc = sipSession && this.client.getPeerConnection(getSipCallId(sipSession));
|
|
476
478
|
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
477
|
-
const localStream = sipSession && this.client.getLocalStream(
|
|
479
|
+
const localStream = sipSession && this.client.getLocalStream(getSipCallId(sipSession));
|
|
478
480
|
const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
|
|
479
481
|
const hadVideo = !!videoTrack;
|
|
480
482
|
|
|
@@ -493,7 +495,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
493
495
|
sender.replaceTrack(screenTrack);
|
|
494
496
|
}
|
|
495
497
|
|
|
496
|
-
this._onScreenSharing(screenShareStream, sipSession as
|
|
498
|
+
this._onScreenSharing(screenShareStream, sipSession as SipCall, callSession, hadVideo, constraints.desktop);
|
|
497
499
|
|
|
498
500
|
return screenShareStream;
|
|
499
501
|
}
|
|
@@ -547,14 +549,14 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
547
549
|
return reinvited;
|
|
548
550
|
}
|
|
549
551
|
|
|
550
|
-
_onScreenSharing(screenStream: MediaStream, sipSession:
|
|
552
|
+
_onScreenSharing(screenStream: MediaStream, sipSession: SipCall, callSession: CallSession | null | undefined, hadVideo: boolean, desktop?: boolean | null | undefined) {
|
|
551
553
|
const screenTrack = screenStream.getVideoTracks()[0];
|
|
552
|
-
const sipSessionId =
|
|
554
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
553
555
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
554
556
|
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
555
557
|
logger.info('WebRTC phone - on screensharing', {
|
|
556
558
|
hadVideo,
|
|
557
|
-
id:
|
|
559
|
+
id: getSipCallId(sipSession),
|
|
558
560
|
screenTrack,
|
|
559
561
|
});
|
|
560
562
|
|
|
@@ -562,7 +564,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
562
564
|
screenTrack.onended = () => {
|
|
563
565
|
logger.info('WebRTC phone - on screenshare ended', {
|
|
564
566
|
hadVideo,
|
|
565
|
-
id:
|
|
567
|
+
id: getSipCallId(sipSession),
|
|
566
568
|
screenTrack,
|
|
567
569
|
});
|
|
568
570
|
this.eventEmitter.emit(ON_SHARE_SCREEN_ENDING, this._createCallSession(sipSession, callSession));
|
|
@@ -582,9 +584,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
582
584
|
}), screenStream);
|
|
583
585
|
}
|
|
584
586
|
|
|
585
|
-
_onCallAccepted(sipSession:
|
|
587
|
+
_onCallAccepted(sipSession: SipCall, cameraEnabled: boolean): CallSession {
|
|
586
588
|
logger.info('WebRTC phone - on call accepted', {
|
|
587
|
-
sipId: sipSession
|
|
589
|
+
sipId: getSipCallId(sipSession),
|
|
588
590
|
cameraEnabled,
|
|
589
591
|
});
|
|
590
592
|
|
|
@@ -592,7 +594,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
592
594
|
|
|
593
595
|
if (this.currentSipSession && !this.isCurrentCallSipSession(callSession)) {
|
|
594
596
|
logger.info('WebRTC phone - on call accepted with another ongoing call, holding it', {
|
|
595
|
-
sipId: sipSession
|
|
597
|
+
sipId: getSipCallId(sipSession),
|
|
596
598
|
cameraEnabled,
|
|
597
599
|
});
|
|
598
600
|
|
|
@@ -602,7 +604,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
602
604
|
this.currentSipSession = sipSession;
|
|
603
605
|
this.currentCallSession = callSession;
|
|
604
606
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call accepted');
|
|
605
|
-
const sipSessionId =
|
|
607
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
606
608
|
|
|
607
609
|
if (sipSessionId) {
|
|
608
610
|
this.removeIncomingSessions(sipSessionId);
|
|
@@ -673,11 +675,11 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
673
675
|
return this.currentSipSession && this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
674
676
|
}
|
|
675
677
|
|
|
676
|
-
_onCallTerminated(sipSession:
|
|
677
|
-
const sipSessionId =
|
|
678
|
+
_onCallTerminated(sipSession: SipCall): boolean {
|
|
679
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
678
680
|
|
|
679
681
|
logger.info('WebRTC phone - on call terminated', {
|
|
680
|
-
sipId: sipSession
|
|
682
|
+
sipId: getSipCallId(sipSession),
|
|
681
683
|
sipSessionId,
|
|
682
684
|
ids: Object.keys(this.callSessions),
|
|
683
685
|
});
|
|
@@ -701,9 +703,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
701
703
|
|
|
702
704
|
if (sipSessionId) {
|
|
703
705
|
this.removeIncomingSessions(sipSessionId);
|
|
704
|
-
}
|
|
705
706
|
|
|
706
|
-
|
|
707
|
+
delete this.callSessions[sipSessionId];
|
|
708
|
+
}
|
|
707
709
|
|
|
708
710
|
if (isCurrentSession) {
|
|
709
711
|
this.currentSipSession = undefined;
|
|
@@ -713,7 +715,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
713
715
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
714
716
|
// Re-trigger incoming call event for remaining incoming calls
|
|
715
717
|
logger.info('WebRTC phone - check to re-trigger incoming call', {
|
|
716
|
-
sipId: sipSession
|
|
718
|
+
sipId: getSipCallId(sipSession),
|
|
717
719
|
shouldRetrigger,
|
|
718
720
|
hasIncomingCallSession,
|
|
719
721
|
});
|
|
@@ -788,7 +790,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
788
790
|
return false;
|
|
789
791
|
}
|
|
790
792
|
|
|
791
|
-
return this.currentSipSession &&
|
|
793
|
+
return this.currentSipSession && getSipCallId(this.currentSipSession) === callSession.getId();
|
|
792
794
|
}
|
|
793
795
|
|
|
794
796
|
hasVideo(callSession: CallSession): boolean {
|
|
@@ -831,7 +833,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
831
833
|
return Promise.resolve(null);
|
|
832
834
|
}
|
|
833
835
|
|
|
834
|
-
const sipSessionId = this.
|
|
836
|
+
const sipSessionId = this.getSipCallIdFromCallSession(callSession);
|
|
835
837
|
|
|
836
838
|
if (sipSessionId && !(sipSessionId in this.callSessions)) {
|
|
837
839
|
logger.warn('Call session already ended or not found, can\'t accept it.', {
|
|
@@ -857,7 +859,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
857
859
|
const sipSession = this.client.getSipSession(callSession.getId()) as Invitation;
|
|
858
860
|
|
|
859
861
|
if (sipSession) {
|
|
860
|
-
logger.info('accept call, session found', { sipId: sipSession
|
|
862
|
+
logger.info('accept call, session found', { sipId: getSipCallId(sipSession) });
|
|
861
863
|
|
|
862
864
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
863
865
|
return callSession.sipCallId;
|
|
@@ -872,7 +874,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
872
874
|
|
|
873
875
|
logger.warn(error, {
|
|
874
876
|
id: callSession ? callSession.getId() : 'n/a',
|
|
875
|
-
ids: this.client.
|
|
877
|
+
ids: this.client.getSipCallIds(),
|
|
876
878
|
});
|
|
877
879
|
|
|
878
880
|
if (callSession) {
|
|
@@ -902,7 +904,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
902
904
|
|
|
903
905
|
if (sipSession) {
|
|
904
906
|
logger.info('WebRTC rejecting', {
|
|
905
|
-
sipId: sipSession
|
|
907
|
+
sipId: getSipCallId(sipSession),
|
|
906
908
|
});
|
|
907
909
|
this.client.hangup(sipSession);
|
|
908
910
|
}
|
|
@@ -923,7 +925,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
923
925
|
|
|
924
926
|
if (sipSession) {
|
|
925
927
|
logger.info('WebRTC atxfer', {
|
|
926
|
-
sipId: sipSession
|
|
928
|
+
sipId: getSipCallId(sipSession),
|
|
927
929
|
});
|
|
928
930
|
return this.client.atxfer(sipSession);
|
|
929
931
|
}
|
|
@@ -954,13 +956,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
954
956
|
}
|
|
955
957
|
|
|
956
958
|
logger.info('WebRTC resuming', {
|
|
957
|
-
sipId: sipSession
|
|
959
|
+
sipId: getSipCallId(sipSession),
|
|
958
960
|
});
|
|
959
961
|
|
|
960
962
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
961
|
-
if (this.currentSipSession && this.currentSipSession
|
|
963
|
+
if (this.currentSipSession && getSipCallId(this.currentSipSession) !== getSipCallId(sipSession)) {
|
|
962
964
|
logger.info('WebRTC hold call after resume', {
|
|
963
|
-
id: this.currentSipSession
|
|
965
|
+
id: getSipCallId(this.currentSipSession),
|
|
964
966
|
});
|
|
965
967
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, withEvent);
|
|
966
968
|
}
|
|
@@ -975,15 +977,15 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
975
977
|
return promise;
|
|
976
978
|
}
|
|
977
979
|
|
|
978
|
-
async holdSipSession(sipSession:
|
|
980
|
+
async holdSipSession(sipSession: SipCall, callSession?: CallSession, withEvent = true): Promise<OutgoingInviteRequest | void> {
|
|
979
981
|
if (!sipSession) {
|
|
980
982
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
981
983
|
}
|
|
982
984
|
|
|
983
|
-
const sessionId =
|
|
985
|
+
const sessionId = getSipCallId(sipSession);
|
|
984
986
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
985
987
|
logger.info('WebRTC hold sip session', {
|
|
986
|
-
sipId: sipSession
|
|
988
|
+
sipId: getSipCallId(sipSession),
|
|
987
989
|
hasVideo,
|
|
988
990
|
});
|
|
989
991
|
|
|
@@ -1008,13 +1010,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1008
1010
|
return promise;
|
|
1009
1011
|
}
|
|
1010
1012
|
|
|
1011
|
-
async unholdSipSession(sipSession:
|
|
1013
|
+
async unholdSipSession(sipSession: SipCall, callSession: CallSession | null | undefined, withEvent = true): Promise<MediaStream | void | null> {
|
|
1012
1014
|
if (!sipSession) {
|
|
1013
1015
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
1014
1016
|
}
|
|
1015
1017
|
|
|
1016
1018
|
const isConference = !!callSession && callSession.isConference();
|
|
1017
|
-
const sessionId =
|
|
1019
|
+
const sessionId = getSipCallId(sipSession);
|
|
1018
1020
|
logger.info('WebRTC unhold sip session', {
|
|
1019
1021
|
sessionId,
|
|
1020
1022
|
isConference,
|
|
@@ -1080,7 +1082,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1080
1082
|
}
|
|
1081
1083
|
|
|
1082
1084
|
logger.info('WebRTC muting', {
|
|
1083
|
-
sipId: sipSession
|
|
1085
|
+
sipId: getSipCallId(sipSession),
|
|
1084
1086
|
});
|
|
1085
1087
|
this.client.mute(sipSession);
|
|
1086
1088
|
|
|
@@ -1108,7 +1110,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1108
1110
|
}
|
|
1109
1111
|
|
|
1110
1112
|
logger.info('WebRTC unmuting', {
|
|
1111
|
-
sipId: sipSession
|
|
1113
|
+
sipId: getSipCallId(sipSession),
|
|
1112
1114
|
});
|
|
1113
1115
|
this.client.unmute(sipSession);
|
|
1114
1116
|
|
|
@@ -1143,7 +1145,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1143
1145
|
}
|
|
1144
1146
|
|
|
1145
1147
|
logger.info('WebRTC turn camera on', {
|
|
1146
|
-
sipId: sipSession
|
|
1148
|
+
sipId: getSipCallId(sipSession),
|
|
1147
1149
|
});
|
|
1148
1150
|
this.client.toggleCameraOn(sipSession);
|
|
1149
1151
|
this.eventEmitter.emit(ON_CAMERA_RESUMED, this._createCameraResumedCallSession(sipSession, callSession));
|
|
@@ -1157,7 +1159,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1157
1159
|
}
|
|
1158
1160
|
|
|
1159
1161
|
logger.info('WebRTC turn camera off', {
|
|
1160
|
-
sipId: sipSession
|
|
1162
|
+
sipId: getSipCallId(sipSession),
|
|
1161
1163
|
});
|
|
1162
1164
|
this.client.toggleCameraOff(sipSession);
|
|
1163
1165
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -1171,7 +1173,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1171
1173
|
}
|
|
1172
1174
|
|
|
1173
1175
|
logger.info('WebRTC send key', {
|
|
1174
|
-
sipId: sipSession
|
|
1176
|
+
sipId: getSipCallId(sipSession),
|
|
1175
1177
|
tone,
|
|
1176
1178
|
});
|
|
1177
1179
|
this.client.sendDTMF(sipSession, tone);
|
|
@@ -1203,10 +1205,10 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1203
1205
|
});
|
|
1204
1206
|
}
|
|
1205
1207
|
|
|
1206
|
-
let sipSession:
|
|
1208
|
+
let sipSession: SipCall;
|
|
1207
1209
|
|
|
1208
1210
|
try {
|
|
1209
|
-
sipSession = this.client.call(number, this.allowVideo ? cameraEnabled : false, audioOnly, conference, options) as
|
|
1211
|
+
sipSession = this.client.call(number, this.allowVideo ? cameraEnabled : false, audioOnly, conference, options) as SipCall;
|
|
1210
1212
|
|
|
1211
1213
|
this._bindEvents(sipSession);
|
|
1212
1214
|
} catch (error: any) {
|
|
@@ -1249,7 +1251,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1249
1251
|
}
|
|
1250
1252
|
|
|
1251
1253
|
logger.info('WebRTC transfer', {
|
|
1252
|
-
sipId: sipSession
|
|
1254
|
+
sipId: getSipCallId(sipSession),
|
|
1253
1255
|
target,
|
|
1254
1256
|
});
|
|
1255
1257
|
this.client.transfer(sipSession, target);
|
|
@@ -1259,8 +1261,8 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1259
1261
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
1260
1262
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
1261
1263
|
logger.info('WebRTC indirect transfer', {
|
|
1262
|
-
sipId: sipSession ? sipSession
|
|
1263
|
-
target: sipSessionTarget ? sipSessionTarget
|
|
1264
|
+
sipId: sipSession ? getSipCallId(sipSession) : null,
|
|
1265
|
+
target: sipSessionTarget ? getSipCallId(sipSessionTarget) : null,
|
|
1264
1266
|
});
|
|
1265
1267
|
|
|
1266
1268
|
if (!sipSessionTarget) {
|
|
@@ -1296,10 +1298,10 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1296
1298
|
console.error('Call is unknown to the WebRTC phone', callSession ? callSession.sipCallId : null, callSession ? callSession.callId : null);
|
|
1297
1299
|
return false;
|
|
1298
1300
|
}
|
|
1299
|
-
const sipSessionId =
|
|
1301
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
1300
1302
|
|
|
1301
1303
|
logger.info('WebRTC hangup', {
|
|
1302
|
-
sipId: sipSession
|
|
1304
|
+
sipId: getSipCallId(sipSession),
|
|
1303
1305
|
sipSessionId,
|
|
1304
1306
|
});
|
|
1305
1307
|
await this.client.hangup(sipSession);
|
|
@@ -1432,7 +1434,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1432
1434
|
}
|
|
1433
1435
|
|
|
1434
1436
|
// eslint-disable-next-line @typescript-eslint/default-param-last
|
|
1435
|
-
sendMessage(sipSession:
|
|
1437
|
+
sendMessage(sipSession: SipCall | null = null, body: string, contentType = 'text/plain'): void {
|
|
1436
1438
|
return this.client.sendMessage(sipSession, body, contentType);
|
|
1437
1439
|
}
|
|
1438
1440
|
|
|
@@ -1484,11 +1486,11 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1484
1486
|
|
|
1485
1487
|
bindClientEvents() {
|
|
1486
1488
|
this.client.unbind();
|
|
1487
|
-
this.client.on(this.client.INVITE, (sipSession:
|
|
1489
|
+
this.client.on(this.client.INVITE, (sipSession: SipCall, wantsToDoVideo: boolean) => {
|
|
1488
1490
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
1489
1491
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
1490
1492
|
logger.info('WebRTC invite received', {
|
|
1491
|
-
sipId: sipSession
|
|
1493
|
+
sipId: getSipCallId(sipSession),
|
|
1492
1494
|
withVideo,
|
|
1493
1495
|
autoAnswer,
|
|
1494
1496
|
});
|
|
@@ -1527,13 +1529,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1527
1529
|
// if `_createCallSession` is called too soon `hasVideo` will return false because the stream doesn't exists yet
|
|
1528
1530
|
setTimeout(() => {
|
|
1529
1531
|
// Update callSession
|
|
1530
|
-
this._createCallSession(sipSession, this.callSessions[
|
|
1532
|
+
this._createCallSession(sipSession, this.callSessions[getSipCallId(sipSession)]);
|
|
1531
1533
|
|
|
1532
1534
|
this.eventEmitter.emit.apply(this.eventEmitter, [this.client.ON_REINVITE, ...args]);
|
|
1533
1535
|
}, 2000);
|
|
1534
1536
|
});
|
|
1535
|
-
this.client.on(this.client.ACCEPTED, async (sipSession:
|
|
1536
|
-
const sessionId =
|
|
1537
|
+
this.client.on(this.client.ACCEPTED, async (sipSession: SipCall) => {
|
|
1538
|
+
const sessionId = getSipCallId(sipSession);
|
|
1537
1539
|
const hasSession = (sessionId in this.callSessions);
|
|
1538
1540
|
logger.info('WebRTC call accepted', {
|
|
1539
1541
|
sipId: sessionId,
|
|
@@ -1559,13 +1561,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1559
1561
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
1560
1562
|
});
|
|
1561
1563
|
this.client.on(this.client.REJECTED, session => {
|
|
1562
|
-
logger.info('WebRTC call rejected', session
|
|
1564
|
+
logger.info('WebRTC call rejected', { id: getSipCallId(session) });
|
|
1563
1565
|
|
|
1564
1566
|
const callSession = this._createCallSession(session);
|
|
1565
1567
|
|
|
1566
1568
|
// `_createCallSession` add the CallSession in `this.callSessions`.
|
|
1567
1569
|
// so we have to remove it or `callCount` will always return 1 even if the call was rejected
|
|
1568
|
-
delete this.callSessions[
|
|
1570
|
+
delete this.callSessions[getSipCallId(session)];
|
|
1569
1571
|
|
|
1570
1572
|
callSession.endTime = new Date();
|
|
1571
1573
|
|
|
@@ -1585,7 +1587,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1585
1587
|
const callSession = this._createCallSession(session, null, {
|
|
1586
1588
|
incoming: false,
|
|
1587
1589
|
ringing: true,
|
|
1588
|
-
callId:
|
|
1590
|
+
callId: getSipCallId(session),
|
|
1589
1591
|
});
|
|
1590
1592
|
|
|
1591
1593
|
this.eventEmitter.emit(ON_PROGRESS, callSession, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
@@ -1596,7 +1598,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1596
1598
|
const callSession = this._createCallSession(session, null, {
|
|
1597
1599
|
incoming: false,
|
|
1598
1600
|
ringing: true,
|
|
1599
|
-
callId:
|
|
1601
|
+
callId: getSipCallId(session),
|
|
1600
1602
|
});
|
|
1601
1603
|
|
|
1602
1604
|
this.eventEmitter.emit(ON_EARLY_MEDIA, callSession, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
@@ -1657,12 +1659,12 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1657
1659
|
this.eventEmitter.emit(ON_MESSAGE, message);
|
|
1658
1660
|
});
|
|
1659
1661
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
1660
|
-
const callSession = this.getCallSession(
|
|
1662
|
+
const callSession = this.getCallSession(getSipCallId(session));
|
|
1661
1663
|
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
1662
1664
|
});
|
|
1663
1665
|
// Used when upgrading directly in screenshare mode
|
|
1664
|
-
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession:
|
|
1665
|
-
const sipSessionId =
|
|
1666
|
+
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession: SipCall, response: any, desktop: boolean) => {
|
|
1667
|
+
const sipSessionId = getSipCallId(sipSession);
|
|
1666
1668
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
1667
1669
|
const callSession = this.callSessions[sipSessionId];
|
|
1668
1670
|
logger.info('Updrading directly in screensharing mode', {
|
|
@@ -1675,12 +1677,12 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1675
1677
|
}
|
|
1676
1678
|
|
|
1677
1679
|
// Find a corresponding sipSession from a CallSession
|
|
1678
|
-
findSipSession(callSession?: CallSession):
|
|
1679
|
-
const keys = this.client.
|
|
1680
|
+
findSipSession(callSession?: CallSession): SipCall | null | undefined {
|
|
1681
|
+
const keys = this.client.getSipCallIds();
|
|
1680
1682
|
const keyIndex = keys.findIndex(sessionId => callSession && callSession.isId(sessionId));
|
|
1681
1683
|
|
|
1682
1684
|
if (keyIndex === -1) {
|
|
1683
|
-
const currentSipSessionId = this.currentSipSession ?
|
|
1685
|
+
const currentSipSessionId = this.currentSipSession ? getSipCallId(this.currentSipSession) : this.client.getSipCallIds()[0];
|
|
1684
1686
|
return currentSipSessionId ? this.client.getSipSession(currentSipSessionId) : null;
|
|
1685
1687
|
}
|
|
1686
1688
|
|
|
@@ -1691,13 +1693,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1691
1693
|
return this.callSessions[sipSessionId];
|
|
1692
1694
|
}
|
|
1693
1695
|
|
|
1694
|
-
|
|
1696
|
+
getSipCallIdFromCallSession(callSession: CallSession): string | null {
|
|
1695
1697
|
const sipSession = this.findSipSession(callSession);
|
|
1696
|
-
return sipSession ?
|
|
1698
|
+
return sipSession ? getSipCallId(sipSession) : null;
|
|
1697
1699
|
}
|
|
1698
1700
|
|
|
1699
1701
|
_updateCallSession(callSession: CallSession): void {
|
|
1700
|
-
const sipSessionId = this.
|
|
1702
|
+
const sipSessionId = this.getSipCallIdFromCallSession(callSession);
|
|
1701
1703
|
|
|
1702
1704
|
if (sipSessionId) {
|
|
1703
1705
|
this.callSessions[sipSessionId] = callSession;
|
|
@@ -1737,7 +1739,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1737
1739
|
}
|
|
1738
1740
|
}
|
|
1739
1741
|
|
|
1740
|
-
_createIncomingCallSession(sipSession:
|
|
1742
|
+
_createIncomingCallSession(sipSession: SipCall, cameraEnabled: boolean, fromSession?: CallSession | null | undefined, autoAnswer = false): CallSession {
|
|
1741
1743
|
return this._createCallSession(sipSession, fromSession, {
|
|
1742
1744
|
incoming: true,
|
|
1743
1745
|
ringing: true,
|
|
@@ -1746,7 +1748,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1746
1748
|
});
|
|
1747
1749
|
}
|
|
1748
1750
|
|
|
1749
|
-
_createOutgoingCallSession(sipSession:
|
|
1751
|
+
_createOutgoingCallSession(sipSession: SipCall, cameraEnabled: boolean, fromSession?: CallSession): CallSession {
|
|
1750
1752
|
return this._createCallSession(sipSession, fromSession, {
|
|
1751
1753
|
incoming: false,
|
|
1752
1754
|
ringing: true,
|
|
@@ -1754,41 +1756,41 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1754
1756
|
});
|
|
1755
1757
|
}
|
|
1756
1758
|
|
|
1757
|
-
_createAcceptedCallSession(sipSession:
|
|
1759
|
+
_createAcceptedCallSession(sipSession: SipCall, cameraEnabled?: boolean, fromSession?: CallSession): CallSession {
|
|
1758
1760
|
return this._createCallSession(sipSession, fromSession, {
|
|
1759
1761
|
cameraEnabled: cameraEnabled !== undefined ? cameraEnabled : false,
|
|
1760
1762
|
});
|
|
1761
1763
|
}
|
|
1762
1764
|
|
|
1763
|
-
_createMutedCallSession(sipSession:
|
|
1765
|
+
_createMutedCallSession(sipSession: SipCall, fromSession?: CallSession): CallSession {
|
|
1764
1766
|
return this._createCallSession(sipSession, fromSession, {
|
|
1765
1767
|
muted: true,
|
|
1766
1768
|
});
|
|
1767
1769
|
}
|
|
1768
1770
|
|
|
1769
|
-
_createUnmutedCallSession(sipSession:
|
|
1771
|
+
_createUnmutedCallSession(sipSession: SipCall, fromSession?: CallSession): CallSession {
|
|
1770
1772
|
return this._createCallSession(sipSession, fromSession, {
|
|
1771
1773
|
muted: false,
|
|
1772
1774
|
});
|
|
1773
1775
|
}
|
|
1774
1776
|
|
|
1775
|
-
_createCameraResumedCallSession(sipSession:
|
|
1777
|
+
_createCameraResumedCallSession(sipSession: SipCall, fromSession?: CallSession): CallSession {
|
|
1776
1778
|
return this._createCallSession(sipSession, fromSession, {
|
|
1777
1779
|
videoMuted: false,
|
|
1778
1780
|
});
|
|
1779
1781
|
}
|
|
1780
1782
|
|
|
1781
|
-
_createCameraDisabledCallSession(sipSession:
|
|
1783
|
+
_createCameraDisabledCallSession(sipSession: SipCall, fromSession?: CallSession): CallSession {
|
|
1782
1784
|
return this._createCallSession(sipSession, fromSession, {
|
|
1783
1785
|
videoMuted: true,
|
|
1784
1786
|
});
|
|
1785
1787
|
}
|
|
1786
1788
|
|
|
1787
|
-
_createCallSession(sipSession:
|
|
1789
|
+
_createCallSession(sipSession: SipCall, fromSession?: CallSession | null | undefined, extra: Record<string, any> = {}): CallSession {
|
|
1788
1790
|
const number = getCallNumber(sipSession);
|
|
1789
1791
|
const displayName = getCallDisplayName(sipSession);
|
|
1790
1792
|
const { state } = sipSession || {};
|
|
1791
|
-
const sessionId =
|
|
1793
|
+
const sessionId = getSipCallId(sipSession);
|
|
1792
1794
|
|
|
1793
1795
|
fromSession = fromSession || this.callSessions[sessionId];
|
|
1794
1796
|
const callSession = new CallSession({
|
|
@@ -3,6 +3,7 @@ import CallSession from '../CallSession';
|
|
|
3
3
|
const stringify = (cs: any) => JSON.parse(JSON.stringify(cs));
|
|
4
4
|
|
|
5
5
|
describe('CallSession domain', () => {
|
|
6
|
+
|
|
6
7
|
it('should update from another CallSession without data loss', () => {
|
|
7
8
|
const callSession = new CallSession({
|
|
8
9
|
callId: null,
|
|
@@ -12,6 +13,7 @@ describe('CallSession domain', () => {
|
|
|
12
13
|
isCaller: true,
|
|
13
14
|
dialedExtension: null,
|
|
14
15
|
} as any);
|
|
16
|
+
|
|
15
17
|
const anotherCallSession = new CallSession({
|
|
16
18
|
callId: 345,
|
|
17
19
|
callerNumber: '8008',
|
|
@@ -19,6 +21,7 @@ describe('CallSession domain', () => {
|
|
|
19
21
|
isCaller: false,
|
|
20
22
|
dialedExtension: undefined,
|
|
21
23
|
} as any);
|
|
24
|
+
|
|
22
25
|
callSession.updateFrom(anotherCallSession);
|
|
23
26
|
expect(callSession.callId).toBe(345);
|
|
24
27
|
expect(callSession.sipCallId).toBe(123);
|
|
@@ -29,6 +32,7 @@ describe('CallSession domain', () => {
|
|
|
29
32
|
expect(callSession.isCaller).toBe(false);
|
|
30
33
|
expect(callSession.dialedExtension).toBe('');
|
|
31
34
|
});
|
|
35
|
+
|
|
32
36
|
it('should compare 2 callSession', () => {
|
|
33
37
|
const cs1 = new CallSession({
|
|
34
38
|
callId: 123,
|
package/src/domain/types.ts
CHANGED
|
@@ -264,11 +264,6 @@ export type PeerConnection = RTCPeerConnection & {
|
|
|
264
264
|
addStream: (stream: MediaStream) => void;
|
|
265
265
|
sfu: any;
|
|
266
266
|
};
|
|
267
|
-
// @TODO, rename it to SipCall
|
|
268
|
-
export type WazoSession = (Invitation | Inviter) & {
|
|
269
|
-
remoteTag?: any;
|
|
270
|
-
callId?: string;
|
|
271
|
-
};
|
|
272
267
|
|
|
273
268
|
export type SipCall = (Invitation | Inviter) & {
|
|
274
269
|
remoteTag?: any;
|