@wazo/sdk 0.39.15 → 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/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 +16 -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/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/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 +16 -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/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/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 +51 -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/simple/Phone.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SessionState } from 'sip.js/lib/api/session-state';
|
|
2
|
-
import { Inviter, Invitation } from 'sip.js/lib/api';
|
|
3
2
|
import { OutgoingInviteRequest } from 'sip.js/lib/core';
|
|
4
3
|
import type SipLine from '../domain/SipLine';
|
|
5
4
|
import type Session from '../domain/Session';
|
|
@@ -9,123 +8,17 @@ import WebRTCPhone, * as PHONE_EVENTS from '../domain/Phone/WebRTCPhone';
|
|
|
9
8
|
import { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL } from '../domain/Phone/WebRTCPhone';
|
|
10
9
|
import WazoWebRTCClient, { events as clientEvents, transportEvents } from '../web-rtc-client';
|
|
11
10
|
import IssueReporter from '../service/IssueReporter';
|
|
12
|
-
import Emitter
|
|
11
|
+
import Emitter from '../utils/Emitter';
|
|
13
12
|
import Wazo from './index';
|
|
14
13
|
import SFUNotAvailableError from '../domain/SFUNotAvailableError';
|
|
15
|
-
import { ConnectionOptions } from '../domain/types';
|
|
14
|
+
import { ConnectionOptions, WazoSession } from '../domain/types';
|
|
16
15
|
|
|
17
16
|
const logger = IssueReporter.loggerFor('simple-phone');
|
|
18
17
|
const sipLogger = IssueReporter.loggerFor('sip.js');
|
|
19
18
|
const protocolLogger = IssueReporter.loggerFor('sip');
|
|
20
19
|
const protocolDebugMessages = ['Received WebSocket text message:', 'Sending WebSocket message:'];
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
client: WazoWebRTCClient;
|
|
24
|
-
phone: WebRTCPhone | null | undefined;
|
|
25
|
-
session: Session;
|
|
26
|
-
sipLine: SipLine | null | undefined;
|
|
27
|
-
SessionState: Record<string, any>;
|
|
28
|
-
|
|
29
|
-
ON_USER_AGENT: string;
|
|
30
|
-
ON_REGISTERED: string;
|
|
31
|
-
ON_UNREGISTERED: string;
|
|
32
|
-
ON_PROGRESS: string;
|
|
33
|
-
ON_CALL_ACCEPTED: string;
|
|
34
|
-
ON_CALL_ANSWERED: string;
|
|
35
|
-
ON_CALL_INCOMING: string;
|
|
36
|
-
ON_CALL_OUTGOING: string;
|
|
37
|
-
ON_CALL_MUTED: string;
|
|
38
|
-
ON_CALL_UNMUTED: string;
|
|
39
|
-
ON_CALL_RESUMED: string;
|
|
40
|
-
ON_CALL_HELD: string;
|
|
41
|
-
ON_CALL_UNHELD: string;
|
|
42
|
-
ON_CAMERA_DISABLED: string;
|
|
43
|
-
ON_CAMERA_RESUMED: string;
|
|
44
|
-
ON_CALL_CANCELED: string;
|
|
45
|
-
ON_CALL_FAILED: string;
|
|
46
|
-
ON_CALL_REJECTED: string;
|
|
47
|
-
ON_CALL_ENDED: string;
|
|
48
|
-
ON_CALL_ENDING: string;
|
|
49
|
-
ON_MESSAGE: string;
|
|
50
|
-
ON_REINVITE: string;
|
|
51
|
-
ON_TRACK: string;
|
|
52
|
-
ON_AUDIO_STREAM: string;
|
|
53
|
-
ON_VIDEO_STREAM: string;
|
|
54
|
-
ON_REMOVE_STREAM: string;
|
|
55
|
-
ON_SHARE_SCREEN_STARTED: string;
|
|
56
|
-
ON_SHARE_SCREEN_ENDING: string;
|
|
57
|
-
ON_SHARE_SCREEN_ENDED: string;
|
|
58
|
-
ON_TERMINATE_SOUND: string;
|
|
59
|
-
ON_PLAY_RING_SOUND: string;
|
|
60
|
-
ON_PLAY_INBOUND_CALL_SIGNAL_SOUND: string;
|
|
61
|
-
ON_PLAY_HANGUP_SOUND: string;
|
|
62
|
-
ON_PLAY_PROGRESS_SOUND: string;
|
|
63
|
-
ON_VIDEO_INPUT_CHANGE: string;
|
|
64
|
-
ON_CALL_ERROR: string;
|
|
65
|
-
ON_MESSAGE_TRACK_UPDATED: string;
|
|
66
|
-
ON_NETWORK_STATS: string;
|
|
67
|
-
ON_CHAT: string;
|
|
68
|
-
ON_SIGNAL: string;
|
|
69
|
-
ON_DISCONNECTED: string;
|
|
70
|
-
ON_EARLY_MEDIA: string;
|
|
71
|
-
MESSAGE_TYPE_CHAT: string;
|
|
72
|
-
MESSAGE_TYPE_SIGNAL: string;
|
|
73
|
-
|
|
74
|
-
connect: (options: Partial<ConnectionOptions>, sipLine?: SipLine | null | undefined) => Promise<void>;
|
|
75
|
-
connectWithCredentials: (server: string, sipLine: SipLine, displayName: string, rawOptions: Partial<ConnectionOptions>) => void;
|
|
76
|
-
disconnect: () => Promise<void>;
|
|
77
|
-
call: (extension: string, withCamera: boolean, rawSipLine: SipLine | null | undefined, audioOnly: boolean, conference: boolean) => Promise<CallSession | null | undefined>;
|
|
78
|
-
hangup: (callSession: CallSession) => Promise<boolean> ;
|
|
79
|
-
startConference: (host: CallSession, otherCalls: CallSession[]) => Promise<AdHocAPIConference>;
|
|
80
|
-
mute: (callSession: CallSession, withApi?: boolean) => void;
|
|
81
|
-
unmute: (callSession: CallSession, withApi?: boolean) => void;
|
|
82
|
-
muteViaAPI: (callSession: CallSession) => void;
|
|
83
|
-
unmuteViaAPI: (callSession: CallSession) => void;
|
|
84
|
-
hold: (callSession: CallSession) => Promise<void | OutgoingInviteRequest> | null | undefined;
|
|
85
|
-
unhold: (callSession: CallSession) => Promise<MediaStream | void | null | undefined>;
|
|
86
|
-
resume: (callSession: CallSession) => Promise<MediaStream | null | void>;
|
|
87
|
-
reject: (callSession: CallSession) => Promise<void> | undefined;
|
|
88
|
-
transfer: (callSession: CallSession, target: string) => void;
|
|
89
|
-
atxfer: (callSession: CallSession) => Record<string, any> | null;
|
|
90
|
-
reinvite: (callSession: CallSession, constraints: (Record<string, any> | null), conference: boolean) => Promise<OutgoingInviteRequest | void | null>;
|
|
91
|
-
getStats: (callSession: CallSession) => Promise<RTCStatsReport | null | undefined>;
|
|
92
|
-
startNetworkMonitoring: (callSession: CallSession, interval: number) => void;
|
|
93
|
-
stopNetworkMonitoring: (callSession: CallSession) => void;
|
|
94
|
-
getSipSessionId: (sipSession: Invitation | Inviter) => string | null | undefined;
|
|
95
|
-
sendMessage: (body: string, sipSession?: Inviter | Invitation, contentType?: string) => void;
|
|
96
|
-
sendChat: (content: string, sipSession?: Inviter | Invitation) => void;
|
|
97
|
-
sendSignal: (content: any, sipSession?: Inviter | Invitation) => void ;
|
|
98
|
-
turnCameraOff: (callSession: CallSession) => void;
|
|
99
|
-
turnCameraOn: (callSession: CallSession) => void;
|
|
100
|
-
startScreenSharing: (constraints: Record<string, any>, callSession?: CallSession) => Promise<MediaStream | null>;
|
|
101
|
-
stopScreenSharing: (callSession?: CallSession, restoreLocalStream?: boolean) => Promise<OutgoingInviteRequest | void | null>;
|
|
102
|
-
sendDTMF: (tone: string, callSession: CallSession) => void;
|
|
103
|
-
getLocalStream: (callSession: CallSession) => MediaStream | null | undefined ;
|
|
104
|
-
hasLocalVideo: (callSession: CallSession) => boolean;
|
|
105
|
-
hasALocalVideoTrack: (callSession: CallSession) => boolean;
|
|
106
|
-
getLocalMediaStream: (callSession: CallSession) => MediaStream | null | undefined;
|
|
107
|
-
getLocalVideoStream: (callSession: CallSession) => MediaStream | null;
|
|
108
|
-
getRemoteStream: (callSession: CallSession) => MediaStream | null;
|
|
109
|
-
getRemoteVideoStream: (callSession: CallSession) => MediaStream | null ;
|
|
110
|
-
isVideoRemotelyHeld: (callSession: CallSession) => boolean;
|
|
111
|
-
getRemoteStreamForCall: (callSession: CallSession) => MediaStream | null;
|
|
112
|
-
getRemoteStreamsForCall: (callSession: CallSession) => MediaStream | null;
|
|
113
|
-
getRemoteVideoStreamForCall: (callSession: CallSession) => MediaStream | null;
|
|
114
|
-
getRemoteVideoStreamFromPc: (callSession: CallSession) => MediaStream | null;
|
|
115
|
-
hasVideo: (callSession: CallSession) => boolean;
|
|
116
|
-
hasAVideoTrack: (callSession: CallSession) => boolean;
|
|
117
|
-
getCurrentSipSession: () => Invitation | Inviter | null;
|
|
118
|
-
getPrimaryWebRtcLine: () => SipLine | null;
|
|
119
|
-
getOutputDevice: () => string | null ;
|
|
120
|
-
getPrimaryLine: () => SipLine | null;
|
|
121
|
-
getLineById: (lineId: string) => SipLine | null;
|
|
122
|
-
getSipLines: () => SipLine[];
|
|
123
|
-
hasSfu: () => boolean;
|
|
124
|
-
checkSfu: () => void;
|
|
125
|
-
_transferEvents: () => void;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
class Phone extends Emitter implements IPhone {
|
|
21
|
+
class Phone extends Emitter {
|
|
129
22
|
client: WazoWebRTCClient;
|
|
130
23
|
|
|
131
24
|
phone: WebRTCPhone | null | undefined;
|
|
@@ -228,7 +121,7 @@ class Phone extends Emitter implements IPhone {
|
|
|
228
121
|
super();
|
|
229
122
|
// Sugar syntax for `Wazo.Phone.EVENT_NAME`
|
|
230
123
|
Object.keys(PHONE_EVENTS).forEach((key: string) => {
|
|
231
|
-
// @ts-ignore
|
|
124
|
+
// @ts-ignore: keys
|
|
232
125
|
this[key] = PHONE_EVENTS[key];
|
|
233
126
|
});
|
|
234
127
|
this.SessionState = SessionState;
|
|
@@ -435,14 +328,14 @@ class Phone extends Emitter implements IPhone {
|
|
|
435
328
|
return this.phone ? this.phone.stopNetworkMonitoring(callSession) : null;
|
|
436
329
|
}
|
|
437
330
|
|
|
438
|
-
getSipSessionId(sipSession:
|
|
331
|
+
getSipSessionId(sipSession: WazoSession): string | null | undefined {
|
|
439
332
|
if (!sipSession || !this.phone) {
|
|
440
333
|
return null;
|
|
441
334
|
}
|
|
442
335
|
return this.phone.getSipSessionId(sipSession);
|
|
443
336
|
}
|
|
444
337
|
|
|
445
|
-
sendMessage(body: string, sipSession?:
|
|
338
|
+
sendMessage(body: string, sipSession?: WazoSession, contentType = 'text/plain'): void {
|
|
446
339
|
const toSipSession = sipSession || this.getCurrentSipSession();
|
|
447
340
|
|
|
448
341
|
if (!toSipSession || !this.phone) {
|
|
@@ -452,14 +345,14 @@ class Phone extends Emitter implements IPhone {
|
|
|
452
345
|
this.phone.sendMessage(toSipSession, body, contentType);
|
|
453
346
|
}
|
|
454
347
|
|
|
455
|
-
sendChat(content: string, sipSession?:
|
|
348
|
+
sendChat(content: string, sipSession?: WazoSession): void {
|
|
456
349
|
this.sendMessage(JSON.stringify({
|
|
457
350
|
type: MESSAGE_TYPE_CHAT,
|
|
458
351
|
content,
|
|
459
352
|
}), sipSession, 'application/json');
|
|
460
353
|
}
|
|
461
354
|
|
|
462
|
-
sendSignal(content: any, sipSession?:
|
|
355
|
+
sendSignal(content: any, sipSession?: WazoSession): void {
|
|
463
356
|
this.sendMessage(JSON.stringify({
|
|
464
357
|
type: MESSAGE_TYPE_SIGNAL,
|
|
465
358
|
content,
|
|
@@ -552,7 +445,7 @@ class Phone extends Emitter implements IPhone {
|
|
|
552
445
|
return this.phone ? this.phone.hasAVideoTrack(callSession) : false;
|
|
553
446
|
}
|
|
554
447
|
|
|
555
|
-
getCurrentSipSession():
|
|
448
|
+
getCurrentSipSession(): WazoSession | null {
|
|
556
449
|
return this.phone?.currentSipSession || null;
|
|
557
450
|
}
|
|
558
451
|
|
package/src/simple/Websocket.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Session from '../domain/Session';
|
|
2
2
|
import WazoWebSocketClient, * as WebSocketClient from '../websocket-client';
|
|
3
|
-
import Emitter
|
|
3
|
+
import Emitter from '../utils/Emitter';
|
|
4
4
|
import IssueReporter from '../service/IssueReporter';
|
|
5
5
|
import { obfuscateToken } from '../utils/string';
|
|
6
6
|
|
|
@@ -11,23 +11,7 @@ const {
|
|
|
11
11
|
const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
|
|
12
12
|
const logger = IssueReporter.loggerFor('simple-ws-client');
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
ws: WazoWebSocketClient | null | undefined;
|
|
16
|
-
eventLists: string[];
|
|
17
|
-
|
|
18
|
-
CONFERENCE_USER_PARTICIPANT_JOINED: string;
|
|
19
|
-
CONFERENCE_USER_PARTICIPANT_LEFT: string;
|
|
20
|
-
MEETING_USER_PARTICIPANT_JOINED: string;
|
|
21
|
-
MEETING_USER_PARTICIPANT_LEFT: string;
|
|
22
|
-
CALL_CREATED: string;
|
|
23
|
-
|
|
24
|
-
open: (host: string, session: Session) => void;
|
|
25
|
-
updateToken: (token: string) => void;
|
|
26
|
-
isOpen: () => boolean;
|
|
27
|
-
close: (force?: boolean) => void;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
class Websocket extends Emitter implements IWebsocket {
|
|
14
|
+
class Websocket extends Emitter {
|
|
31
15
|
ws: WazoWebSocketClient | null | undefined;
|
|
32
16
|
|
|
33
17
|
eventLists: string[];
|
|
@@ -46,11 +30,11 @@ class Websocket extends Emitter implements IWebsocket {
|
|
|
46
30
|
super();
|
|
47
31
|
// Sugar syntax for `Wazo.WebSocket.EVENT_NAME`
|
|
48
32
|
Object.keys(OTHER_EVENTS).forEach(key => {
|
|
49
|
-
// @ts-ignore
|
|
33
|
+
// @ts-ignore: keys
|
|
50
34
|
this[key] = OTHER_EVENTS[key];
|
|
51
35
|
});
|
|
52
36
|
Object.keys(SOCKET_EVENTS).forEach(key => {
|
|
53
|
-
// @ts-ignore
|
|
37
|
+
// @ts-ignore: keys
|
|
54
38
|
this[key] = SOCKET_EVENTS[key];
|
|
55
39
|
});
|
|
56
40
|
this.eventLists = WazoWebSocketClient.eventLists;
|
package/src/simple/index.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/* global window */
|
|
2
|
-
import Auth, {
|
|
3
|
-
import Phone
|
|
4
|
-
import Websocket
|
|
2
|
+
import Auth, { InvalidSubscription, InvalidAuthorization, NoTenantIdError, NoDomainNameError } from './Auth';
|
|
3
|
+
import Phone from './Phone';
|
|
4
|
+
import Websocket from './Websocket';
|
|
5
5
|
import Room from './room/Room';
|
|
6
6
|
import SipRoom from './room/SipRoom';
|
|
7
7
|
import RemoteParticipant from './room/RemoteParticipant';
|
|
8
8
|
import LocalParticipant from './room/LocalParticipant';
|
|
9
|
+
import Participant from './room/Participant';
|
|
9
10
|
import Stream from './room/Stream';
|
|
10
11
|
import Directory from './Directory';
|
|
11
12
|
import Configuration from './Configuration';
|
|
@@ -40,13 +41,14 @@ import Meeting from '../domain/Meeting';
|
|
|
40
41
|
import Checker from '../checker/Checker';
|
|
41
42
|
|
|
42
43
|
const Wazo = {
|
|
43
|
-
Auth
|
|
44
|
-
Phone
|
|
45
|
-
Websocket
|
|
44
|
+
Auth,
|
|
45
|
+
Phone,
|
|
46
|
+
Websocket,
|
|
46
47
|
Room,
|
|
47
48
|
SipRoom,
|
|
48
49
|
RemoteParticipant,
|
|
49
50
|
LocalParticipant,
|
|
51
|
+
Participant,
|
|
50
52
|
Stream,
|
|
51
53
|
createLocalVideoStream,
|
|
52
54
|
createLocalAudioStream,
|
|
@@ -138,7 +140,6 @@ const Wazo = {
|
|
|
138
140
|
};
|
|
139
141
|
|
|
140
142
|
if (window) {
|
|
141
|
-
// @ts-ignore
|
|
142
143
|
window.Wazo = Wazo;
|
|
143
144
|
}
|
|
144
145
|
|
|
@@ -4,6 +4,7 @@ import Phone from '../Phone';
|
|
|
4
4
|
import Room, { SIGNAL_TYPE_PARTICIPANT_UPDATE } from './Room';
|
|
5
5
|
import Contact from '../../domain/Contact';
|
|
6
6
|
import getApiClient from '../../service/getApiClient';
|
|
7
|
+
import Stream from './Stream';
|
|
7
8
|
|
|
8
9
|
const logger = IssueReporter.loggerFor('room');
|
|
9
10
|
|
|
@@ -27,9 +28,9 @@ class Participant extends Emitter {
|
|
|
27
28
|
|
|
28
29
|
isTalking: boolean;
|
|
29
30
|
|
|
30
|
-
streams:
|
|
31
|
+
streams: Stream[];
|
|
31
32
|
|
|
32
|
-
videoStreams:
|
|
33
|
+
videoStreams: Stream[];
|
|
33
34
|
|
|
34
35
|
audioMuted: boolean;
|
|
35
36
|
|
|
@@ -371,7 +372,7 @@ class Participant extends Emitter {
|
|
|
371
372
|
});
|
|
372
373
|
}
|
|
373
374
|
|
|
374
|
-
resetStreams(streams:
|
|
375
|
+
resetStreams(streams: Stream[]) {
|
|
375
376
|
this.streams = streams;
|
|
376
377
|
this.videoStreams = streams;
|
|
377
378
|
}
|
package/src/simple/room/Room.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Message } from 'sip.js/lib/api/message';
|
|
2
2
|
import sdpParser from 'sdp-transform';
|
|
3
|
-
import {
|
|
3
|
+
import { SessionDescriptionHandler } from 'sip.js/lib/platform/web';
|
|
4
4
|
import type CallSession from '../../domain/CallSession';
|
|
5
5
|
import getApiClient from '../../service/getApiClient';
|
|
6
6
|
import Emitter from '../../utils/Emitter';
|
|
@@ -9,11 +9,21 @@ import Participant, { RawParticipant } from './Participant';
|
|
|
9
9
|
import RemoteParticipant from './RemoteParticipant';
|
|
10
10
|
import IssueReporter from '../../service/IssueReporter';
|
|
11
11
|
import LocalParticipant from './LocalParticipant';
|
|
12
|
+
import { PeerConnection, WazoSession } from '../../domain/types';
|
|
12
13
|
|
|
13
14
|
export const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
|
|
14
15
|
export const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
|
|
15
16
|
const logger = IssueReporter.loggerFor('sdk-room');
|
|
16
17
|
|
|
18
|
+
type ConnectArgs = {
|
|
19
|
+
extension: string;
|
|
20
|
+
constraints: Record<string, any>;
|
|
21
|
+
audioOnly?: boolean;
|
|
22
|
+
extra?: Record<string, any>;
|
|
23
|
+
room: Room;
|
|
24
|
+
meeting: any;
|
|
25
|
+
};
|
|
26
|
+
|
|
17
27
|
class Room extends Emitter {
|
|
18
28
|
callSession: CallSession | null | undefined;
|
|
19
29
|
|
|
@@ -31,13 +41,13 @@ class Room extends Emitter {
|
|
|
31
41
|
|
|
32
42
|
connected: boolean;
|
|
33
43
|
|
|
34
|
-
localParticipant:
|
|
44
|
+
localParticipant: LocalParticipant | null | undefined;
|
|
35
45
|
|
|
36
46
|
_callIdStreamIdMap: Record<string, any>;
|
|
37
47
|
|
|
38
|
-
_unassociatedVideoStreams: Record<string,
|
|
48
|
+
_unassociatedVideoStreams: Record<string, MediaStream>;
|
|
39
49
|
|
|
40
|
-
_unassociatedParticipants: Record<string,
|
|
50
|
+
_unassociatedParticipants: Record<string, Participant>;
|
|
41
51
|
|
|
42
52
|
_boundOnParticipantJoined: (...args: Array<any>) => any;
|
|
43
53
|
|
|
@@ -53,12 +63,12 @@ class Room extends Emitter {
|
|
|
53
63
|
|
|
54
64
|
_boundOnReinvite: (...args: Array<any>) => any;
|
|
55
65
|
|
|
56
|
-
audioStream:
|
|
66
|
+
audioStream: MediaStream | null | undefined;
|
|
57
67
|
|
|
58
68
|
extra: Record<string, any>;
|
|
59
69
|
|
|
60
70
|
// video tag representing the room audio stream
|
|
61
|
-
roomAudioElement:
|
|
71
|
+
roomAudioElement: HTMLAudioElement;
|
|
62
72
|
|
|
63
73
|
CONFERENCE_USER_PARTICIPANT_JOINED: string;
|
|
64
74
|
|
|
@@ -170,7 +180,7 @@ class Room extends Emitter {
|
|
|
170
180
|
extra,
|
|
171
181
|
room,
|
|
172
182
|
meeting,
|
|
173
|
-
}:
|
|
183
|
+
}: ConnectArgs) {
|
|
174
184
|
logger.info('connecting to room', {
|
|
175
185
|
extension,
|
|
176
186
|
audioOnly,
|
|
@@ -190,7 +200,7 @@ class Room extends Emitter {
|
|
|
190
200
|
// Call_created is triggered before call_accepted, so we have to listen for it here.
|
|
191
201
|
Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({
|
|
192
202
|
data,
|
|
193
|
-
}) => {
|
|
203
|
+
}: { data: Record<string, any> }) => {
|
|
194
204
|
logger.info('room call received via WS', {
|
|
195
205
|
callId: data.call_id,
|
|
196
206
|
});
|
|
@@ -200,8 +210,9 @@ class Room extends Emitter {
|
|
|
200
210
|
}
|
|
201
211
|
});
|
|
202
212
|
const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
|
|
213
|
+
// @ts-fix: heads up: added an extra `null` here
|
|
203
214
|
// eslint-disable-next-line no-param-reassign
|
|
204
|
-
room = new Room(callSession as CallSession, extension, null, null, extra);
|
|
215
|
+
room = new Room(callSession as CallSession, extension, null, null, null, extra);
|
|
205
216
|
// Wait for the call to be accepted
|
|
206
217
|
await new Promise((resolve, reject) => {
|
|
207
218
|
Wazo.Phone.once(Wazo.Phone.ON_CALL_ACCEPTED, resolve);
|
|
@@ -226,8 +237,8 @@ class Room extends Emitter {
|
|
|
226
237
|
});
|
|
227
238
|
|
|
228
239
|
if (conference) {
|
|
229
|
-
room.setSourceId(conference.sourceId);
|
|
230
|
-
room.setName(conference.name);
|
|
240
|
+
room.setSourceId(parseInt(`${conference.sourceId}`, 10));
|
|
241
|
+
room.setName(`${conference.name}`);
|
|
231
242
|
}
|
|
232
243
|
} else if (meeting) {
|
|
233
244
|
logger.info('Already connected to meeting', {
|
|
@@ -467,8 +478,7 @@ class Room extends Emitter {
|
|
|
467
478
|
}
|
|
468
479
|
|
|
469
480
|
// Retrieve mapping
|
|
470
|
-
|
|
471
|
-
Wazo.Phone.phone.currentSipSession.sessionDescriptionHandler.on('setDescription', ({
|
|
481
|
+
(Wazo.Phone.phone.currentSipSession.sessionDescriptionHandler as SessionDescriptionHandler & { on: (input: string, options?: Record<string, any>) => void })?.on('setDescription', ({
|
|
472
482
|
type,
|
|
473
483
|
sdp: rawSdp,
|
|
474
484
|
}: any) => {
|
|
@@ -486,7 +496,7 @@ class Room extends Emitter {
|
|
|
486
496
|
this.audioStream = stream;
|
|
487
497
|
|
|
488
498
|
if (!this.roomAudioElement) {
|
|
489
|
-
const sessionId = Wazo.Phone.phone?.getSipSessionId(Wazo.Phone.phone?.currentSipSession as
|
|
499
|
+
const sessionId = Wazo.Phone.phone?.getSipSessionId(Wazo.Phone.phone?.currentSipSession as WazoSession);
|
|
490
500
|
this.roomAudioElement = Wazo.Phone.phone?.createAudioElementFor(sessionId as string);
|
|
491
501
|
this.roomAudioElement.srcObject = stream;
|
|
492
502
|
} else {
|
|
@@ -546,13 +556,11 @@ class Room extends Emitter {
|
|
|
546
556
|
|
|
547
557
|
_mapMsid(rawSdp: string) {
|
|
548
558
|
const sdp = sdpParser.parse(rawSdp);
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
msid,
|
|
552
|
-
}: any) => ({
|
|
559
|
+
// @ts-ignore: Property 'label' does not exist
|
|
560
|
+
const labelMsidArray = sdp.media.filter((media) => !!media.label).map(({ label, msid }) => ({
|
|
553
561
|
label: String(label),
|
|
554
|
-
streamId: msid
|
|
555
|
-
trackId: msid
|
|
562
|
+
streamId: msid?.split(' ')[0],
|
|
563
|
+
trackId: msid?.split(' ')[1],
|
|
556
564
|
}));
|
|
557
565
|
labelMsidArray.forEach(({
|
|
558
566
|
label,
|
|
@@ -583,21 +591,19 @@ class Room extends Emitter {
|
|
|
583
591
|
Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
|
|
584
592
|
Wazo.Phone.on(this.ON_SIGNAL, this._boundOnSignal);
|
|
585
593
|
Wazo.Phone.on(this.ON_VIDEO_INPUT_CHANGE, this._boundSaveLocalVideoStream);
|
|
586
|
-
[this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event => Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
|
|
594
|
+
[this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event => Wazo.Phone.on(event, (...args: any[]) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
|
|
587
595
|
}
|
|
588
596
|
|
|
589
|
-
_onMessage(message: Message): Record<string, any> | null | undefined {
|
|
590
|
-
// @ts-ignore
|
|
597
|
+
_onMessage(message: Message & { method?: string, body?: string }): Record<string, any> | null | undefined {
|
|
591
598
|
if (message.method !== 'MESSAGE') {
|
|
592
599
|
return null;
|
|
593
600
|
}
|
|
594
601
|
|
|
595
|
-
let body
|
|
602
|
+
let body;
|
|
596
603
|
|
|
597
604
|
try {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
} catch (e: any) {
|
|
605
|
+
body = JSON.parse(message.body as string);
|
|
606
|
+
} catch (e) {
|
|
601
607
|
return null;
|
|
602
608
|
}
|
|
603
609
|
|
|
@@ -731,7 +737,7 @@ class Room extends Emitter {
|
|
|
731
737
|
});
|
|
732
738
|
response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
|
|
733
739
|
}
|
|
734
|
-
} catch (e
|
|
740
|
+
} catch (e) {
|
|
735
741
|
logger.error('room participants fetching, error', e);
|
|
736
742
|
}
|
|
737
743
|
|
|
@@ -744,7 +750,7 @@ class Room extends Emitter {
|
|
|
744
750
|
return isMe && item.call_id ? new Wazo.LocalParticipant(this, item, this.extra) : new Wazo.RemoteParticipant(this, item);
|
|
745
751
|
});
|
|
746
752
|
this.participants = participants;
|
|
747
|
-
const localParticipant = participants.find((someParticipant:
|
|
753
|
+
const localParticipant = participants.find((someParticipant: Participant) => someParticipant instanceof Wazo.LocalParticipant);
|
|
748
754
|
|
|
749
755
|
if (!this.localParticipant && localParticipant) {
|
|
750
756
|
this._onLocalParticipantJoined(localParticipant);
|
|
@@ -839,10 +845,10 @@ class Room extends Emitter {
|
|
|
839
845
|
trackId,
|
|
840
846
|
streamId,
|
|
841
847
|
} = this._callIdStreamIdMap[newParticipant.callId] || {};
|
|
842
|
-
|
|
843
|
-
const pc = Wazo.Phone.phone
|
|
848
|
+
|
|
849
|
+
const pc = (Wazo.Phone.phone?.currentSipSession?.sessionDescriptionHandler as SessionDescriptionHandler)?.peerConnection as PeerConnection;
|
|
844
850
|
// Can't use `getReceivers` here because on FF we make the mapping based on the streamId
|
|
845
|
-
const stream = pc.getRemoteStreams().find(
|
|
851
|
+
const stream = pc.getRemoteStreams().find(someStream => someStream.id === streamId || someStream.getTracks().some(track => track.id === trackId));
|
|
846
852
|
|
|
847
853
|
if (update === 'downgrade') {
|
|
848
854
|
newParticipant.resetStreams([]);
|
|
@@ -875,15 +881,17 @@ class Room extends Emitter {
|
|
|
875
881
|
|
|
876
882
|
const streamId = this._getStreamIdFrTrackId(trackId);
|
|
877
883
|
|
|
878
|
-
const key
|
|
884
|
+
const key = this._getUnassociatedMapIdFromTrackIdOrStreamId(trackId, streamId);
|
|
879
885
|
|
|
880
|
-
const stream = this._unassociatedVideoStreams[key];
|
|
886
|
+
const stream = key ? this._unassociatedVideoStreams[key] : null;
|
|
881
887
|
|
|
882
888
|
if (stream) {
|
|
883
889
|
// Try to associate stream
|
|
884
890
|
this._associateStreamTo(stream, participant);
|
|
885
891
|
|
|
886
|
-
|
|
892
|
+
if (key) {
|
|
893
|
+
delete this._unassociatedVideoStreams[key];
|
|
894
|
+
}
|
|
887
895
|
delete this._unassociatedParticipants[participant.callId];
|
|
888
896
|
}
|
|
889
897
|
}
|
|
@@ -909,7 +917,7 @@ class Room extends Emitter {
|
|
|
909
917
|
return mapping ? mapping.streamId : null;
|
|
910
918
|
}
|
|
911
919
|
|
|
912
|
-
_associateStreamTo(rawStream:
|
|
920
|
+
_associateStreamTo(rawStream: MediaStream, participant: Participant) {
|
|
913
921
|
const stream = new Wazo.Stream(rawStream, participant);
|
|
914
922
|
participant.streams.push(stream);
|
|
915
923
|
participant.videoStreams.push(stream);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Invitation, Inviter } from 'sip.js';
|
|
2
1
|
import type { Message } from 'sip.js/lib/api/message';
|
|
3
2
|
import CallSession from '../../domain/CallSession';
|
|
4
3
|
import IssueReporter from '../../service/IssueReporter';
|
|
5
4
|
import Wazo from '../index';
|
|
6
5
|
import Room from './Room';
|
|
6
|
+
import { WazoSession } from '../../domain/types';
|
|
7
7
|
|
|
8
8
|
const logger = IssueReporter.loggerFor('sdk-sip-room');
|
|
9
9
|
|
|
@@ -54,7 +54,7 @@ class SipRoom extends Room {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
getLocalGuestName(): string | null {
|
|
57
|
-
// @ts-ignore
|
|
57
|
+
// @ts-ignore: private
|
|
58
58
|
return Wazo.Phone.phone?.client.userAgent?.options.displayName || null;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -65,7 +65,7 @@ class SipRoom extends Room {
|
|
|
65
65
|
Wazo.Phone.on(this.ON_CHAT, this._boundOnChat);
|
|
66
66
|
Wazo.Phone.on(this.ON_SIGNAL, this._boundOnSignal);
|
|
67
67
|
Wazo.Phone.on(this.ON_VIDEO_INPUT_CHANGE, this._boundSaveLocalVideoStream);
|
|
68
|
-
[this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event => Wazo.Phone.on(event, (...args) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
|
|
68
|
+
[this.ON_AUDIO_STREAM, this.ON_VIDEO_STREAM, this.ON_REMOVE_STREAM].forEach(event => Wazo.Phone.on(event, (...args: any[]) => this.eventEmitter.emit.apply(this.eventEmitter, [event, ...args])));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
_onMessage(message: Message): Record<string, any> | null | undefined {
|
|
@@ -156,7 +156,7 @@ class SipRoom extends Room {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
_getCurrentSipCallIs() {
|
|
159
|
-
return Wazo.Phone.getSipSessionId(Wazo.Phone.phone?.currentSipSession as
|
|
159
|
+
return Wazo.Phone.getSipSessionId(Wazo.Phone.phone?.currentSipSession as WazoSession);
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
}
|
|
@@ -9,7 +9,7 @@ class Stream {
|
|
|
9
9
|
|
|
10
10
|
participant: Participant | undefined;
|
|
11
11
|
|
|
12
|
-
static detachStream(stream:
|
|
12
|
+
static detachStream(stream: MediaStream) {
|
|
13
13
|
stream.getTracks()
|
|
14
14
|
.filter((track: MediaStreamTrack) => track.enabled)
|
|
15
15
|
.forEach((track: MediaStreamTrack) => track.stop());
|
|
@@ -34,9 +34,8 @@ class Stream {
|
|
|
34
34
|
|
|
35
35
|
element.onloadedmetadata = () => {
|
|
36
36
|
const tracks = this.htmlStream ? this.htmlStream.getVideoTracks() : [];
|
|
37
|
-
tracks.forEach(track => {
|
|
37
|
+
tracks.forEach((track: MediaStreamTrack & { loaded?: boolean }) => {
|
|
38
38
|
track.enabled = true;
|
|
39
|
-
// @ts-ignore
|
|
40
39
|
track.loaded = true;
|
|
41
40
|
});
|
|
42
41
|
};
|
|
@@ -26,8 +26,7 @@ describe('Participant', () => {
|
|
|
26
26
|
const room = new Room();
|
|
27
27
|
room.setMeetingUuid(meetingUuid);
|
|
28
28
|
const banMeetingParticipant = jest.fn();
|
|
29
|
-
|
|
30
|
-
getApiClient.mockImplementation(() => ({
|
|
29
|
+
(getApiClient as any).mockImplementation(() => ({
|
|
31
30
|
calld: {
|
|
32
31
|
banMeetingParticipant,
|
|
33
32
|
},
|
|
@@ -52,8 +51,7 @@ describe('Participant', () => {
|
|
|
52
51
|
const room = new Room();
|
|
53
52
|
room.setMeetingUuid(meetingUuid);
|
|
54
53
|
const banMeetingParticipant = jest.fn();
|
|
55
|
-
|
|
56
|
-
getApiClient.mockImplementation(() => ({
|
|
54
|
+
(getApiClient as any).mockImplementation(() => ({
|
|
57
55
|
calld: {
|
|
58
56
|
banMeetingParticipant,
|
|
59
57
|
},
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// Using directly Wazo to avoid issues with require cycle
|
|
2
2
|
import Wazo from '../../index';
|
|
3
|
+
import { RawParticipant } from '../Participant';
|
|
4
|
+
import Room from '../Room';
|
|
3
5
|
|
|
4
6
|
describe('RemoteParticipant', () => {
|
|
5
7
|
it('should fall back on number when name is <unknown>', () => {
|
|
6
8
|
const number = '1234';
|
|
7
|
-
|
|
8
|
-
const participant = new Wazo.RemoteParticipant(null, {
|
|
9
|
+
const participant = new Wazo.RemoteParticipant({} as Room, {
|
|
9
10
|
caller_id_name: '<unknown>',
|
|
10
11
|
caller_id_number: number,
|
|
11
|
-
});
|
|
12
|
+
} as RawParticipant);
|
|
12
13
|
expect(participant.name).toEqual(number);
|
|
13
14
|
});
|
|
14
15
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '@wazo/sdk';
|
|
@@ -59,7 +59,7 @@ const getDisplayableNumber = (rawNumber: string, country: string, asYouType = fa
|
|
|
59
59
|
|
|
60
60
|
const parsePhoneNumber = (phoneNumber: string): string => phoneNumber.replace(EXTRA_CHAR_REGEXP, '');
|
|
61
61
|
|
|
62
|
-
const getCallableNumber = (number: string, country
|
|
62
|
+
const getCallableNumber = (number: string, country?: string | null): string | null | undefined => {
|
|
63
63
|
try {
|
|
64
64
|
if (country) {
|
|
65
65
|
return getDisplayableNumber(number, country).replace(EXTRA_CHAR_REGEXP, '');
|
|
@@ -44,17 +44,11 @@ describe('getCallableNumber', () => {
|
|
|
44
44
|
expect(getCallableNumber('9000', 'US')).toBe('9000');
|
|
45
45
|
});
|
|
46
46
|
it('works without a country', () => {
|
|
47
|
-
// @ts-expect-error
|
|
48
47
|
expect(getCallableNumber('06 75 45')).toBe('067545');
|
|
49
|
-
// @ts-expect-error
|
|
50
48
|
expect(getCallableNumber('067-545')).toBe('067545');
|
|
51
|
-
// @ts-expect-error
|
|
52
49
|
expect(getCallableNumber('8008')).toBe('8008');
|
|
53
|
-
// @ts-expect-error
|
|
54
50
|
expect(getCallableNumber('80.08')).toBe('8008');
|
|
55
|
-
// @ts-expect-error
|
|
56
51
|
expect(getCallableNumber('*10')).toBe('*10');
|
|
57
|
-
// @ts-expect-error
|
|
58
52
|
expect(getCallableNumber('9000')).toBe('9000');
|
|
59
53
|
});
|
|
60
54
|
});
|