@wazo/sdk 0.39.14 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/wazo-sdk.js +12 -12
- package/esm/__tests__/api-client.test.js +0 -10
- package/esm/__tests__/web-rtc-client.test.js +2 -15
- package/esm/api/amid.js +12 -4
- package/esm/api/chatd.js +0 -1
- package/esm/api/dird.js +7 -10
- package/esm/checker/checks/ice-ipv4.js +2 -3
- package/esm/checker/checks/symmetric-nat.js +7 -4
- package/esm/domain/AdHocAPIConference.js +1 -1
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/Contact.js +2 -1
- package/esm/domain/MeetingAuthorization.js +6 -0
- package/esm/domain/Phone/CTIPhone.js +2 -0
- package/esm/domain/Phone/WebRTCPhone.js +23 -18
- package/esm/domain/Session.js +2 -2
- package/esm/domain/__tests__/Agent.test.js +0 -2
- package/esm/domain/__tests__/Call.test.js +0 -1
- package/esm/domain/__tests__/CallLog.test.js +0 -1
- package/esm/domain/__tests__/CallSession.test.js +1 -2
- package/esm/domain/__tests__/Contact.test.js +2 -4
- package/esm/domain/__tests__/IndirectTransfer.test.js +0 -1
- package/esm/domain/__tests__/Profile.test.js +0 -1
- package/esm/domain/__tests__/Room.test.js +1 -25
- package/esm/domain/__tests__/Session.test.js +13 -14
- package/esm/domain/__tests__/SipLine.test.js +2 -3
- package/esm/index.js +42 -88
- package/esm/lib/WazoSessionDescriptionHandler.js +9 -15
- package/esm/service/IssueReporter.js +1 -3
- package/esm/service/__tests__/IssueReporter.test.js +0 -1
- package/esm/simple/Phone.js +1 -1
- package/esm/simple/Websocket.js +2 -2
- package/esm/simple/index.js +5 -4
- package/esm/simple/room/Room.js +15 -15
- package/esm/simple/room/SipRoom.js +1 -1
- package/esm/simple/room/Stream.js +1 -2
- package/esm/simple/room/__tests__/Participant.test.js +0 -2
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +1 -2
- package/esm/types/api/amid.d.ts.map +1 -1
- package/esm/types/api/auth.d.ts +2 -2
- package/esm/types/api/auth.d.ts.map +1 -1
- package/esm/types/api/call-logd.d.ts +3 -3
- package/esm/types/api/call-logd.d.ts.map +1 -1
- package/esm/types/api/chatd.d.ts +9 -22
- package/esm/types/api/chatd.d.ts.map +1 -1
- package/esm/types/api/dird.d.ts +21 -14
- package/esm/types/api/dird.d.ts.map +1 -1
- package/esm/types/checker/checks/ice-ipv4.d.ts.map +1 -1
- package/esm/types/checker/checks/index.d.ts +1 -1
- package/esm/types/checker/checks/symmetric-nat.d.ts.map +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/Agent.d.ts +1 -1
- package/esm/types/domain/Agent.d.ts.map +1 -1
- package/esm/types/domain/CallLog.d.ts +14 -26
- package/esm/types/domain/CallLog.d.ts.map +1 -1
- package/esm/types/domain/CallSession.d.ts +3 -4
- package/esm/types/domain/CallSession.d.ts.map +1 -1
- package/esm/types/domain/Contact.d.ts +8 -0
- package/esm/types/domain/Contact.d.ts.map +1 -1
- package/esm/types/domain/MeetingAuthorization.d.ts +6 -0
- package/esm/types/domain/MeetingAuthorization.d.ts.map +1 -1
- package/esm/types/domain/Phone/CTIPhone.d.ts +2 -0
- package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/esm/types/domain/Phone/Phone.d.ts +12 -2
- package/esm/types/domain/Phone/Phone.d.ts.map +1 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +24 -20
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/esm/types/domain/Room.d.ts +10 -12
- package/esm/types/domain/Room.d.ts.map +1 -1
- package/esm/types/domain/Session.d.ts +1 -1
- package/esm/types/domain/Session.d.ts.map +1 -1
- package/esm/types/domain/SipLine.d.ts +3 -3
- package/esm/types/domain/SipLine.d.ts.map +1 -1
- package/esm/types/domain/types.d.ts +64 -10
- package/esm/types/domain/types.d.ts.map +1 -1
- package/esm/types/index.d.ts +51 -314
- package/esm/types/index.d.ts.map +1 -1
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +5 -4
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/esm/types/service/CallApi.d.ts +3 -3
- package/esm/types/service/CallApi.d.ts.map +1 -1
- package/esm/types/service/IssueReporter.d.ts.map +1 -1
- package/esm/types/simple/Auth.d.ts +0 -40
- package/esm/types/simple/Auth.d.ts.map +1 -1
- package/esm/types/simple/Phone.d.ts +0 -113
- package/esm/types/simple/Phone.d.ts.map +1 -1
- package/esm/types/simple/Websocket.d.ts +0 -16
- package/esm/types/simple/Websocket.d.ts.map +1 -1
- package/esm/types/simple/index.d.ts +8 -8
- package/esm/types/simple/index.d.ts.map +1 -1
- package/esm/types/simple/room/Participant.d.ts +4 -3
- package/esm/types/simple/room/Participant.d.ts.map +1 -1
- package/esm/types/simple/room/Room.d.ts +29 -18
- package/esm/types/simple/room/Room.d.ts.map +1 -1
- package/esm/types/simple/room/SipRoom.d.ts +1 -1
- package/esm/types/simple/room/SipRoom.d.ts.map +1 -1
- package/esm/types/simple/room/Stream.d.ts +1 -1
- package/esm/types/simple/room/Stream.d.ts.map +1 -1
- package/esm/types/utils/PhoneNumberUtil.d.ts +1 -1
- package/esm/types/utils/PhoneNumberUtil.d.ts.map +1 -1
- package/esm/types/utils/api-requester.d.ts +1 -1
- package/esm/types/utils/api-requester.d.ts.map +1 -1
- package/esm/types/utils/sdp.d.ts +20 -5
- package/esm/types/utils/sdp.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts +51 -49
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/types/websocket-client.d.ts.map +1 -1
- package/esm/utils/__tests__/PhoneNumberUtil.test.js +0 -6
- package/esm/utils/__tests__/api-requester.test.js +0 -2
- package/esm/utils/__tests__/sdp.test.js +4 -18
- package/esm/utils/api-requester.js +1 -2
- package/esm/utils/sdp.js +8 -3
- package/esm/web-rtc-client.js +99 -136
- package/esm/websocket-client.js +1 -2
- package/index.js +1 -0
- package/lib/__tests__/api-client.test.js +0 -10
- package/lib/__tests__/web-rtc-client.test.js +2 -15
- package/lib/api/amid.js +12 -4
- package/lib/api/chatd.js +0 -1
- package/lib/api/dird.js +19 -22
- package/lib/checker/checks/ice-ipv4.js +2 -3
- package/lib/checker/checks/symmetric-nat.js +7 -4
- package/lib/domain/AdHocAPIConference.js +1 -1
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/Contact.js +2 -1
- package/lib/domain/MeetingAuthorization.js +6 -0
- package/lib/domain/Phone/CTIPhone.js +2 -0
- package/lib/domain/Phone/WebRTCPhone.js +23 -18
- package/lib/domain/Session.js +2 -2
- package/lib/domain/__tests__/Agent.test.js +0 -2
- package/lib/domain/__tests__/Call.test.js +0 -1
- package/lib/domain/__tests__/CallLog.test.js +0 -1
- package/lib/domain/__tests__/CallSession.test.js +1 -2
- package/lib/domain/__tests__/Contact.test.js +2 -4
- package/lib/domain/__tests__/IndirectTransfer.test.js +0 -1
- package/lib/domain/__tests__/Profile.test.js +0 -1
- package/lib/domain/__tests__/Room.test.js +1 -25
- package/lib/domain/__tests__/Session.test.js +13 -14
- package/lib/domain/__tests__/SipLine.test.js +2 -3
- package/lib/index.js +93 -99
- package/lib/lib/WazoSessionDescriptionHandler.js +9 -15
- package/lib/service/IssueReporter.js +1 -3
- package/lib/service/__tests__/IssueReporter.test.js +0 -1
- package/lib/simple/Phone.js +1 -1
- package/lib/simple/Websocket.js +2 -2
- package/lib/simple/index.js +2 -1
- package/lib/simple/room/Room.js +17 -15
- package/lib/simple/room/SipRoom.js +1 -1
- package/lib/simple/room/Stream.js +1 -2
- package/lib/simple/room/__tests__/Participant.test.js +0 -2
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +1 -2
- package/lib/types/api/amid.d.ts.map +1 -1
- package/lib/types/api/auth.d.ts +2 -2
- package/lib/types/api/auth.d.ts.map +1 -1
- package/lib/types/api/call-logd.d.ts +3 -3
- package/lib/types/api/call-logd.d.ts.map +1 -1
- package/lib/types/api/chatd.d.ts +9 -22
- package/lib/types/api/chatd.d.ts.map +1 -1
- package/lib/types/api/dird.d.ts +21 -14
- package/lib/types/api/dird.d.ts.map +1 -1
- package/lib/types/checker/checks/ice-ipv4.d.ts.map +1 -1
- package/lib/types/checker/checks/index.d.ts +1 -1
- package/lib/types/checker/checks/symmetric-nat.d.ts.map +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/Agent.d.ts +1 -1
- package/lib/types/domain/Agent.d.ts.map +1 -1
- package/lib/types/domain/CallLog.d.ts +14 -26
- package/lib/types/domain/CallLog.d.ts.map +1 -1
- package/lib/types/domain/CallSession.d.ts +3 -4
- package/lib/types/domain/CallSession.d.ts.map +1 -1
- package/lib/types/domain/Contact.d.ts +8 -0
- package/lib/types/domain/Contact.d.ts.map +1 -1
- package/lib/types/domain/MeetingAuthorization.d.ts +6 -0
- package/lib/types/domain/MeetingAuthorization.d.ts.map +1 -1
- package/lib/types/domain/Phone/CTIPhone.d.ts +2 -0
- package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/lib/types/domain/Phone/Phone.d.ts +12 -2
- package/lib/types/domain/Phone/Phone.d.ts.map +1 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +24 -20
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/lib/types/domain/Room.d.ts +10 -12
- package/lib/types/domain/Room.d.ts.map +1 -1
- package/lib/types/domain/Session.d.ts +1 -1
- package/lib/types/domain/Session.d.ts.map +1 -1
- package/lib/types/domain/SipLine.d.ts +3 -3
- package/lib/types/domain/SipLine.d.ts.map +1 -1
- package/lib/types/domain/types.d.ts +64 -10
- package/lib/types/domain/types.d.ts.map +1 -1
- package/lib/types/index.d.ts +51 -314
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +5 -4
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/lib/types/service/CallApi.d.ts +3 -3
- package/lib/types/service/CallApi.d.ts.map +1 -1
- package/lib/types/service/IssueReporter.d.ts.map +1 -1
- package/lib/types/simple/Auth.d.ts +0 -40
- package/lib/types/simple/Auth.d.ts.map +1 -1
- package/lib/types/simple/Phone.d.ts +0 -113
- package/lib/types/simple/Phone.d.ts.map +1 -1
- package/lib/types/simple/Websocket.d.ts +0 -16
- package/lib/types/simple/Websocket.d.ts.map +1 -1
- package/lib/types/simple/index.d.ts +8 -8
- package/lib/types/simple/index.d.ts.map +1 -1
- package/lib/types/simple/room/Participant.d.ts +4 -3
- package/lib/types/simple/room/Participant.d.ts.map +1 -1
- package/lib/types/simple/room/Room.d.ts +29 -18
- package/lib/types/simple/room/Room.d.ts.map +1 -1
- package/lib/types/simple/room/SipRoom.d.ts +1 -1
- package/lib/types/simple/room/SipRoom.d.ts.map +1 -1
- package/lib/types/simple/room/Stream.d.ts +1 -1
- package/lib/types/simple/room/Stream.d.ts.map +1 -1
- package/lib/types/utils/PhoneNumberUtil.d.ts +1 -1
- package/lib/types/utils/PhoneNumberUtil.d.ts.map +1 -1
- package/lib/types/utils/api-requester.d.ts +1 -1
- package/lib/types/utils/api-requester.d.ts.map +1 -1
- package/lib/types/utils/sdp.d.ts +20 -5
- package/lib/types/utils/sdp.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts +51 -49
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/types/websocket-client.d.ts.map +1 -1
- package/lib/utils/__tests__/PhoneNumberUtil.test.js +0 -6
- package/lib/utils/__tests__/api-requester.test.js +0 -2
- package/lib/utils/__tests__/sdp.test.js +6 -18
- package/lib/utils/api-requester.js +2 -3
- package/lib/utils/sdp.js +9 -3
- package/lib/web-rtc-client.js +105 -140
- package/lib/websocket-client.js +1 -2
- package/package.json +5 -18
- package/src/__tests__/api-client.test.ts +10 -19
- package/src/__tests__/web-rtc-client.test.ts +13 -25
- package/src/api/amid.ts +13 -4
- package/src/api/auth.ts +2 -5
- package/src/api/call-logd.ts +3 -3
- package/src/api/chatd.ts +10 -24
- package/src/api/dird.ts +33 -39
- package/src/checker/checks/ice-ipv4.ts +4 -5
- package/src/checker/checks/symmetric-nat.ts +11 -7
- package/src/checker/checks/webrtc-transport.ts +2 -2
- package/src/domain/AdHocAPIConference.ts +1 -1
- package/src/domain/Agent.ts +1 -1
- package/src/domain/CallLog.ts +19 -27
- package/src/domain/CallSession.ts +3 -4
- package/src/domain/Contact.ts +3 -1
- package/src/domain/MeetingAuthorization.ts +13 -0
- package/src/domain/Phone/CTIPhone.ts +4 -0
- package/src/domain/Phone/Phone.ts +11 -2
- package/src/domain/Phone/WebRTCPhone.ts +60 -52
- package/src/domain/Room.ts +12 -14
- package/src/domain/Session.ts +3 -3
- package/src/domain/SipLine.ts +3 -3
- package/src/domain/__tests__/Agent.test.ts +3 -5
- package/src/domain/__tests__/Call.test.ts +4 -5
- package/src/domain/__tests__/CallLog.test.ts +1 -3
- package/src/domain/__tests__/CallSession.test.ts +10 -11
- package/src/domain/__tests__/Contact.test.ts +2 -4
- package/src/domain/__tests__/IndirectTransfer.test.ts +6 -7
- package/src/domain/__tests__/Profile.test.ts +3 -4
- package/src/domain/__tests__/Room.test.ts +27 -51
- package/src/domain/__tests__/Session.test.ts +27 -28
- package/src/domain/__tests__/SipLine.test.ts +4 -5
- package/src/domain/types.ts +64 -11
- package/src/index.ts +51 -111
- package/src/lib/WazoSessionDescriptionHandler.ts +24 -30
- package/src/service/CallApi.ts +3 -3
- package/src/service/IssueReporter.ts +3 -5
- package/src/service/__tests__/IssueReporter.test.ts +1 -2
- package/src/simple/Auth.ts +1 -41
- package/src/simple/Phone.ts +9 -116
- package/src/simple/Websocket.ts +4 -20
- package/src/simple/index.ts +8 -7
- package/src/simple/room/Participant.ts +4 -3
- package/src/simple/room/Room.ts +44 -36
- package/src/simple/room/SipRoom.ts +4 -4
- package/src/simple/room/Stream.ts +2 -3
- package/src/simple/room/__tests__/Participant.test.ts +2 -4
- package/src/simple/room/__tests__/RemoteParticipant.test.ts +4 -3
- package/src/types/wazo.d.ts +1 -0
- package/src/utils/PhoneNumberUtil.ts +1 -1
- package/src/utils/__tests__/PhoneNumberUtil.test.ts +0 -6
- package/src/utils/__tests__/api-requester.test.ts +3 -4
- package/src/utils/__tests__/sdp.test.ts +16 -30
- package/src/utils/api-requester.ts +1 -4
- package/src/utils/sdp.ts +38 -17
- package/src/web-rtc-client.ts +196 -234
- package/src/websocket-client.ts +2 -3
- package/lib/.DS_Store +0 -0
package/src/domain/CallLog.ts
CHANGED
|
@@ -8,46 +8,47 @@ type CallLogResponse = {
|
|
|
8
8
|
answer: string | null | undefined;
|
|
9
9
|
answered: boolean;
|
|
10
10
|
call_direction: string;
|
|
11
|
-
destination_extension
|
|
12
|
-
destination_name
|
|
13
|
-
destination_user_uuid
|
|
11
|
+
destination_extension?: string;
|
|
12
|
+
destination_name?: string;
|
|
13
|
+
destination_user_uuid?: string;
|
|
14
14
|
duration: number;
|
|
15
15
|
end: string | null | undefined;
|
|
16
16
|
id: number;
|
|
17
17
|
source_extension: string;
|
|
18
18
|
source_name: string;
|
|
19
|
-
source_user_uuid
|
|
19
|
+
source_user_uuid?: string;
|
|
20
20
|
recordings: RecordingResponse[];
|
|
21
21
|
requested_extension: string;
|
|
22
22
|
requested_name: string;
|
|
23
23
|
start: string;
|
|
24
24
|
};
|
|
25
|
+
|
|
25
26
|
type Response = {
|
|
26
27
|
filtered: number;
|
|
27
28
|
items: Array<CallLogResponse>;
|
|
28
29
|
total: number;
|
|
29
30
|
};
|
|
31
|
+
|
|
32
|
+
type LogOrigin = {
|
|
33
|
+
extension: string;
|
|
34
|
+
name: string;
|
|
35
|
+
uuid?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
30
38
|
type CallLogArguments = {
|
|
31
39
|
answer: Date | null | undefined;
|
|
32
40
|
answered: boolean;
|
|
33
41
|
newMissedCall?: boolean;
|
|
34
42
|
callDirection: string;
|
|
35
|
-
destination:
|
|
36
|
-
|
|
37
|
-
name: string;
|
|
38
|
-
uuid: string | null | undefined;
|
|
39
|
-
};
|
|
40
|
-
source: {
|
|
41
|
-
extension: string;
|
|
42
|
-
name: string;
|
|
43
|
-
uuid: string | null | undefined;
|
|
44
|
-
};
|
|
43
|
+
destination: LogOrigin;
|
|
44
|
+
source: LogOrigin;
|
|
45
45
|
id: number;
|
|
46
46
|
duration: number;
|
|
47
47
|
start: Date;
|
|
48
48
|
end: Date | null | undefined;
|
|
49
49
|
recordings: Recording[];
|
|
50
50
|
};
|
|
51
|
+
|
|
51
52
|
export default class CallLog {
|
|
52
53
|
type: string;
|
|
53
54
|
|
|
@@ -59,17 +60,11 @@ export default class CallLog {
|
|
|
59
60
|
|
|
60
61
|
callDirection: string;
|
|
61
62
|
|
|
62
|
-
destination:
|
|
63
|
-
extension: string;
|
|
64
|
-
name: string;
|
|
65
|
-
};
|
|
63
|
+
destination: LogOrigin;
|
|
66
64
|
|
|
67
65
|
recordings: Recording[];
|
|
68
66
|
|
|
69
|
-
source:
|
|
70
|
-
extension: string;
|
|
71
|
-
name: string;
|
|
72
|
-
};
|
|
67
|
+
source: LogOrigin;
|
|
73
68
|
|
|
74
69
|
id: number;
|
|
75
70
|
|
|
@@ -124,7 +119,7 @@ export default class CallLog {
|
|
|
124
119
|
static parseNew(plain: CallLogResponse, session: Session): CallLog {
|
|
125
120
|
const callLog: CallLog = CallLog.parse(plain);
|
|
126
121
|
// @TODO: FIXME add verification declined vs missed call
|
|
127
|
-
callLog.newMissedCall = session && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
|
|
122
|
+
callLog.newMissedCall = session && session.hasExtension((plain.requested_extension || plain.destination_extension) as string) && !plain.answered;
|
|
128
123
|
return callLog;
|
|
129
124
|
}
|
|
130
125
|
|
|
@@ -162,10 +157,7 @@ export default class CallLog {
|
|
|
162
157
|
return this.theOtherParty(session).extension === other.theOtherParty(session).extension;
|
|
163
158
|
}
|
|
164
159
|
|
|
165
|
-
theOtherParty(session: Session): {
|
|
166
|
-
extension: string;
|
|
167
|
-
name: string;
|
|
168
|
-
} {
|
|
160
|
+
theOtherParty(session: Session): LogOrigin {
|
|
169
161
|
if (this.callDirection === 'inbound') {
|
|
170
162
|
return this.source;
|
|
171
163
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { SessionState } from 'sip.js/lib/api/session-state';
|
|
2
|
-
import type { Invitation } from 'sip.js/lib/api';
|
|
3
|
-
import { Inviter } from 'sip.js/lib/api';
|
|
4
2
|
import Call from './Call';
|
|
5
3
|
import newFrom from '../utils/new-from';
|
|
6
4
|
import updateFrom from '../utils/update-from';
|
|
5
|
+
import { WazoSession } from './types';
|
|
7
6
|
|
|
8
7
|
type CallSessionArguments = {
|
|
9
8
|
answered: boolean;
|
|
@@ -33,7 +32,7 @@ type CallSessionArguments = {
|
|
|
33
32
|
screensharing: boolean;
|
|
34
33
|
recording: boolean;
|
|
35
34
|
recordingPaused: boolean;
|
|
36
|
-
sipSession?:
|
|
35
|
+
sipSession?: WazoSession;
|
|
37
36
|
conference: boolean;
|
|
38
37
|
};
|
|
39
38
|
export default class CallSession {
|
|
@@ -97,7 +96,7 @@ export default class CallSession {
|
|
|
97
96
|
|
|
98
97
|
recordingPaused: boolean;
|
|
99
98
|
|
|
100
|
-
sipSession:
|
|
99
|
+
sipSession: WazoSession | undefined;
|
|
101
100
|
|
|
102
101
|
conference: boolean;
|
|
103
102
|
|
package/src/domain/Contact.ts
CHANGED
|
@@ -239,6 +239,8 @@ type GoogleResponse = {
|
|
|
239
239
|
|
|
240
240
|
const SOURCE_MOBILE = 'mobile';
|
|
241
241
|
export default class Contact {
|
|
242
|
+
static BACKEND = BACKEND;
|
|
243
|
+
|
|
242
244
|
type: string;
|
|
243
245
|
|
|
244
246
|
id: string | null | undefined;
|
|
@@ -769,7 +771,7 @@ export default class Contact {
|
|
|
769
771
|
|
|
770
772
|
merge(old: Contact): Contact {
|
|
771
773
|
Object.keys(old).filter(key => key !== 'lineState').forEach(key => {
|
|
772
|
-
// @ts-ignore
|
|
774
|
+
// @ts-ignore: keys
|
|
773
775
|
this[key] = old[key] || this[key];
|
|
774
776
|
});
|
|
775
777
|
|
|
@@ -11,7 +11,20 @@ export const REJECTED = 'rejected';
|
|
|
11
11
|
export const POST_PROCESSING = 'post_processing';
|
|
12
12
|
export const POST_PROCESSED_SUCCESS = 'post_processed_success';
|
|
13
13
|
export const POST_PROCESSED_ERROR = 'post_processed_error';
|
|
14
|
+
|
|
14
15
|
export default class MeetingAuthorization {
|
|
16
|
+
static PENDING = PENDING;
|
|
17
|
+
|
|
18
|
+
static ACCEPTED = ACCEPTED;
|
|
19
|
+
|
|
20
|
+
static REJECTED = REJECTED;
|
|
21
|
+
|
|
22
|
+
static POST_PROCESSING = POST_PROCESSING;
|
|
23
|
+
|
|
24
|
+
static POST_PROCESSED_SUCCESS = POST_PROCESSED_SUCCESS;
|
|
25
|
+
|
|
26
|
+
static POST_PROCESSED_ERROR = POST_PROCESSED_ERROR;
|
|
27
|
+
|
|
15
28
|
meetingUuid: string;
|
|
16
29
|
|
|
17
30
|
uuid: string;
|
|
@@ -20,6 +20,8 @@ export default class CTIPhone extends Emitter implements Phone {
|
|
|
20
20
|
|
|
21
21
|
currentCall: Call | null | undefined;
|
|
22
22
|
|
|
23
|
+
client = null;
|
|
24
|
+
|
|
23
25
|
constructor(session: Session, isMobile = false, callbackAllLines = false) {
|
|
24
26
|
super();
|
|
25
27
|
logger.info('CTI Phone created');
|
|
@@ -373,4 +375,6 @@ export default class CTIPhone extends Emitter implements Phone {
|
|
|
373
375
|
|
|
374
376
|
setMediaConstraints() {}
|
|
375
377
|
|
|
378
|
+
register() { return Promise.resolve(null); }
|
|
379
|
+
|
|
376
380
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import EventEmitter from 'events';
|
|
1
2
|
import Line from '../Line';
|
|
2
3
|
import CallSession from '../CallSession';
|
|
4
|
+
import type WebRTCClient from '../../web-rtc-client';
|
|
5
|
+
import { IEmitter } from '../../utils/Emitter';
|
|
3
6
|
|
|
4
7
|
export type PhoneEventCallbacks = {
|
|
5
8
|
onCallIncoming?: (number: string) => void;
|
|
@@ -25,7 +28,7 @@ export type AvailablePhoneOptions = {
|
|
|
25
28
|
sendKey: boolean;
|
|
26
29
|
transfer: boolean;
|
|
27
30
|
};
|
|
28
|
-
export interface Phone {
|
|
31
|
+
export interface Phone extends IEmitter {
|
|
29
32
|
accept(callSession: CallSession, enableVideo: boolean): Promise<string | null>;
|
|
30
33
|
changeAudioDevice(id: string): PhoneVoid;
|
|
31
34
|
changeRingDevice(id: string): PhoneVoid;
|
|
@@ -54,7 +57,7 @@ export interface Phone {
|
|
|
54
57
|
hasAVideoTrack(callSession: CallSession): boolean;
|
|
55
58
|
isWebRTC(): boolean;
|
|
56
59
|
getUserAgent(): string;
|
|
57
|
-
makeCall(number: string, line: Line, enableVideo?: boolean, audioOnly?: boolean):
|
|
60
|
+
makeCall(number: string, line: Line, enableVideo?: boolean, audioOnly?: boolean): Promise<CallSession | null | undefined>;
|
|
58
61
|
mute(callSession: CallSession): PhoneVoid;
|
|
59
62
|
reject(callSession: CallSession): PhoneVoid;
|
|
60
63
|
resume(callSession: CallSession): Promise<any> | null | undefined;
|
|
@@ -67,4 +70,10 @@ export interface Phone {
|
|
|
67
70
|
isRegistered(): boolean;
|
|
68
71
|
hasIncomingCallSession(): boolean;
|
|
69
72
|
setMediaConstraints(media: MediaStreamConstraints): PhoneVoid;
|
|
73
|
+
getCurrentCallSession(): CallSession | null | undefined;
|
|
74
|
+
getRemoteVideoStream(callSession: CallSession): MediaStream | null | undefined;
|
|
75
|
+
hasLocalVideo(callSession: CallSession): boolean;
|
|
76
|
+
eventEmitter: EventEmitter;
|
|
77
|
+
client: WebRTCClient | null;
|
|
78
|
+
register(): Promise<null | void>;
|
|
70
79
|
}
|
|
@@ -4,12 +4,14 @@ import type { Message } from 'sip.js/lib/api/message';
|
|
|
4
4
|
import { SessionState } from 'sip.js/lib/api/session-state';
|
|
5
5
|
import type { IncomingRequestMessage } from 'sip.js/lib/core/messages/incoming-request-message';
|
|
6
6
|
import { OutgoingInviteRequest } from 'sip.js/lib/core';
|
|
7
|
-
import { Inviter, Invitation, Session } from 'sip.js/lib/api';
|
|
7
|
+
import { Inviter, Invitation, Session, SessionDescriptionHandlerOptions } from 'sip.js/lib/api';
|
|
8
|
+
import { SessionDescriptionHandler } from 'sip.js/lib/platform/web';
|
|
8
9
|
import CallSession from '../CallSession';
|
|
9
10
|
import type { Phone, AvailablePhoneOptions } from './Phone';
|
|
10
11
|
import WazoWebRTCClient from '../../web-rtc-client';
|
|
11
12
|
import Emitter from '../../utils/Emitter';
|
|
12
13
|
import IssueReporter from '../../service/IssueReporter';
|
|
14
|
+
import { PeerConnection, WazoSession } from '../types';
|
|
13
15
|
|
|
14
16
|
export const ON_USER_AGENT = 'onUserAgent';
|
|
15
17
|
export const ON_REGISTERED = 'onRegistered';
|
|
@@ -66,7 +68,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
66
68
|
|
|
67
69
|
incomingSessions: string[];
|
|
68
70
|
|
|
69
|
-
currentSipSession:
|
|
71
|
+
currentSipSession: WazoSession | undefined;
|
|
70
72
|
|
|
71
73
|
currentCallSession: CallSession | null | undefined;
|
|
72
74
|
|
|
@@ -311,8 +313,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
311
313
|
const shouldScreenShare = constraints && !!constraints.screen;
|
|
312
314
|
const desktop = constraints && constraints.desktop;
|
|
313
315
|
const options = sipSession.sessionDescriptionHandlerOptionsReInvite;
|
|
314
|
-
|
|
315
|
-
const wasAudioOnly = options?.audioOnly;
|
|
316
|
+
const wasAudioOnly = (options as SessionDescriptionHandlerOptions & { audioOnly: boolean })?.audioOnly;
|
|
316
317
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
317
318
|
|
|
318
319
|
if (callSession) {
|
|
@@ -363,7 +364,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
363
364
|
}, 2500);
|
|
364
365
|
}
|
|
365
366
|
|
|
366
|
-
_bindEvents(sipSession:
|
|
367
|
+
_bindEvents(sipSession: WazoSession) {
|
|
367
368
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
368
369
|
|
|
369
370
|
if (sipSession instanceof Invitation) {
|
|
@@ -431,12 +432,15 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
431
432
|
}
|
|
432
433
|
|
|
433
434
|
// Video events
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
435
|
+
const sdh = sipSession.sessionDescriptionHandler as SessionDescriptionHandler;
|
|
436
|
+
const peerConnection = sdh.peerConnection as PeerConnection;
|
|
437
|
+
|
|
438
|
+
if (!peerConnection) {
|
|
439
|
+
logger.info('null peer connection');
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
438
442
|
|
|
439
|
-
peerConnection.ontrack = (rawEvent:
|
|
443
|
+
peerConnection.ontrack = (rawEvent: RTCTrackEvent) => {
|
|
440
444
|
const event = rawEvent;
|
|
441
445
|
const [stream] = event.streams;
|
|
442
446
|
const kind = event && event.track && event.track.kind;
|
|
@@ -477,7 +481,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
477
481
|
const screenTrack = screenShareStream.getVideoTracks()[0];
|
|
478
482
|
const sipSession = this.currentSipSession;
|
|
479
483
|
const pc = sipSession && this.client.getPeerConnection(this.getSipSessionId(sipSession));
|
|
480
|
-
const sender = pc && pc.getSenders && pc.getSenders().find((s
|
|
484
|
+
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
481
485
|
const localStream = sipSession && this.client.getLocalStream(this.getSipSessionId(sipSession));
|
|
482
486
|
const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
|
|
483
487
|
const hadVideo = !!videoTrack;
|
|
@@ -497,7 +501,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
497
501
|
sender.replaceTrack(screenTrack);
|
|
498
502
|
}
|
|
499
503
|
|
|
500
|
-
this._onScreenSharing(screenShareStream, sipSession as
|
|
504
|
+
this._onScreenSharing(screenShareStream, sipSession as WazoSession, callSession, hadVideo, constraints.desktop);
|
|
501
505
|
|
|
502
506
|
return screenShareStream;
|
|
503
507
|
}
|
|
@@ -551,11 +555,11 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
551
555
|
return reinvited;
|
|
552
556
|
}
|
|
553
557
|
|
|
554
|
-
_onScreenSharing(screenStream: MediaStream, sipSession:
|
|
558
|
+
_onScreenSharing(screenStream: MediaStream, sipSession: WazoSession, callSession: CallSession | null | undefined, hadVideo: boolean, desktop?: boolean | null | undefined) {
|
|
555
559
|
const screenTrack = screenStream.getVideoTracks()[0];
|
|
556
560
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
557
561
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
558
|
-
const sender = pc && pc.getSenders && pc.getSenders().find((s
|
|
562
|
+
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
559
563
|
logger.info('WebRTC phone - on screensharing', {
|
|
560
564
|
hadVideo,
|
|
561
565
|
id: this.getSipSessionId(sipSession),
|
|
@@ -586,7 +590,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
586
590
|
}), screenStream);
|
|
587
591
|
}
|
|
588
592
|
|
|
589
|
-
_onCallAccepted(sipSession:
|
|
593
|
+
_onCallAccepted(sipSession: WazoSession, cameraEnabled: boolean): CallSession {
|
|
590
594
|
logger.info('WebRTC phone - on call accepted', {
|
|
591
595
|
sipId: sipSession.id,
|
|
592
596
|
cameraEnabled,
|
|
@@ -594,6 +598,15 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
594
598
|
|
|
595
599
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
596
600
|
|
|
601
|
+
if (this.currentSipSession && !this.isCurrentCallSipSession(callSession)) {
|
|
602
|
+
logger.info('WebRTC phone - on call accepted with another ongoing call, holding it', {
|
|
603
|
+
sipId: sipSession.id,
|
|
604
|
+
cameraEnabled,
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
608
|
+
}
|
|
609
|
+
|
|
597
610
|
this.currentSipSession = sipSession;
|
|
598
611
|
this.currentCallSession = callSession;
|
|
599
612
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call accepted');
|
|
@@ -668,7 +681,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
668
681
|
return this.currentSipSession && this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
669
682
|
}
|
|
670
683
|
|
|
671
|
-
_onCallTerminated(sipSession:
|
|
684
|
+
_onCallTerminated(sipSession: WazoSession): boolean {
|
|
672
685
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
673
686
|
|
|
674
687
|
logger.info('WebRTC phone - on call terminated', {
|
|
@@ -734,7 +747,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
734
747
|
return false;
|
|
735
748
|
}
|
|
736
749
|
|
|
737
|
-
// @ts-ignore
|
|
750
|
+
// @ts-ignore: does not exist
|
|
738
751
|
if (!sipSession.isCanceled) {
|
|
739
752
|
setTimeout(() => {
|
|
740
753
|
this.eventEmitter.emit(ON_PLAY_HANGUP_SOUND, this.audioOutputDeviceId, this.audioOutputVolume, callSession);
|
|
@@ -768,11 +781,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
768
781
|
return false;
|
|
769
782
|
}
|
|
770
783
|
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
} = sipSession.sessionDescriptionHandler;
|
|
775
|
-
const remoteStream: MediaStream = peerConnection.getRemoteStreams().find((stream: MediaStream) => !!stream.getVideoTracks().length);
|
|
784
|
+
const sdh = sipSession.sessionDescriptionHandler as SessionDescriptionHandler;
|
|
785
|
+
const peerConnection = sdh.peerConnection as PeerConnection;
|
|
786
|
+
const remoteStream: MediaStream = peerConnection.getRemoteStreams().find((stream: MediaStream) => !!stream.getVideoTracks().length) as MediaStream;
|
|
776
787
|
return remoteStream && remoteStream.getVideoTracks().some(track => !track.muted);
|
|
777
788
|
}
|
|
778
789
|
|
|
@@ -972,7 +983,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
972
983
|
return promise;
|
|
973
984
|
}
|
|
974
985
|
|
|
975
|
-
async holdSipSession(sipSession:
|
|
986
|
+
async holdSipSession(sipSession: WazoSession, callSession: CallSession | null | undefined, withEvent = true): Promise<OutgoingInviteRequest | void> {
|
|
976
987
|
if (!sipSession) {
|
|
977
988
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
978
989
|
}
|
|
@@ -1005,7 +1016,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1005
1016
|
return promise;
|
|
1006
1017
|
}
|
|
1007
1018
|
|
|
1008
|
-
async unholdSipSession(sipSession:
|
|
1019
|
+
async unholdSipSession(sipSession: WazoSession, callSession: CallSession | null | undefined, withEvent = true): Promise<MediaStream | void | null> {
|
|
1009
1020
|
if (!sipSession) {
|
|
1010
1021
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
1011
1022
|
}
|
|
@@ -1199,10 +1210,10 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1199
1210
|
});
|
|
1200
1211
|
}
|
|
1201
1212
|
|
|
1202
|
-
let sipSession:
|
|
1213
|
+
let sipSession: WazoSession;
|
|
1203
1214
|
|
|
1204
1215
|
try {
|
|
1205
|
-
sipSession = this.client.call(number, this.allowVideo ? cameraEnabled : false, audioOnly, conference);
|
|
1216
|
+
sipSession = this.client.call(number, this.allowVideo ? cameraEnabled : false, audioOnly, conference) as WazoSession;
|
|
1206
1217
|
|
|
1207
1218
|
this._bindEvents(sipSession);
|
|
1208
1219
|
} catch (error: any) {
|
|
@@ -1226,9 +1237,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1226
1237
|
this.eventEmitter.emit(ON_CALL_OUTGOING, callSession);
|
|
1227
1238
|
|
|
1228
1239
|
// If an invite promise exists, catch exceptions on it to trigger error like OverConstraintsError.
|
|
1229
|
-
// @ts-ignore
|
|
1240
|
+
// @ts-ignore: does not exist
|
|
1230
1241
|
if (sipSession.invitePromise) {
|
|
1231
|
-
// @ts-ignore
|
|
1242
|
+
// @ts-ignore: does not exist
|
|
1232
1243
|
sipSession.invitePromise.catch(error => {
|
|
1233
1244
|
this.eventEmitter.emit(ON_CALL_ERROR, error, callSession);
|
|
1234
1245
|
});
|
|
@@ -1327,13 +1338,13 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1327
1338
|
}
|
|
1328
1339
|
|
|
1329
1340
|
forceCancel(sipSession: Inviter): void {
|
|
1330
|
-
// @ts-ignore
|
|
1341
|
+
// @ts-ignore: private
|
|
1331
1342
|
if (!sipSession || !sipSession.outgoingInviteRequest) {
|
|
1332
1343
|
return;
|
|
1333
1344
|
}
|
|
1334
1345
|
|
|
1335
1346
|
try {
|
|
1336
|
-
// @ts-ignore
|
|
1347
|
+
// @ts-ignore: private
|
|
1337
1348
|
sipSession.outgoingInviteRequest.cancel();
|
|
1338
1349
|
} catch (e) {
|
|
1339
1350
|
logger.info('force cancel, error', e);
|
|
@@ -1428,7 +1439,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1428
1439
|
}
|
|
1429
1440
|
|
|
1430
1441
|
// eslint-disable-next-line @typescript-eslint/default-param-last
|
|
1431
|
-
sendMessage(sipSession:
|
|
1442
|
+
sendMessage(sipSession: WazoSession | null = null, body: string, contentType = 'text/plain'): void {
|
|
1432
1443
|
return this.client.sendMessage(sipSession, body, contentType);
|
|
1433
1444
|
}
|
|
1434
1445
|
|
|
@@ -1480,7 +1491,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1480
1491
|
|
|
1481
1492
|
bindClientEvents() {
|
|
1482
1493
|
this.client.unbind();
|
|
1483
|
-
this.client.on(this.client.INVITE, (sipSession:
|
|
1494
|
+
this.client.on(this.client.INVITE, (sipSession: WazoSession, wantsToDoVideo: boolean) => {
|
|
1484
1495
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
1485
1496
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
1486
1497
|
logger.info('WebRTC invite received', {
|
|
@@ -1528,7 +1539,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1528
1539
|
this.eventEmitter.emit.apply(this.eventEmitter, [this.client.ON_REINVITE, ...args]);
|
|
1529
1540
|
}, 2000);
|
|
1530
1541
|
});
|
|
1531
|
-
this.client.on(this.client.ACCEPTED, (sipSession:
|
|
1542
|
+
this.client.on(this.client.ACCEPTED, (sipSession: WazoSession) => {
|
|
1532
1543
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1533
1544
|
const hasSession = (sessionId in this.callSessions);
|
|
1534
1545
|
logger.info('WebRTC call accepted', {
|
|
@@ -1595,8 +1606,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1595
1606
|
// send a reinvite to renegociate ICE with new IP
|
|
1596
1607
|
if (this.shouldSendReinvite && this.currentSipSession && this.currentSipSession.state === SessionState.Established) {
|
|
1597
1608
|
this.shouldSendReinvite = false;
|
|
1598
|
-
|
|
1599
|
-
const pc = this.currentSipSession?.sessionDescriptionHandler?.peerConnection;
|
|
1609
|
+
const pc = (this.currentSipSession?.sessionDescriptionHandler as SessionDescriptionHandler)?.peerConnection as PeerConnection;
|
|
1600
1610
|
const isConference = pc ? pc.sfu : false;
|
|
1601
1611
|
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
1602
1612
|
|
|
@@ -1643,7 +1653,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1643
1653
|
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
1644
1654
|
});
|
|
1645
1655
|
// Used when upgrading directly in screenshare mode
|
|
1646
|
-
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession:
|
|
1656
|
+
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession: WazoSession, response: any, desktop: boolean) => {
|
|
1647
1657
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
1648
1658
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
1649
1659
|
const callSession = this.callSessions[sipSessionId];
|
|
@@ -1657,7 +1667,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1657
1667
|
}
|
|
1658
1668
|
|
|
1659
1669
|
// Find a corresponding sipSession from a CallSession
|
|
1660
|
-
findSipSession(callSession: CallSession | null | undefined):
|
|
1670
|
+
findSipSession(callSession: CallSession | null | undefined): WazoSession | null | undefined {
|
|
1661
1671
|
const keys = this.client.getSipSessionIds();
|
|
1662
1672
|
const keyIndex = keys.findIndex(sessionId => callSession && callSession.isId(sessionId));
|
|
1663
1673
|
|
|
@@ -1673,7 +1683,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1673
1683
|
return this.callSessions[sipSessionId];
|
|
1674
1684
|
}
|
|
1675
1685
|
|
|
1676
|
-
getSipSessionId(sipSession:
|
|
1686
|
+
getSipSessionId(sipSession: WazoSession): string {
|
|
1677
1687
|
return this.client.getSipSessionId(sipSession);
|
|
1678
1688
|
}
|
|
1679
1689
|
|
|
@@ -1690,8 +1700,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1690
1700
|
}
|
|
1691
1701
|
}
|
|
1692
1702
|
|
|
1693
|
-
_onMessage(message: Message): void {
|
|
1694
|
-
// @ts-ignore
|
|
1703
|
+
_onMessage(message: Message & { method?: string, body?: string }): void {
|
|
1695
1704
|
if (!message || message.method !== 'MESSAGE') {
|
|
1696
1705
|
return;
|
|
1697
1706
|
}
|
|
@@ -1699,8 +1708,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1699
1708
|
let body;
|
|
1700
1709
|
|
|
1701
1710
|
try {
|
|
1702
|
-
|
|
1703
|
-
body = JSON.parse(message.body);
|
|
1711
|
+
body = JSON.parse(message.body || '');
|
|
1704
1712
|
} catch (e: any) {
|
|
1705
1713
|
return;
|
|
1706
1714
|
}
|
|
@@ -1725,7 +1733,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1725
1733
|
}
|
|
1726
1734
|
}
|
|
1727
1735
|
|
|
1728
|
-
_createIncomingCallSession(sipSession:
|
|
1736
|
+
_createIncomingCallSession(sipSession: WazoSession, cameraEnabled: boolean, fromSession?: CallSession | null | undefined, autoAnswer = false): CallSession {
|
|
1729
1737
|
return this._createCallSession(sipSession, fromSession, {
|
|
1730
1738
|
incoming: true,
|
|
1731
1739
|
ringing: true,
|
|
@@ -1734,7 +1742,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1734
1742
|
});
|
|
1735
1743
|
}
|
|
1736
1744
|
|
|
1737
|
-
_createOutgoingCallSession(sipSession:
|
|
1745
|
+
_createOutgoingCallSession(sipSession: WazoSession, cameraEnabled: boolean, fromSession?: CallSession): CallSession {
|
|
1738
1746
|
return this._createCallSession(sipSession, fromSession, {
|
|
1739
1747
|
incoming: false,
|
|
1740
1748
|
ringing: true,
|
|
@@ -1742,40 +1750,40 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1742
1750
|
});
|
|
1743
1751
|
}
|
|
1744
1752
|
|
|
1745
|
-
_createAcceptedCallSession(sipSession:
|
|
1753
|
+
_createAcceptedCallSession(sipSession: WazoSession, cameraEnabled?: boolean, fromSession?: CallSession): CallSession {
|
|
1746
1754
|
return this._createCallSession(sipSession, fromSession, {
|
|
1747
1755
|
cameraEnabled: cameraEnabled !== undefined ? cameraEnabled : false,
|
|
1748
1756
|
});
|
|
1749
1757
|
}
|
|
1750
1758
|
|
|
1751
|
-
_createMutedCallSession(sipSession:
|
|
1759
|
+
_createMutedCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession {
|
|
1752
1760
|
return this._createCallSession(sipSession, fromSession, {
|
|
1753
1761
|
muted: true,
|
|
1754
1762
|
});
|
|
1755
1763
|
}
|
|
1756
1764
|
|
|
1757
|
-
_createUnmutedCallSession(sipSession:
|
|
1765
|
+
_createUnmutedCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession {
|
|
1758
1766
|
return this._createCallSession(sipSession, fromSession, {
|
|
1759
1767
|
muted: false,
|
|
1760
1768
|
});
|
|
1761
1769
|
}
|
|
1762
1770
|
|
|
1763
|
-
_createCameraResumedCallSession(sipSession:
|
|
1771
|
+
_createCameraResumedCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession {
|
|
1764
1772
|
return this._createCallSession(sipSession, fromSession, {
|
|
1765
1773
|
videoMuted: false,
|
|
1766
1774
|
});
|
|
1767
1775
|
}
|
|
1768
1776
|
|
|
1769
|
-
_createCameraDisabledCallSession(sipSession:
|
|
1777
|
+
_createCameraDisabledCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession {
|
|
1770
1778
|
return this._createCallSession(sipSession, fromSession, {
|
|
1771
1779
|
videoMuted: true,
|
|
1772
1780
|
});
|
|
1773
1781
|
}
|
|
1774
1782
|
|
|
1775
|
-
_createCallSession(sipSession:
|
|
1783
|
+
_createCallSession(sipSession: WazoSession, fromSession?: CallSession | null | undefined, extra: Record<string, any> = {}): CallSession {
|
|
1776
1784
|
// eslint-disable-next-line
|
|
1777
1785
|
const identity = sipSession ? sipSession.remoteIdentity || sipSession.assertedIdentity : null;
|
|
1778
|
-
// @ts-ignore
|
|
1786
|
+
// @ts-ignore: private
|
|
1779
1787
|
const number = identity ? identity.uri._normal.user : null;
|
|
1780
1788
|
const {
|
|
1781
1789
|
state,
|
|
@@ -1787,7 +1795,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1787
1795
|
sipCallId: sessionId,
|
|
1788
1796
|
sipStatus: state,
|
|
1789
1797
|
displayName: identity ? identity.displayName || number : number,
|
|
1790
|
-
// @ts-ignore:
|
|
1798
|
+
// @ts-ignore: date / number
|
|
1791
1799
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
1792
1800
|
creationTime: fromSession ? fromSession.creationTime : null,
|
|
1793
1801
|
answerTime: fromSession ? fromSession.answerTime : null,
|
package/src/domain/Room.ts
CHANGED
|
@@ -2,15 +2,17 @@ import CallSession from './CallSession';
|
|
|
2
2
|
import newFrom from '../utils/new-from';
|
|
3
3
|
import updateFrom from '../utils/update-from';
|
|
4
4
|
|
|
5
|
+
type RoomParticipant = {
|
|
6
|
+
extension: string;
|
|
7
|
+
uuid: string;
|
|
8
|
+
talking?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
5
11
|
export type RoomArguments = {
|
|
6
12
|
connectedCallSession: CallSession | null;
|
|
7
13
|
id: string;
|
|
8
14
|
name?: string;
|
|
9
|
-
participants:
|
|
10
|
-
extension: string;
|
|
11
|
-
uuid: string;
|
|
12
|
-
talking: boolean | null | undefined;
|
|
13
|
-
}>;
|
|
15
|
+
participants: RoomParticipant[];
|
|
14
16
|
}; // Represents a conference room, like `9000`.
|
|
15
17
|
|
|
16
18
|
export default class Room {
|
|
@@ -20,11 +22,7 @@ export default class Room {
|
|
|
20
22
|
|
|
21
23
|
connectedCallSession: CallSession | null;
|
|
22
24
|
|
|
23
|
-
participants:
|
|
24
|
-
extension: string;
|
|
25
|
-
uuid: string;
|
|
26
|
-
talking: boolean | null | undefined;
|
|
27
|
-
}>;
|
|
25
|
+
participants: RoomParticipant[];
|
|
28
26
|
|
|
29
27
|
constructor({
|
|
30
28
|
id,
|
|
@@ -66,14 +64,14 @@ export default class Room {
|
|
|
66
64
|
return this;
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
updateParticipant(uuid: string, participant:
|
|
67
|
+
updateParticipant(uuid: string, participant: RoomParticipant, shouldAdd = false) {
|
|
70
68
|
const idx = this.participants.findIndex(someParticipant => someParticipant.uuid === uuid);
|
|
71
69
|
|
|
72
70
|
if (idx === -1 && !shouldAdd) {
|
|
73
71
|
return this;
|
|
74
72
|
}
|
|
75
73
|
|
|
76
|
-
const updatedParticipants
|
|
74
|
+
const updatedParticipants = [...this.participants];
|
|
77
75
|
|
|
78
76
|
if (idx !== -1) {
|
|
79
77
|
updatedParticipants[idx] = { ...updatedParticipants[idx],
|
|
@@ -88,14 +86,14 @@ export default class Room {
|
|
|
88
86
|
});
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
updateParticipantByExtension(extension: string, participant:
|
|
89
|
+
updateParticipantByExtension(extension: string, participant: RoomParticipant, shouldAdd = false) {
|
|
92
90
|
const idx = this.participants.findIndex(someParticipant => someParticipant.extension === extension);
|
|
93
91
|
|
|
94
92
|
if (idx === -1 && !shouldAdd) {
|
|
95
93
|
return this;
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
const updatedParticipants
|
|
96
|
+
const updatedParticipants = [...this.participants];
|
|
99
97
|
|
|
100
98
|
if (idx !== -1) {
|
|
101
99
|
updatedParticipants[idx] = { ...updatedParticipants[idx],
|