@wazo/sdk 0.38.22 → 0.39.0-beta.2
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 +0 -293
- package/dist/wazo-sdk.js +9 -25
- package/esm/__tests__/api-client.test.js +183 -5059
- package/esm/__tests__/web-rtc-client.test.js +177 -7930
- package/esm/api/agentd.js +23 -832
- package/esm/api/amid.js +9 -411
- package/esm/api/application.js +60 -829
- package/esm/api/auth.js +164 -1213
- package/esm/api/call-logd.js +24 -733
- package/esm/api/calld.js +114 -1469
- package/esm/api/chatd.js +35 -1312
- package/esm/api/confd.js +67 -1580
- package/esm/api/ctid-ng.js +92 -1343
- package/esm/api/dird.js +100 -1590
- package/esm/api/webhookd.js +7 -513
- package/esm/api-client.js +143 -4881
- package/esm/checker/Checker.js +45 -8727
- package/esm/checker/checks/aor.js +24 -4924
- package/esm/checker/checks/api.js +70 -4968
- package/esm/checker/checks/ice-ipv4.js +63 -117
- package/esm/checker/checks/index.js +8 -8677
- package/esm/checker/checks/symmetric-nat.js +54 -102
- package/esm/checker/checks/wazo-websocket.js +34 -999
- package/esm/checker/checks/webrtc-transport.js +28 -7845
- package/esm/checker/checks/webrtc.js +31 -7852
- package/esm/domain/AdHocAPIConference.js +86 -5115
- package/esm/domain/Agent.js +27 -61
- package/esm/domain/BadResponse.js +20 -43
- package/esm/domain/Call.js +120 -210
- package/esm/domain/CallLog.js +123 -305
- package/esm/domain/CallSession.js +251 -423
- package/esm/domain/ChatMessage.js +52 -105
- package/esm/domain/ChatRoom.js +28 -60
- package/esm/domain/Contact.js +430 -741
- package/esm/domain/Country.js +17 -19
- package/esm/domain/Device/DebugDevice.js +31 -47
- package/esm/domain/Device/Device.js +1 -1
- package/esm/domain/DirectorySource.js +1 -1
- package/esm/domain/ExternalApp.js +23 -56
- package/esm/domain/Features.js +57 -5009
- package/esm/domain/ForwardOption.js +35 -70
- package/esm/domain/IndirectTransfer.js +38 -97
- package/esm/domain/Line.js +37 -88
- package/esm/domain/Meeting.js +58 -113
- package/esm/domain/MeetingAuthorization.js +38 -68
- package/esm/domain/MeetingStatus.js +13 -28
- package/esm/domain/NotificationOptions.js +43 -77
- package/esm/domain/Phone/CTIPhone.js +245 -5743
- package/esm/domain/Phone/Phone.js +1 -2
- package/esm/domain/Phone/WebRTCPhone.js +1450 -2670
- package/esm/domain/Profile.js +120 -405
- package/esm/domain/Recording.js +27 -51
- package/esm/domain/Relocation.js +16 -40
- package/esm/domain/Room.js +90 -133
- package/esm/domain/SFUNotAvailableError.js +5 -8
- package/esm/domain/ServerError.js +8 -61
- package/esm/domain/Session.js +125 -251
- package/esm/domain/SipLine.js +78 -155
- package/esm/domain/Subscription.js +39 -83
- package/esm/domain/SwitchboardCall.js +51 -143
- package/esm/domain/Voicemail.js +57 -122
- package/esm/domain/__tests__/Agent.test.js +31 -101
- package/esm/domain/__tests__/Call.test.js +24 -232
- package/esm/domain/__tests__/CallLog.test.js +60 -386
- package/esm/domain/__tests__/CallSession.test.js +74 -502
- package/esm/domain/__tests__/Contact.test.js +220 -902
- package/esm/domain/__tests__/IndirectTransfer.test.js +63 -546
- package/esm/domain/__tests__/Line.test.js +48 -156
- package/esm/domain/__tests__/Meeting.test.js +73 -226
- package/esm/domain/__tests__/MeetingAuthorization.test.js +45 -105
- package/esm/domain/__tests__/Profile.test.js +135 -496
- package/esm/domain/__tests__/Room.test.js +227 -719
- package/esm/domain/__tests__/Session.test.js +357 -1025
- package/esm/domain/__tests__/SipLine.test.js +24 -179
- package/esm/domain/__tests__/Voicemail.test.js +82 -200
- package/esm/domain/types.js +1 -1
- package/esm/index.js +63 -14985
- package/esm/lib/WazoSessionDescriptionHandler.js +406 -890
- package/esm/pubkey.js +10 -0
- package/esm/service/CallApi.js +42 -5014
- package/esm/service/IssueReporter.js +278 -360
- package/esm/service/__tests__/IssueReporter.test.js +92 -494
- package/esm/service/getApiClient.js +53 -4972
- package/esm/simple/Auth.js +212 -14747
- package/esm/simple/Configuration.js +8 -14796
- package/esm/simple/Directory.js +6 -4964
- package/esm/simple/Phone.js +309 -14727
- package/esm/simple/Websocket.js +68 -1112
- package/esm/simple/index.js +125 -14792
- package/esm/simple/room/LocalParticipant.js +1 -14797
- package/esm/simple/room/Participant.js +274 -14760
- package/esm/simple/room/RemoteParticipant.js +6 -14796
- package/esm/simple/room/Room.js +648 -14736
- package/esm/simple/room/SipRoom.js +111 -14790
- package/esm/simple/room/Stream.js +40 -14792
- package/esm/simple/room/__tests__/Participant.test.js +68 -14872
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +10 -14805
- package/esm/simple/utils.js +9 -14799
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/types/__tests__/api-client.test.d.ts +2 -0
- package/esm/types/__tests__/api-client.test.d.ts.map +1 -0
- package/esm/types/__tests__/web-rtc-client.test.d.ts +2 -0
- package/esm/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
- package/esm/types/api/agentd.d.ts +17 -0
- package/esm/types/api/agentd.d.ts.map +1 -0
- package/esm/types/api/amid.d.ts +8 -0
- package/esm/types/api/amid.d.ts.map +1 -0
- package/esm/types/api/application.d.ts +34 -0
- package/esm/types/api/application.d.ts.map +1 -0
- package/esm/types/api/auth.d.ts +64 -0
- package/esm/types/api/auth.d.ts.map +1 -0
- package/esm/types/api/call-logd.d.ts +12 -0
- package/esm/types/api/call-logd.d.ts.map +1 -0
- package/esm/types/api/calld.d.ts +51 -0
- package/esm/types/api/calld.d.ts.map +1 -0
- package/esm/types/api/chatd.d.ts +42 -0
- package/esm/types/api/chatd.d.ts.map +1 -0
- package/esm/types/api/confd.d.ts +39 -0
- package/esm/types/api/confd.d.ts.map +1 -0
- package/esm/types/api/ctid-ng.d.ts +36 -0
- package/esm/types/api/ctid-ng.d.ts.map +1 -0
- package/esm/types/api/dird.d.ts +38 -0
- package/esm/types/api/dird.d.ts.map +1 -0
- package/esm/types/api/webhookd.d.ts +24 -0
- package/esm/types/api/webhookd.d.ts.map +1 -0
- package/esm/types/api-client.d.ts +63 -0
- package/esm/types/api-client.d.ts.map +1 -0
- package/esm/types/checker/Checker.d.ts +13 -0
- package/esm/types/checker/Checker.d.ts.map +1 -0
- package/esm/types/checker/checks/aor.d.ts +6 -0
- package/esm/types/checker/checks/aor.d.ts.map +1 -0
- package/esm/types/checker/checks/api.d.ts +6 -0
- package/esm/types/checker/checks/api.d.ts.map +1 -0
- package/esm/types/checker/checks/ice-ipv4.d.ts +6 -0
- package/esm/types/checker/checks/ice-ipv4.d.ts.map +1 -0
- package/esm/types/checker/checks/index.d.ts +9 -0
- package/esm/types/checker/checks/index.d.ts.map +1 -0
- package/esm/types/checker/checks/symmetric-nat.d.ts +6 -0
- package/esm/types/checker/checks/symmetric-nat.d.ts.map +1 -0
- package/esm/types/checker/checks/wazo-websocket.d.ts +6 -0
- package/esm/types/checker/checks/wazo-websocket.d.ts.map +1 -0
- package/esm/types/checker/checks/webrtc-transport.d.ts +7 -0
- package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -0
- package/esm/types/checker/checks/webrtc.d.ts +6 -0
- package/esm/types/checker/checks/webrtc.d.ts.map +1 -0
- package/esm/types/domain/AdHocAPIConference.d.ts +54 -0
- package/esm/types/domain/AdHocAPIConference.d.ts.map +1 -0
- package/esm/types/domain/Agent.d.ts +31 -0
- package/esm/types/domain/Agent.d.ts.map +1 -0
- package/esm/types/domain/BadResponse.d.ts +11 -0
- package/esm/types/domain/BadResponse.d.ts.map +1 -0
- package/esm/types/domain/Call.d.ts +79 -0
- package/esm/types/domain/Call.d.ts.map +1 -0
- package/esm/types/domain/CallLog.d.ts +91 -0
- package/esm/types/domain/CallLog.d.ts.map +1 -0
- package/esm/types/domain/CallSession.d.ts +120 -0
- package/esm/types/domain/CallSession.d.ts.map +1 -0
- package/esm/types/domain/ChatMessage.d.ts +41 -0
- package/esm/types/domain/ChatMessage.d.ts.map +1 -0
- package/esm/types/domain/ChatRoom.d.ts +22 -0
- package/esm/types/domain/ChatRoom.d.ts.map +1 -0
- package/esm/types/domain/Contact.d.ts +316 -0
- package/esm/types/domain/Contact.d.ts.map +1 -0
- package/esm/types/domain/Country.d.ts +20 -0
- package/esm/types/domain/Country.d.ts.map +1 -0
- package/esm/types/domain/Device/DebugDevice.d.ts +14 -0
- package/esm/types/domain/Device/DebugDevice.d.ts.map +1 -0
- package/esm/types/domain/Device/Device.d.ts +13 -0
- package/esm/types/domain/Device/Device.d.ts.map +1 -0
- package/esm/types/domain/DirectorySource.d.ts +13 -0
- package/esm/types/domain/DirectorySource.d.ts.map +1 -0
- package/esm/types/domain/ExternalApp.d.ts +22 -0
- package/esm/types/domain/ExternalApp.d.ts.map +1 -0
- package/esm/types/domain/Features.d.ts +24 -0
- package/esm/types/domain/Features.d.ts.map +1 -0
- package/esm/types/domain/ForwardOption.d.ts +27 -0
- package/esm/types/domain/ForwardOption.d.ts.map +1 -0
- package/esm/types/domain/IndirectTransfer.d.ts +31 -0
- package/esm/types/domain/IndirectTransfer.d.ts.map +1 -0
- package/esm/types/domain/Line.d.ts +46 -0
- package/esm/types/domain/Line.d.ts.map +1 -0
- package/esm/types/domain/Meeting.d.ts +45 -0
- package/esm/types/domain/Meeting.d.ts.map +1 -0
- package/esm/types/domain/MeetingAuthorization.d.ts +26 -0
- package/esm/types/domain/MeetingAuthorization.d.ts.map +1 -0
- package/esm/types/domain/MeetingStatus.d.ts +10 -0
- package/esm/types/domain/MeetingStatus.d.ts.map +1 -0
- package/esm/types/domain/NotificationOptions.d.ts +22 -0
- package/esm/types/domain/NotificationOptions.d.ts.map +1 -0
- package/esm/types/domain/Phone/CTIPhone.d.ts +76 -0
- package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -0
- package/esm/types/domain/Phone/Phone.d.ts +71 -0
- package/esm/types/domain/Phone/Phone.d.ts.map +1 -0
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +179 -0
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
- package/esm/types/domain/Profile.d.ts +151 -0
- package/esm/types/domain/Profile.d.ts.map +1 -0
- package/esm/types/domain/Recording.d.ts +26 -0
- package/esm/types/domain/Recording.d.ts.map +1 -0
- package/esm/types/domain/Relocation.d.ts +23 -0
- package/esm/types/domain/Relocation.d.ts.map +1 -0
- package/esm/types/domain/Room.d.ts +35 -0
- package/esm/types/domain/Room.d.ts.map +1 -0
- package/esm/types/domain/SFUNotAvailableError.d.ts +4 -0
- package/esm/types/domain/SFUNotAvailableError.d.ts.map +1 -0
- package/esm/types/domain/ServerError.d.ts +6 -0
- package/esm/types/domain/ServerError.d.ts.map +1 -0
- package/esm/types/domain/Session.d.ts +90 -0
- package/esm/types/domain/Session.d.ts.map +1 -0
- package/esm/types/domain/SipLine.d.ts +54 -0
- package/esm/types/domain/SipLine.d.ts.map +1 -0
- package/esm/types/domain/Subscription.d.ts +43 -0
- package/esm/types/domain/Subscription.d.ts.map +1 -0
- package/esm/types/domain/SwitchboardCall.d.ts +62 -0
- package/esm/types/domain/SwitchboardCall.d.ts.map +1 -0
- package/esm/types/domain/Voicemail.d.ts +50 -0
- package/esm/types/domain/Voicemail.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Agent.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Agent.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Call.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Call.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/CallLog.test.d.ts +2 -0
- package/esm/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/CallSession.test.d.ts +2 -0
- package/esm/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Contact.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Contact.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
- package/esm/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Line.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Line.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Meeting.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
- package/esm/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Profile.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Profile.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Room.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Room.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Session.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Session.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/SipLine.test.d.ts +2 -0
- package/esm/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
- package/esm/types/domain/__tests__/Voicemail.test.d.ts +2 -0
- package/esm/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
- package/esm/types/domain/types.d.ts +217 -0
- package/esm/types/domain/types.d.ts.map +1 -0
- package/esm/types/index.d.ts +304 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
- package/esm/types/pubkey.d.ts +3 -0
- package/esm/types/pubkey.d.ts.map +1 -0
- package/esm/types/service/CallApi.d.ts +28 -0
- package/esm/types/service/CallApi.d.ts.map +1 -0
- package/esm/types/service/IssueReporter.d.ts +40 -0
- package/esm/types/service/IssueReporter.d.ts.map +1 -0
- package/esm/types/service/__tests__/IssueReporter.test.d.ts +2 -0
- package/esm/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
- package/esm/types/service/getApiClient.d.ts +16 -0
- package/esm/types/service/getApiClient.d.ts.map +1 -0
- package/esm/types/simple/Auth.d.ts +51 -0
- package/esm/types/simple/Auth.d.ts.map +1 -0
- package/esm/types/simple/Configuration.d.ts +3 -0
- package/esm/types/simple/Configuration.d.ts.map +1 -0
- package/esm/types/simple/Directory.d.ts +3 -0
- package/esm/types/simple/Directory.d.ts.map +1 -0
- package/esm/types/simple/Phone.d.ts +115 -0
- package/esm/types/simple/Phone.d.ts.map +1 -0
- package/esm/types/simple/Websocket.d.ts +19 -0
- package/esm/types/simple/Websocket.d.ts.map +1 -0
- package/esm/types/simple/index.d.ts +147 -0
- package/esm/types/simple/index.d.ts.map +1 -0
- package/esm/types/simple/room/LocalParticipant.d.ts +5 -0
- package/esm/types/simple/room/LocalParticipant.d.ts.map +1 -0
- package/esm/types/simple/room/Participant.d.ts +76 -0
- package/esm/types/simple/room/Participant.d.ts.map +1 -0
- package/esm/types/simple/room/RemoteParticipant.d.ts +7 -0
- package/esm/types/simple/room/RemoteParticipant.d.ts.map +1 -0
- package/esm/types/simple/room/Room.d.ts +116 -0
- package/esm/types/simple/room/Room.d.ts.map +1 -0
- package/esm/types/simple/room/SipRoom.d.ts +14 -0
- package/esm/types/simple/room/SipRoom.d.ts.map +1 -0
- package/esm/types/simple/room/Stream.d.ts +13 -0
- package/esm/types/simple/room/Stream.d.ts.map +1 -0
- package/esm/types/simple/room/__tests__/Participant.test.d.ts +2 -0
- package/esm/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
- package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
- package/esm/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
- package/esm/types/simple/utils.d.ts +3 -0
- package/esm/types/simple/utils.d.ts.map +1 -0
- package/esm/types/types/WebSocketMessage.d.ts +285 -0
- package/esm/types/types/WebSocketMessage.d.ts.map +1 -0
- package/esm/types/utils/Emitter.d.ts +18 -0
- package/esm/types/utils/Emitter.d.ts.map +1 -0
- package/esm/types/utils/Heartbeat.d.ts +21 -0
- package/esm/types/utils/Heartbeat.d.ts.map +1 -0
- package/esm/types/utils/PhoneNumberUtil.d.ts +8 -0
- package/esm/types/utils/PhoneNumberUtil.d.ts.map +1 -0
- package/esm/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
- package/esm/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
- package/esm/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/api-requester.test.d.ts +2 -0
- package/esm/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/array.test.d.ts +2 -0
- package/esm/types/utils/__tests__/array.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/compare-version.test.d.ts +2 -0
- package/esm/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/object.test.d.ts +2 -0
- package/esm/types/utils/__tests__/object.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/sdp.test.d.ts +2 -0
- package/esm/types/utils/__tests__/sdp.test.d.ts.map +1 -0
- package/esm/types/utils/__tests__/string.test.d.ts +2 -0
- package/esm/types/utils/__tests__/string.test.d.ts.map +1 -0
- package/esm/types/utils/api-requester.d.ts +45 -0
- package/esm/types/utils/api-requester.d.ts.map +1 -0
- package/esm/types/utils/array.d.ts +2 -0
- package/esm/types/utils/array.d.ts.map +1 -0
- package/esm/types/utils/compare-version.d.ts +3 -0
- package/esm/types/utils/compare-version.d.ts.map +1 -0
- package/esm/types/utils/isMobile.d.ts +3 -0
- package/esm/types/utils/isMobile.d.ts.map +1 -0
- package/esm/types/utils/new-from.d.ts +3 -0
- package/esm/types/utils/new-from.d.ts.map +1 -0
- package/esm/types/utils/object.d.ts +2 -0
- package/esm/types/utils/object.d.ts.map +1 -0
- package/esm/types/utils/once.d.ts +2 -0
- package/esm/types/utils/once.d.ts.map +1 -0
- package/esm/types/utils/sdp.d.ts +13 -0
- package/esm/types/utils/sdp.d.ts.map +1 -0
- package/esm/types/utils/string.d.ts +2 -0
- package/esm/types/utils/string.d.ts.map +1 -0
- package/esm/types/utils/update-from.d.ts +3 -0
- package/esm/types/utils/update-from.d.ts.map +1 -0
- package/esm/types/utils/webrtc.d.ts +15 -0
- package/esm/types/utils/webrtc.d.ts.map +1 -0
- package/esm/types/web-rtc-client.d.ts +211 -0
- package/esm/types/web-rtc-client.d.ts.map +1 -0
- package/esm/types/websocket-client.d.ts +134 -0
- package/esm/types/websocket-client.d.ts.map +1 -0
- package/esm/utils/Emitter.js +17 -27
- package/esm/utils/Heartbeat.js +60 -83
- package/esm/utils/PhoneNumberUtil.js +48 -63
- package/esm/utils/__tests__/Heartbeat.test.js +59 -168
- package/esm/utils/__tests__/PhoneNumberUtil.test.js +55 -125
- package/esm/utils/__tests__/api-requester.test.js +127 -780
- package/esm/utils/__tests__/array.test.js +16 -19
- package/esm/utils/__tests__/compare-version.test.js +8 -26
- package/esm/utils/__tests__/object.test.js +73 -54
- package/esm/utils/__tests__/sdp.test.js +87 -216
- package/esm/utils/__tests__/string.test.js +21 -27
- package/esm/utils/api-requester.js +197 -675
- package/esm/utils/array.js +7 -11
- package/esm/utils/compare-version.js +12 -15
- package/esm/utils/isMobile.js +0 -2
- package/esm/utils/new-from.js +7 -12
- package/esm/utils/object.js +9 -23
- package/esm/utils/once.js +12 -13
- package/esm/utils/sdp.js +87 -131
- package/esm/utils/string.js +5 -9
- package/esm/utils/update-from.js +9 -16
- package/esm/utils/webrtc.js +35 -36
- package/esm/web-rtc-client.js +1974 -7676
- package/esm/websocket-client.js +352 -944
- package/lib/__tests__/api-client.test.js +199 -5067
- package/lib/__tests__/web-rtc-client.test.js +191 -7941
- package/lib/api/agentd.js +27 -837
- package/lib/api/amid.js +18 -415
- package/lib/api/application.js +64 -834
- package/lib/api/auth.js +166 -1222
- package/lib/api/call-logd.js +28 -738
- package/lib/api/calld.js +126 -1473
- package/lib/api/chatd.js +49 -1316
- package/lib/api/confd.js +79 -1584
- package/lib/api/ctid-ng.js +96 -1348
- package/lib/api/dird.js +105 -1596
- package/lib/api/webhookd.js +11 -518
- package/lib/api-client.js +138 -4884
- package/lib/checker/Checker.js +61 -8739
- package/lib/checker/checks/aor.js +37 -4929
- package/lib/checker/checks/api.js +81 -4971
- package/lib/checker/checks/ice-ipv4.js +66 -118
- package/lib/checker/checks/index.js +13 -8687
- package/lib/checker/checks/symmetric-nat.js +56 -104
- package/lib/checker/checks/wazo-websocket.js +58 -1006
- package/lib/checker/checks/webrtc-transport.js +41 -7853
- package/lib/checker/checks/webrtc.js +42 -7858
- package/lib/domain/AdHocAPIConference.js +80 -5116
- package/lib/domain/Agent.js +23 -64
- package/lib/domain/BadResponse.js +17 -44
- package/lib/domain/Call.js +108 -215
- package/lib/domain/CallLog.js +117 -311
- package/lib/domain/CallSession.js +221 -424
- package/lib/domain/ChatMessage.js +49 -110
- package/lib/domain/ChatRoom.js +28 -60
- package/lib/domain/Contact.js +404 -742
- package/lib/domain/Country.js +19 -21
- package/lib/domain/Device/DebugDevice.js +34 -49
- package/lib/domain/Device/Device.js +2 -2
- package/lib/domain/DirectorySource.js +2 -2
- package/lib/domain/ExternalApp.js +24 -56
- package/lib/domain/Features.js +68 -5018
- package/lib/domain/ForwardOption.js +36 -71
- package/lib/domain/IndirectTransfer.js +39 -98
- package/lib/domain/Line.js +35 -88
- package/lib/domain/Meeting.js +51 -118
- package/lib/domain/MeetingAuthorization.js +35 -75
- package/lib/domain/MeetingStatus.js +13 -29
- package/lib/domain/NotificationOptions.js +45 -77
- package/lib/domain/Phone/CTIPhone.js +283 -5755
- package/lib/domain/Phone/Phone.js +2 -5
- package/lib/domain/Phone/WebRTCPhone.js +1450 -2715
- package/lib/domain/Profile.js +127 -406
- package/lib/domain/Recording.js +28 -57
- package/lib/domain/Relocation.js +15 -43
- package/lib/domain/Room.js +73 -134
- package/lib/domain/SFUNotAvailableError.js +7 -9
- package/lib/domain/ServerError.js +14 -63
- package/lib/domain/Session.js +118 -251
- package/lib/domain/SipLine.js +70 -155
- package/lib/domain/Subscription.js +32 -86
- package/lib/domain/SwitchboardCall.js +45 -145
- package/lib/domain/Voicemail.js +56 -127
- package/lib/domain/__tests__/Agent.test.js +36 -103
- package/lib/domain/__tests__/Call.test.js +28 -237
- package/lib/domain/__tests__/CallLog.test.js +65 -392
- package/lib/domain/__tests__/CallSession.test.js +78 -503
- package/lib/domain/__tests__/Contact.test.js +224 -903
- package/lib/domain/__tests__/IndirectTransfer.test.js +75 -546
- package/lib/domain/__tests__/Line.test.js +52 -157
- package/lib/domain/__tests__/Meeting.test.js +78 -232
- package/lib/domain/__tests__/MeetingAuthorization.test.js +50 -107
- package/lib/domain/__tests__/Profile.test.js +161 -496
- package/lib/domain/__tests__/Room.test.js +239 -719
- package/lib/domain/__tests__/Session.test.js +350 -1024
- package/lib/domain/__tests__/SipLine.test.js +28 -180
- package/lib/domain/__tests__/Voicemail.test.js +86 -205
- package/lib/domain/types.js +2 -2
- package/lib/index.js +105 -15010
- package/lib/lib/WazoSessionDescriptionHandler.js +409 -898
- package/lib/pubkey.js +12 -0
- package/lib/service/CallApi.js +88 -5015
- package/lib/service/IssueReporter.js +264 -366
- package/lib/service/__tests__/IssueReporter.test.js +97 -500
- package/lib/service/getApiClient.js +70 -4990
- package/lib/simple/Auth.js +272 -14777
- package/lib/simple/Configuration.js +23 -14805
- package/lib/simple/Directory.js +18 -4966
- package/lib/simple/Phone.js +345 -14746
- package/lib/simple/Websocket.js +98 -1117
- package/lib/simple/index.js +151 -14800
- package/lib/simple/room/LocalParticipant.js +7 -14808
- package/lib/simple/room/Participant.js +269 -14778
- package/lib/simple/room/RemoteParticipant.js +11 -14806
- package/lib/simple/room/Room.js +655 -14761
- package/lib/simple/room/SipRoom.js +136 -14805
- package/lib/simple/room/Stream.js +43 -14802
- package/lib/simple/room/__tests__/Participant.test.js +79 -14879
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +14 -14814
- package/lib/simple/utils.js +22 -14808
- package/lib/types/WebSocketMessage.js +2 -4
- package/lib/types/__tests__/api-client.test.d.ts +2 -0
- package/lib/types/__tests__/api-client.test.d.ts.map +1 -0
- package/lib/types/__tests__/web-rtc-client.test.d.ts +2 -0
- package/lib/types/__tests__/web-rtc-client.test.d.ts.map +1 -0
- package/lib/types/api/agentd.d.ts +17 -0
- package/lib/types/api/agentd.d.ts.map +1 -0
- package/lib/types/api/amid.d.ts +8 -0
- package/lib/types/api/amid.d.ts.map +1 -0
- package/lib/types/api/application.d.ts +34 -0
- package/lib/types/api/application.d.ts.map +1 -0
- package/lib/types/api/auth.d.ts +64 -0
- package/lib/types/api/auth.d.ts.map +1 -0
- package/lib/types/api/call-logd.d.ts +12 -0
- package/lib/types/api/call-logd.d.ts.map +1 -0
- package/lib/types/api/calld.d.ts +51 -0
- package/lib/types/api/calld.d.ts.map +1 -0
- package/lib/types/api/chatd.d.ts +42 -0
- package/lib/types/api/chatd.d.ts.map +1 -0
- package/lib/types/api/confd.d.ts +39 -0
- package/lib/types/api/confd.d.ts.map +1 -0
- package/lib/types/api/ctid-ng.d.ts +36 -0
- package/lib/types/api/ctid-ng.d.ts.map +1 -0
- package/lib/types/api/dird.d.ts +38 -0
- package/lib/types/api/dird.d.ts.map +1 -0
- package/lib/types/api/webhookd.d.ts +24 -0
- package/lib/types/api/webhookd.d.ts.map +1 -0
- package/lib/types/api-client.d.ts +63 -0
- package/lib/types/api-client.d.ts.map +1 -0
- package/lib/types/checker/Checker.d.ts +13 -0
- package/lib/types/checker/Checker.d.ts.map +1 -0
- package/lib/types/checker/checks/aor.d.ts +6 -0
- package/lib/types/checker/checks/aor.d.ts.map +1 -0
- package/lib/types/checker/checks/api.d.ts +6 -0
- package/lib/types/checker/checks/api.d.ts.map +1 -0
- package/lib/types/checker/checks/ice-ipv4.d.ts +6 -0
- package/lib/types/checker/checks/ice-ipv4.d.ts.map +1 -0
- package/lib/types/checker/checks/index.d.ts +9 -0
- package/lib/types/checker/checks/index.d.ts.map +1 -0
- package/lib/types/checker/checks/symmetric-nat.d.ts +6 -0
- package/lib/types/checker/checks/symmetric-nat.d.ts.map +1 -0
- package/lib/types/checker/checks/wazo-websocket.d.ts +6 -0
- package/lib/types/checker/checks/wazo-websocket.d.ts.map +1 -0
- package/lib/types/checker/checks/webrtc-transport.d.ts +7 -0
- package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -0
- package/lib/types/checker/checks/webrtc.d.ts +6 -0
- package/lib/types/checker/checks/webrtc.d.ts.map +1 -0
- package/lib/types/domain/AdHocAPIConference.d.ts +54 -0
- package/lib/types/domain/AdHocAPIConference.d.ts.map +1 -0
- package/lib/types/domain/Agent.d.ts +31 -0
- package/lib/types/domain/Agent.d.ts.map +1 -0
- package/lib/types/domain/BadResponse.d.ts +11 -0
- package/lib/types/domain/BadResponse.d.ts.map +1 -0
- package/lib/types/domain/Call.d.ts +79 -0
- package/lib/types/domain/Call.d.ts.map +1 -0
- package/lib/types/domain/CallLog.d.ts +91 -0
- package/lib/types/domain/CallLog.d.ts.map +1 -0
- package/lib/types/domain/CallSession.d.ts +120 -0
- package/lib/types/domain/CallSession.d.ts.map +1 -0
- package/lib/types/domain/ChatMessage.d.ts +41 -0
- package/lib/types/domain/ChatMessage.d.ts.map +1 -0
- package/lib/types/domain/ChatRoom.d.ts +22 -0
- package/lib/types/domain/ChatRoom.d.ts.map +1 -0
- package/lib/types/domain/Contact.d.ts +316 -0
- package/lib/types/domain/Contact.d.ts.map +1 -0
- package/lib/types/domain/Country.d.ts +20 -0
- package/lib/types/domain/Country.d.ts.map +1 -0
- package/lib/types/domain/Device/DebugDevice.d.ts +14 -0
- package/lib/types/domain/Device/DebugDevice.d.ts.map +1 -0
- package/lib/types/domain/Device/Device.d.ts +13 -0
- package/lib/types/domain/Device/Device.d.ts.map +1 -0
- package/lib/types/domain/DirectorySource.d.ts +13 -0
- package/lib/types/domain/DirectorySource.d.ts.map +1 -0
- package/lib/types/domain/ExternalApp.d.ts +22 -0
- package/lib/types/domain/ExternalApp.d.ts.map +1 -0
- package/lib/types/domain/Features.d.ts +24 -0
- package/lib/types/domain/Features.d.ts.map +1 -0
- package/lib/types/domain/ForwardOption.d.ts +27 -0
- package/lib/types/domain/ForwardOption.d.ts.map +1 -0
- package/lib/types/domain/IndirectTransfer.d.ts +31 -0
- package/lib/types/domain/IndirectTransfer.d.ts.map +1 -0
- package/lib/types/domain/Line.d.ts +46 -0
- package/lib/types/domain/Line.d.ts.map +1 -0
- package/lib/types/domain/Meeting.d.ts +45 -0
- package/lib/types/domain/Meeting.d.ts.map +1 -0
- package/lib/types/domain/MeetingAuthorization.d.ts +26 -0
- package/lib/types/domain/MeetingAuthorization.d.ts.map +1 -0
- package/lib/types/domain/MeetingStatus.d.ts +10 -0
- package/lib/types/domain/MeetingStatus.d.ts.map +1 -0
- package/lib/types/domain/NotificationOptions.d.ts +22 -0
- package/lib/types/domain/NotificationOptions.d.ts.map +1 -0
- package/lib/types/domain/Phone/CTIPhone.d.ts +76 -0
- package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -0
- package/lib/types/domain/Phone/Phone.d.ts +71 -0
- package/lib/types/domain/Phone/Phone.d.ts.map +1 -0
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +179 -0
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -0
- package/lib/types/domain/Profile.d.ts +151 -0
- package/lib/types/domain/Profile.d.ts.map +1 -0
- package/lib/types/domain/Recording.d.ts +26 -0
- package/lib/types/domain/Recording.d.ts.map +1 -0
- package/lib/types/domain/Relocation.d.ts +23 -0
- package/lib/types/domain/Relocation.d.ts.map +1 -0
- package/lib/types/domain/Room.d.ts +35 -0
- package/lib/types/domain/Room.d.ts.map +1 -0
- package/lib/types/domain/SFUNotAvailableError.d.ts +4 -0
- package/lib/types/domain/SFUNotAvailableError.d.ts.map +1 -0
- package/lib/types/domain/ServerError.d.ts +6 -0
- package/lib/types/domain/ServerError.d.ts.map +1 -0
- package/lib/types/domain/Session.d.ts +90 -0
- package/lib/types/domain/Session.d.ts.map +1 -0
- package/lib/types/domain/SipLine.d.ts +54 -0
- package/lib/types/domain/SipLine.d.ts.map +1 -0
- package/lib/types/domain/Subscription.d.ts +43 -0
- package/lib/types/domain/Subscription.d.ts.map +1 -0
- package/lib/types/domain/SwitchboardCall.d.ts +62 -0
- package/lib/types/domain/SwitchboardCall.d.ts.map +1 -0
- package/lib/types/domain/Voicemail.d.ts +50 -0
- package/lib/types/domain/Voicemail.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Agent.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Agent.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Call.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Call.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/CallLog.test.d.ts +2 -0
- package/lib/types/domain/__tests__/CallLog.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/CallSession.test.d.ts +2 -0
- package/lib/types/domain/__tests__/CallSession.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Contact.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Contact.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts +2 -0
- package/lib/types/domain/__tests__/IndirectTransfer.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Line.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Line.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Meeting.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Meeting.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts +2 -0
- package/lib/types/domain/__tests__/MeetingAuthorization.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Profile.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Profile.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Room.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Room.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Session.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Session.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/SipLine.test.d.ts +2 -0
- package/lib/types/domain/__tests__/SipLine.test.d.ts.map +1 -0
- package/lib/types/domain/__tests__/Voicemail.test.d.ts +2 -0
- package/lib/types/domain/__tests__/Voicemail.test.d.ts.map +1 -0
- package/lib/types/domain/types.d.ts +217 -0
- package/lib/types/domain/types.d.ts.map +1 -0
- package/lib/types/index.d.ts +304 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +30 -0
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -0
- package/lib/types/pubkey.d.ts +3 -0
- package/lib/types/pubkey.d.ts.map +1 -0
- package/lib/types/service/CallApi.d.ts +28 -0
- package/lib/types/service/CallApi.d.ts.map +1 -0
- package/lib/types/service/IssueReporter.d.ts +40 -0
- package/lib/types/service/IssueReporter.d.ts.map +1 -0
- package/lib/types/service/__tests__/IssueReporter.test.d.ts +2 -0
- package/lib/types/service/__tests__/IssueReporter.test.d.ts.map +1 -0
- package/lib/types/service/getApiClient.d.ts +16 -0
- package/lib/types/service/getApiClient.d.ts.map +1 -0
- package/lib/types/simple/Auth.d.ts +51 -0
- package/lib/types/simple/Auth.d.ts.map +1 -0
- package/lib/types/simple/Configuration.d.ts +3 -0
- package/lib/types/simple/Configuration.d.ts.map +1 -0
- package/lib/types/simple/Directory.d.ts +3 -0
- package/lib/types/simple/Directory.d.ts.map +1 -0
- package/lib/types/simple/Phone.d.ts +115 -0
- package/lib/types/simple/Phone.d.ts.map +1 -0
- package/lib/types/simple/Websocket.d.ts +19 -0
- package/lib/types/simple/Websocket.d.ts.map +1 -0
- package/lib/types/simple/index.d.ts +147 -0
- package/lib/types/simple/index.d.ts.map +1 -0
- package/lib/types/simple/room/LocalParticipant.d.ts +5 -0
- package/lib/types/simple/room/LocalParticipant.d.ts.map +1 -0
- package/lib/types/simple/room/Participant.d.ts +76 -0
- package/lib/types/simple/room/Participant.d.ts.map +1 -0
- package/lib/types/simple/room/RemoteParticipant.d.ts +7 -0
- package/lib/types/simple/room/RemoteParticipant.d.ts.map +1 -0
- package/lib/types/simple/room/Room.d.ts +116 -0
- package/lib/types/simple/room/Room.d.ts.map +1 -0
- package/lib/types/simple/room/SipRoom.d.ts +14 -0
- package/lib/types/simple/room/SipRoom.d.ts.map +1 -0
- package/lib/types/simple/room/Stream.d.ts +13 -0
- package/lib/types/simple/room/Stream.d.ts.map +1 -0
- package/lib/types/simple/room/__tests__/Participant.test.d.ts +2 -0
- package/lib/types/simple/room/__tests__/Participant.test.d.ts.map +1 -0
- package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts +2 -0
- package/lib/types/simple/room/__tests__/RemoteParticipant.test.d.ts.map +1 -0
- package/lib/types/simple/utils.d.ts +3 -0
- package/lib/types/simple/utils.d.ts.map +1 -0
- package/lib/types/types/WebSocketMessage.d.ts +285 -0
- package/lib/types/types/WebSocketMessage.d.ts.map +1 -0
- package/lib/types/utils/Emitter.d.ts +18 -0
- package/lib/types/utils/Emitter.d.ts.map +1 -0
- package/lib/types/utils/Heartbeat.d.ts +21 -0
- package/lib/types/utils/Heartbeat.d.ts.map +1 -0
- package/lib/types/utils/PhoneNumberUtil.d.ts +8 -0
- package/lib/types/utils/PhoneNumberUtil.d.ts.map +1 -0
- package/lib/types/utils/__tests__/Heartbeat.test.d.ts +2 -0
- package/lib/types/utils/__tests__/Heartbeat.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts +2 -0
- package/lib/types/utils/__tests__/PhoneNumberUtil.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/api-requester.test.d.ts +2 -0
- package/lib/types/utils/__tests__/api-requester.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/array.test.d.ts +2 -0
- package/lib/types/utils/__tests__/array.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/compare-version.test.d.ts +2 -0
- package/lib/types/utils/__tests__/compare-version.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/object.test.d.ts +2 -0
- package/lib/types/utils/__tests__/object.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/sdp.test.d.ts +2 -0
- package/lib/types/utils/__tests__/sdp.test.d.ts.map +1 -0
- package/lib/types/utils/__tests__/string.test.d.ts +2 -0
- package/lib/types/utils/__tests__/string.test.d.ts.map +1 -0
- package/lib/types/utils/api-requester.d.ts +45 -0
- package/lib/types/utils/api-requester.d.ts.map +1 -0
- package/lib/types/utils/array.d.ts +2 -0
- package/lib/types/utils/array.d.ts.map +1 -0
- package/lib/types/utils/compare-version.d.ts +3 -0
- package/lib/types/utils/compare-version.d.ts.map +1 -0
- package/lib/types/utils/isMobile.d.ts +3 -0
- package/lib/types/utils/isMobile.d.ts.map +1 -0
- package/lib/types/utils/new-from.d.ts +3 -0
- package/lib/types/utils/new-from.d.ts.map +1 -0
- package/lib/types/utils/object.d.ts +2 -0
- package/lib/types/utils/object.d.ts.map +1 -0
- package/lib/types/utils/once.d.ts +2 -0
- package/lib/types/utils/once.d.ts.map +1 -0
- package/lib/types/utils/sdp.d.ts +13 -0
- package/lib/types/utils/sdp.d.ts.map +1 -0
- package/lib/types/utils/string.d.ts +2 -0
- package/lib/types/utils/string.d.ts.map +1 -0
- package/lib/types/utils/update-from.d.ts +3 -0
- package/lib/types/utils/update-from.d.ts.map +1 -0
- package/lib/types/utils/webrtc.d.ts +15 -0
- package/lib/types/utils/webrtc.d.ts.map +1 -0
- package/lib/types/web-rtc-client.d.ts +211 -0
- package/lib/types/web-rtc-client.d.ts.map +1 -0
- package/lib/types/websocket-client.d.ts +134 -0
- package/lib/types/websocket-client.d.ts.map +1 -0
- package/lib/utils/Emitter.js +22 -33
- package/lib/utils/Heartbeat.js +54 -86
- package/lib/utils/PhoneNumberUtil.js +60 -77
- package/lib/utils/__tests__/Heartbeat.test.js +73 -170
- package/lib/utils/__tests__/PhoneNumberUtil.test.js +57 -131
- package/lib/utils/__tests__/api-requester.test.js +139 -784
- package/lib/utils/__tests__/array.test.js +18 -21
- package/lib/utils/__tests__/compare-version.test.js +12 -27
- package/lib/utils/__tests__/object.test.js +75 -56
- package/lib/utils/__tests__/sdp.test.js +99 -220
- package/lib/utils/__tests__/string.test.js +23 -29
- package/lib/utils/api-requester.js +191 -685
- package/lib/utils/array.js +10 -14
- package/lib/utils/compare-version.js +15 -18
- package/lib/utils/isMobile.js +3 -5
- package/lib/utils/new-from.js +9 -14
- package/lib/utils/object.js +12 -26
- package/lib/utils/once.js +15 -15
- package/lib/utils/sdp.js +97 -150
- package/lib/utils/string.js +8 -12
- package/lib/utils/update-from.js +11 -18
- package/lib/utils/webrtc.js +38 -39
- package/lib/web-rtc-client.js +2001 -7695
- package/lib/websocket-client.js +357 -1021
- package/package.json +40 -34
- package/src/__tests__/{api-client.test.js → api-client.test.ts} +71 -29
- package/src/__tests__/{web-rtc-client.test.js → web-rtc-client.test.ts} +95 -35
- package/src/api/agentd.ts +37 -0
- package/src/api/amid.ts +16 -0
- package/src/api/application.ts +96 -0
- package/src/api/auth.ts +259 -0
- package/src/api/call-logd.ts +38 -0
- package/src/api/calld.ts +183 -0
- package/src/api/chatd.ts +83 -0
- package/src/api/confd.ts +110 -0
- package/src/api/ctid-ng.ts +152 -0
- package/src/api/dird.ts +146 -0
- package/src/api/webhookd.ts +30 -0
- package/src/{api-client.js → api-client.ts} +99 -65
- package/src/checker/{Checker.js → Checker.ts} +27 -20
- package/src/checker/checks/{aor.js → aor.ts} +10 -6
- package/src/checker/checks/{api.js → api.ts} +18 -17
- package/src/checker/checks/{ice-ipv4.js → ice-ipv4.ts} +23 -26
- package/src/checker/checks/{index.js → index.ts} +1 -9
- package/src/checker/checks/{symmetric-nat.js → symmetric-nat.ts} +14 -15
- package/src/checker/checks/{wazo-websocket.js → wazo-websocket.ts} +7 -5
- package/src/checker/checks/{webrtc-transport.js → webrtc-transport.ts} +3 -2
- package/src/checker/checks/{webrtc.js → webrtc.ts} +3 -4
- package/src/domain/{AdHocAPIConference.js → AdHocAPIConference.ts} +38 -54
- package/src/domain/{Agent.js → Agent.ts} +11 -7
- package/src/domain/BadResponse.ts +29 -0
- package/src/domain/{Call.js → Call.ts} +62 -46
- package/src/domain/{CallLog.js → CallLog.ts} +61 -63
- package/src/domain/{CallSession.js → CallSession.ts} +55 -52
- package/src/domain/{ChatMessage.js → ChatMessage.ts} +32 -21
- package/src/domain/{ChatRoom.js → ChatRoom.ts} +15 -11
- package/src/domain/{Contact.js → Contact.ts} +373 -261
- package/src/domain/{Country.js → Country.ts} +0 -0
- package/src/domain/Device/{DebugDevice.js → DebugDevice.ts} +3 -5
- package/src/domain/Device/{Device.js → Device.ts} +0 -11
- package/src/domain/DirectorySource.ts +13 -0
- package/src/domain/{ExternalApp.js → ExternalApp.ts} +14 -13
- package/src/domain/{Features.js → Features.ts} +43 -17
- package/src/domain/{ForwardOption.js → ForwardOption.ts} +16 -16
- package/src/domain/{IndirectTransfer.js → IndirectTransfer.ts} +21 -19
- package/src/domain/{Line.js → Line.ts} +39 -26
- package/src/domain/{Meeting.js → Meeting.ts} +36 -29
- package/src/domain/{MeetingAuthorization.js → MeetingAuthorization.ts} +13 -12
- package/src/domain/{MeetingStatus.js → MeetingStatus.ts} +2 -6
- package/src/domain/{NotificationOptions.js → NotificationOptions.ts} +14 -13
- package/src/domain/Phone/{CTIPhone.js → CTIPhone.ts} +90 -60
- package/src/domain/Phone/{Phone.js → Phone.ts} +27 -72
- package/src/domain/Phone/{WebRTCPhone.js → WebRTCPhone.ts} +441 -413
- package/src/domain/{Profile.js → Profile.ts} +117 -100
- package/src/domain/{Recording.js → Recording.ts} +25 -16
- package/src/domain/{Relocation.js → Relocation.ts} +15 -14
- package/src/domain/{Room.js → Room.ts} +58 -27
- package/src/domain/{SFUNotAvailableError.js → SFUNotAvailableError.ts} +2 -2
- package/src/domain/ServerError.ts +12 -0
- package/src/domain/{Session.js → Session.ts} +89 -67
- package/src/domain/{SipLine.js → SipLine.ts} +52 -45
- package/src/domain/{Subscription.js → Subscription.ts} +22 -13
- package/src/domain/{SwitchboardCall.js → SwitchboardCall.ts} +48 -43
- package/src/domain/{Voicemail.js → Voicemail.ts} +38 -34
- package/src/domain/__tests__/{Agent.test.js → Agent.test.ts} +11 -19
- package/src/domain/__tests__/{Call.test.js → Call.test.ts} +12 -9
- package/src/domain/__tests__/CallLog.test.ts +65 -0
- package/src/domain/__tests__/{CallSession.test.js → CallSession.test.ts} +15 -19
- package/src/domain/__tests__/Contact.test.ts +238 -0
- package/src/domain/__tests__/{IndirectTransfer.test.js → IndirectTransfer.test.ts} +38 -31
- package/src/domain/__tests__/Line.test.ts +53 -0
- package/src/domain/__tests__/{Meeting.test.js → Meeting.test.ts} +12 -38
- package/src/domain/__tests__/{MeetingAuthorization.test.js → MeetingAuthorization.test.ts} +13 -21
- package/src/domain/__tests__/Profile.test.ts +139 -0
- package/src/domain/__tests__/{Room.test.js → Room.test.ts} +114 -76
- package/src/domain/__tests__/{Session.test.js → Session.test.ts} +137 -162
- package/src/domain/__tests__/{SipLine.test.js → SipLine.test.ts} +7 -3
- package/src/domain/__tests__/{Voicemail.test.js → Voicemail.test.ts} +26 -20
- package/src/domain/types.ts +227 -0
- package/src/{index.js → index.ts} +4 -28
- package/src/lib/WazoSessionDescriptionHandler.ts +534 -0
- package/{config.js → src/pubkey.ts} +3 -3
- package/src/service/{CallApi.js → CallApi.ts} +14 -18
- package/src/service/{IssueReporter.js → IssueReporter.ts} +105 -56
- package/src/service/__tests__/{IssueReporter.test.js → IssueReporter.test.ts} +27 -23
- package/src/service/getApiClient.ts +94 -0
- package/src/simple/{Auth.js → Auth.ts} +129 -100
- package/src/simple/{Configuration.js → Configuration.ts} +2 -3
- package/src/simple/{Directory.js → Directory.ts} +2 -3
- package/src/simple/Phone.ts +623 -0
- package/src/simple/Websocket.ts +119 -0
- package/src/simple/{index.js → index.ts} +51 -21
- package/src/simple/room/{LocalParticipant.js → LocalParticipant.ts} +1 -3
- package/src/simple/room/{Participant.js → Participant.ts} +108 -46
- package/src/simple/room/{RemoteParticipant.js → RemoteParticipant.ts} +5 -4
- package/src/simple/room/{Room.js → Room.ts} +266 -183
- package/src/simple/room/{SipRoom.js → SipRoom.ts} +46 -29
- package/src/simple/room/{Stream.js → Stream.ts} +8 -6
- package/src/simple/room/__tests__/{Participant.test.js → Participant.test.ts} +9 -15
- package/src/simple/room/__tests__/{RemoteParticipant.test.js → RemoteParticipant.test.ts} +5 -1
- package/src/simple/utils.ts +12 -0
- package/src/types/WebSocketMessage.ts +335 -0
- package/src/types/global.d.ts +26 -0
- package/src/utils/Emitter.ts +34 -0
- package/src/utils/{Heartbeat.js → Heartbeat.ts} +17 -11
- package/src/utils/{PhoneNumberUtil.js → PhoneNumberUtil.ts} +12 -18
- package/src/utils/__tests__/{Heartbeat.test.js → Heartbeat.test.ts} +0 -15
- package/src/utils/__tests__/{PhoneNumberUtil.test.js → PhoneNumberUtil.test.ts} +6 -4
- package/src/utils/__tests__/{api-requester.test.js → api-requester.test.ts} +75 -24
- package/src/utils/__tests__/{array.test.js → array.test.ts} +10 -2
- package/src/utils/__tests__/{compare-version.test.js → compare-version.test.ts} +0 -0
- package/src/utils/__tests__/object.test.ts +77 -0
- package/src/utils/__tests__/{sdp.test.js → sdp.test.ts} +15 -37
- package/src/utils/__tests__/{string.test.js → string.test.ts} +4 -2
- package/src/utils/{api-requester.js → api-requester.ts} +104 -83
- package/src/utils/{array.js → array.ts} +2 -2
- package/src/utils/{compare-version.js → compare-version.ts} +3 -2
- package/src/utils/{isMobile.js → isMobile.ts} +1 -1
- package/src/utils/{new-from.js → new-from.ts} +3 -6
- package/src/utils/{object.js → object.ts} +3 -6
- package/src/utils/{once.js → once.ts} +5 -5
- package/src/utils/sdp.ts +119 -0
- package/src/utils/{string.js → string.ts} +2 -3
- package/src/utils/update-from.ts +11 -0
- package/src/utils/{webrtc.js → webrtc.ts} +21 -3
- package/src/{web-rtc-client.js → web-rtc-client.ts} +793 -463
- package/src/{websocket-client.js → websocket-client.ts} +146 -144
- package/esm/simple/Softphone.js +0 -394
- package/lib/simple/Softphone.js +0 -396
- package/src/api/agentd.js +0 -74
- package/src/api/amid.js +0 -13
- package/src/api/application.js +0 -137
- package/src/api/auth.js +0 -279
- package/src/api/call-logd.js +0 -20
- package/src/api/calld.js +0 -214
- package/src/api/chatd.js +0 -80
- package/src/api/confd.js +0 -127
- package/src/api/ctid-ng.js +0 -153
- package/src/api/dird.js +0 -159
- package/src/api/webhookd.js +0 -31
- package/src/domain/BadResponse.js +0 -42
- package/src/domain/DirectorySource.js +0 -16
- package/src/domain/ServerError.js +0 -18
- package/src/domain/__tests__/CallLog.test.js +0 -75
- package/src/domain/__tests__/Contact.test.js +0 -170
- package/src/domain/__tests__/Line.test.js +0 -73
- package/src/domain/__tests__/Profile.test.js +0 -104
- package/src/domain/types.js +0 -248
- package/src/lib/WazoSessionDescriptionHandler.js +0 -467
- package/src/service/getApiClient.js +0 -122
- package/src/simple/Phone.js +0 -425
- package/src/simple/Softphone.js +0 -392
- package/src/simple/Websocket.js +0 -86
- package/src/simple/utils.js +0 -17
- package/src/types/WebSocketMessage.js +0 -232
- package/src/utils/Emitter.js +0 -26
- package/src/utils/__tests__/object.test.js +0 -35
- package/src/utils/sdp.js +0 -140
- package/src/utils/update-from.js +0 -15
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */
|
|
2
2
|
/* eslint-disable no-underscore-dangle */
|
|
3
|
-
// @flow
|
|
4
3
|
import type { Message } from 'sip.js/lib/api/message';
|
|
5
|
-
import type { Session } from 'sip.js/lib/core/session';
|
|
6
|
-
import { Invitation } from 'sip.js/lib/api/invitation';
|
|
7
4
|
import { SessionState } from 'sip.js/lib/api/session-state';
|
|
8
5
|
import type { IncomingRequestMessage } from 'sip.js/lib/core/messages/incoming-request-message';
|
|
9
|
-
|
|
6
|
+
import { OutgoingInviteRequest } from 'sip.js/lib/core';
|
|
7
|
+
import { Inviter, Invitation, Session } from 'sip.js/lib/api';
|
|
10
8
|
import CallSession from '../CallSession';
|
|
11
9
|
import type { Phone, AvailablePhoneOptions } from './Phone';
|
|
12
10
|
import WazoWebRTCClient from '../../web-rtc-client';
|
|
@@ -55,68 +53,26 @@ export const ON_CHAT = 'phone/ON_CHAT';
|
|
|
55
53
|
export const ON_SIGNAL = 'phone/ON_SIGNAL';
|
|
56
54
|
export const ON_DISCONNECTED = 'onDisconnected';
|
|
57
55
|
export const ON_EARLY_MEDIA = 'onEarlyMedia';
|
|
58
|
-
|
|
59
56
|
export const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
60
57
|
export const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
61
|
-
|
|
62
|
-
export const events = [
|
|
63
|
-
ON_USER_AGENT,
|
|
64
|
-
ON_REGISTERED,
|
|
65
|
-
ON_UNREGISTERED,
|
|
66
|
-
ON_PROGRESS,
|
|
67
|
-
ON_CALL_ACCEPTED,
|
|
68
|
-
ON_CALL_ANSWERED,
|
|
69
|
-
ON_CALL_INCOMING,
|
|
70
|
-
ON_CALL_OUTGOING,
|
|
71
|
-
ON_CALL_MUTED,
|
|
72
|
-
ON_CALL_UNMUTED,
|
|
73
|
-
ON_CALL_RESUMED,
|
|
74
|
-
ON_CALL_HELD,
|
|
75
|
-
ON_CALL_UNHELD,
|
|
76
|
-
ON_CAMERA_DISABLED,
|
|
77
|
-
ON_CALL_FAILED,
|
|
78
|
-
ON_CALL_ENDED,
|
|
79
|
-
ON_CALL_REJECTED,
|
|
80
|
-
ON_MESSAGE,
|
|
81
|
-
ON_REINVITE,
|
|
82
|
-
ON_TRACK,
|
|
83
|
-
ON_AUDIO_STREAM,
|
|
84
|
-
ON_VIDEO_STREAM,
|
|
85
|
-
ON_REMOVE_STREAM,
|
|
86
|
-
ON_SHARE_SCREEN_ENDED,
|
|
87
|
-
ON_TERMINATE_SOUND,
|
|
88
|
-
ON_PLAY_RING_SOUND,
|
|
89
|
-
ON_PLAY_INBOUND_CALL_SIGNAL_SOUND,
|
|
90
|
-
ON_PLAY_HANGUP_SOUND,
|
|
91
|
-
ON_PLAY_PROGRESS_SOUND,
|
|
92
|
-
ON_VIDEO_INPUT_CHANGE,
|
|
93
|
-
ON_SHARE_SCREEN_STARTED,
|
|
94
|
-
ON_CALL_ERROR,
|
|
95
|
-
ON_CHAT,
|
|
96
|
-
ON_SIGNAL,
|
|
97
|
-
ON_NETWORK_STATS,
|
|
98
|
-
ON_DISCONNECTED,
|
|
99
|
-
ON_EARLY_MEDIA,
|
|
100
|
-
];
|
|
101
|
-
|
|
58
|
+
export const events = [ON_USER_AGENT, ON_REGISTERED, ON_UNREGISTERED, ON_PROGRESS, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_INCOMING, ON_CALL_OUTGOING, ON_CALL_MUTED, ON_CALL_UNMUTED, ON_CALL_RESUMED, ON_CALL_HELD, ON_CALL_UNHELD, ON_CAMERA_DISABLED, ON_CALL_FAILED, ON_CALL_ENDED, ON_CALL_REJECTED, ON_MESSAGE, ON_REINVITE, ON_TRACK, ON_AUDIO_STREAM, ON_VIDEO_STREAM, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_TERMINATE_SOUND, ON_PLAY_RING_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_HANGUP_SOUND, ON_PLAY_PROGRESS_SOUND, ON_VIDEO_INPUT_CHANGE, ON_SHARE_SCREEN_STARTED, ON_CALL_ERROR, ON_CHAT, ON_SIGNAL, ON_NETWORK_STATS, ON_DISCONNECTED, ON_EARLY_MEDIA];
|
|
102
59
|
const logger = IssueReporter.loggerFor('webrtc-phone');
|
|
103
|
-
|
|
104
60
|
export default class WebRTCPhone extends Emitter implements Phone {
|
|
105
61
|
client: WazoWebRTCClient;
|
|
106
62
|
|
|
107
63
|
allowVideo: boolean;
|
|
108
64
|
|
|
109
|
-
callSessions:
|
|
65
|
+
callSessions: Record<string, CallSession>;
|
|
110
66
|
|
|
111
67
|
incomingSessions: string[];
|
|
112
68
|
|
|
113
|
-
currentSipSession:
|
|
69
|
+
currentSipSession: Invitation | Inviter | undefined;
|
|
114
70
|
|
|
115
|
-
currentCallSession:
|
|
71
|
+
currentCallSession: CallSession | null | undefined;
|
|
116
72
|
|
|
117
|
-
audioOutputDeviceId:
|
|
73
|
+
audioOutputDeviceId: string | null | undefined;
|
|
118
74
|
|
|
119
|
-
audioRingDeviceId:
|
|
75
|
+
audioRingDeviceId: string | null | undefined;
|
|
120
76
|
|
|
121
77
|
audioOutputVolume: number;
|
|
122
78
|
|
|
@@ -124,26 +80,20 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
124
80
|
|
|
125
81
|
ringingEnabled: boolean;
|
|
126
82
|
|
|
127
|
-
acceptedSessions:
|
|
83
|
+
acceptedSessions: Record<string, any>;
|
|
128
84
|
|
|
129
|
-
rejectedSessions:
|
|
85
|
+
rejectedSessions: Record<string, any>;
|
|
130
86
|
|
|
131
|
-
ignoredSessions:
|
|
87
|
+
ignoredSessions: Record<string, any>;
|
|
132
88
|
|
|
133
|
-
currentScreenShare:
|
|
89
|
+
currentScreenShare: Record<string, any> | null;
|
|
134
90
|
|
|
135
|
-
lastScreenShare:
|
|
91
|
+
lastScreenShare: Record<string, any> | null;
|
|
136
92
|
|
|
137
93
|
shouldSendReinvite: boolean;
|
|
138
94
|
|
|
139
|
-
constructor(
|
|
140
|
-
client: WazoWebRTCClient,
|
|
141
|
-
audioOutputDeviceId: ?string,
|
|
142
|
-
allowVideo: boolean = false,
|
|
143
|
-
audioRingDeviceId?: string,
|
|
144
|
-
) {
|
|
95
|
+
constructor(client: WazoWebRTCClient, audioOutputDeviceId: string | null | undefined, allowVideo = false, audioRingDeviceId?: string) {
|
|
145
96
|
super();
|
|
146
|
-
|
|
147
97
|
this.client = client;
|
|
148
98
|
this.allowVideo = allowVideo;
|
|
149
99
|
this.callSessions = {};
|
|
@@ -154,9 +104,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
154
104
|
this.incomingSessions = [];
|
|
155
105
|
this.ringingEnabled = true;
|
|
156
106
|
this.shouldSendReinvite = false;
|
|
157
|
-
|
|
158
107
|
this.bindClientEvents();
|
|
159
|
-
|
|
160
108
|
this.acceptedSessions = {};
|
|
161
109
|
this.rejectedSessions = {};
|
|
162
110
|
this.ignoredSessions = {};
|
|
@@ -172,7 +120,10 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
172
120
|
}).catch(error => {
|
|
173
121
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
174
122
|
console.error('register error', error, error.message, error.stack);
|
|
175
|
-
logger.error('WebRTC register error', {
|
|
123
|
+
logger.error('WebRTC register error', {
|
|
124
|
+
message: error.message,
|
|
125
|
+
stack: error.stack,
|
|
126
|
+
});
|
|
176
127
|
});
|
|
177
128
|
}
|
|
178
129
|
|
|
@@ -180,6 +131,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
180
131
|
if (!this.client || !this.client.isRegistered()) {
|
|
181
132
|
return null;
|
|
182
133
|
}
|
|
134
|
+
|
|
183
135
|
return this.client.unregister();
|
|
184
136
|
}
|
|
185
137
|
|
|
@@ -187,6 +139,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
187
139
|
if (!this.client) {
|
|
188
140
|
return;
|
|
189
141
|
}
|
|
142
|
+
|
|
190
143
|
logger.info('WebRTC phone stop');
|
|
191
144
|
this.client.stop();
|
|
192
145
|
}
|
|
@@ -199,8 +152,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
199
152
|
return true;
|
|
200
153
|
}
|
|
201
154
|
|
|
202
|
-
async sendReinvite(callSession:
|
|
203
|
-
audioOnly: boolean = false, iceRestart: boolean = false) {
|
|
155
|
+
async sendReinvite(callSession: CallSession | null | undefined, constraints: Record<string, any> | null | undefined = null, conference = false, audioOnly = false, iceRestart = false): Promise<OutgoingInviteRequest | void> {
|
|
204
156
|
const sipSession = this.findSipSession(callSession);
|
|
205
157
|
logger.info('WebRTC phone - send reinvite', {
|
|
206
158
|
sessionId: sipSession ? sipSession.id : null,
|
|
@@ -211,24 +163,25 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
211
163
|
});
|
|
212
164
|
|
|
213
165
|
if (!sipSession) {
|
|
214
|
-
return
|
|
166
|
+
return;
|
|
215
167
|
}
|
|
216
168
|
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
const isUpgrade = shouldScreenShare || (constraints && constraints.video);
|
|
169
|
+
const shouldScreenShare = constraints?.screen;
|
|
170
|
+
const isUpgrade = shouldScreenShare || constraints?.video;
|
|
220
171
|
|
|
221
172
|
// Downgrade
|
|
222
173
|
if (constraints && !isUpgrade) {
|
|
223
174
|
// No reinvite needed
|
|
224
175
|
this._downgradeToAudio(callSession);
|
|
225
|
-
|
|
176
|
+
|
|
177
|
+
return;
|
|
226
178
|
}
|
|
227
179
|
|
|
228
180
|
if (isUpgrade) {
|
|
229
181
|
const shouldReinvite = await this._upgradeToVideo(callSession, constraints, conference);
|
|
182
|
+
|
|
230
183
|
if (!shouldReinvite) {
|
|
231
|
-
return
|
|
184
|
+
return;
|
|
232
185
|
}
|
|
233
186
|
}
|
|
234
187
|
|
|
@@ -236,11 +189,15 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
236
189
|
}
|
|
237
190
|
|
|
238
191
|
getUserAgent() {
|
|
239
|
-
return
|
|
192
|
+
return this.client?.config?.userAgentString || 'webrtc-phone';
|
|
240
193
|
}
|
|
241
194
|
|
|
242
195
|
startHeartbeat() {
|
|
243
|
-
logger.info('WebRTC phone - start heartbeat', {
|
|
196
|
+
logger.info('WebRTC phone - start heartbeat', {
|
|
197
|
+
client: !!this.client,
|
|
198
|
+
hasHeartbeat: this.client.hasHeartbeat(),
|
|
199
|
+
});
|
|
200
|
+
|
|
244
201
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
245
202
|
return;
|
|
246
203
|
}
|
|
@@ -249,7 +206,10 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
249
206
|
}
|
|
250
207
|
|
|
251
208
|
stopHeartbeat() {
|
|
252
|
-
logger.info('WebRTC phone - stopHeartbeat', {
|
|
209
|
+
logger.info('WebRTC phone - stopHeartbeat', {
|
|
210
|
+
client: !!this.client,
|
|
211
|
+
});
|
|
212
|
+
|
|
253
213
|
if (!this.client) {
|
|
254
214
|
return;
|
|
255
215
|
}
|
|
@@ -257,19 +217,23 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
257
217
|
this.client.stopHeartbeat();
|
|
258
218
|
}
|
|
259
219
|
|
|
260
|
-
setOnHeartbeatTimeout(cb:
|
|
220
|
+
setOnHeartbeatTimeout(cb: (...args: Array<any>) => any) {
|
|
261
221
|
this.client.setOnHeartbeatTimeout(cb);
|
|
262
222
|
}
|
|
263
223
|
|
|
264
|
-
setOnHeartbeatCallback(cb:
|
|
224
|
+
setOnHeartbeatCallback(cb: (...args: Array<any>) => any) {
|
|
265
225
|
this.client.setOnHeartbeatCallback(cb);
|
|
266
226
|
}
|
|
267
227
|
|
|
268
228
|
reconnect() {
|
|
269
|
-
logger.info('WebRTC phone - reconnect', {
|
|
229
|
+
logger.info('WebRTC phone - reconnect', {
|
|
230
|
+
client: !!this.client,
|
|
231
|
+
});
|
|
232
|
+
|
|
270
233
|
if (!this.client) {
|
|
271
234
|
return;
|
|
272
235
|
}
|
|
236
|
+
|
|
273
237
|
this.client.attemptReconnection();
|
|
274
238
|
}
|
|
275
239
|
|
|
@@ -291,6 +255,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
291
255
|
if (!this.client) {
|
|
292
256
|
return Promise.reject(new Error('No webrtc client'));
|
|
293
257
|
}
|
|
258
|
+
|
|
294
259
|
return this.client.onConnect();
|
|
295
260
|
}
|
|
296
261
|
|
|
@@ -298,21 +263,26 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
298
263
|
if (!this.client) {
|
|
299
264
|
return Promise.reject(new Error('No webrtc client'));
|
|
300
265
|
}
|
|
266
|
+
|
|
301
267
|
return this.client.onDisconnect();
|
|
302
268
|
}
|
|
303
269
|
|
|
304
|
-
_downgradeToAudio(callSession:
|
|
270
|
+
_downgradeToAudio(callSession: CallSession | null | undefined, withMessage = true) {
|
|
305
271
|
const sipSession = this.findSipSession(callSession);
|
|
272
|
+
|
|
306
273
|
if (!sipSession) {
|
|
307
274
|
return false;
|
|
308
275
|
}
|
|
309
276
|
|
|
310
|
-
logger.info('Downgrade to video', {
|
|
311
|
-
|
|
277
|
+
logger.info('Downgrade to video', {
|
|
278
|
+
id: callSession ? callSession.getId() : null,
|
|
279
|
+
withMessage,
|
|
280
|
+
});
|
|
312
281
|
this.client.downgradeToAudio(sipSession);
|
|
313
282
|
|
|
314
283
|
if (callSession) {
|
|
315
284
|
callSession.cameraEnabled = false;
|
|
285
|
+
|
|
316
286
|
this._updateCallSession(callSession);
|
|
317
287
|
}
|
|
318
288
|
|
|
@@ -324,8 +294,9 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
324
294
|
}
|
|
325
295
|
|
|
326
296
|
// Returns true if we need to send a re-INVITE request
|
|
327
|
-
async _upgradeToVideo(callSession:
|
|
297
|
+
async _upgradeToVideo(callSession: CallSession | null | undefined, constraints: Record<string, any>, isConference: boolean): Promise<boolean> {
|
|
328
298
|
const sipSession = this.findSipSession(callSession);
|
|
299
|
+
|
|
329
300
|
if (!sipSession) {
|
|
330
301
|
return Promise.resolve(false);
|
|
331
302
|
}
|
|
@@ -335,16 +306,16 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
335
306
|
constraints,
|
|
336
307
|
isConference,
|
|
337
308
|
});
|
|
338
|
-
|
|
339
309
|
const shouldScreenShare = constraints && !!constraints.screen;
|
|
340
310
|
const desktop = constraints && constraints.desktop;
|
|
341
311
|
const options = sipSession.sessionDescriptionHandlerOptionsReInvite;
|
|
342
|
-
|
|
343
|
-
|
|
312
|
+
// @ts-ignore
|
|
313
|
+
const wasAudioOnly = options?.audioOnly;
|
|
344
314
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
345
315
|
|
|
346
316
|
if (callSession) {
|
|
347
317
|
callSession.cameraEnabled = true;
|
|
318
|
+
|
|
348
319
|
this._updateCallSession(callSession);
|
|
349
320
|
}
|
|
350
321
|
|
|
@@ -368,13 +339,12 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
368
339
|
return false;
|
|
369
340
|
}
|
|
370
341
|
|
|
371
|
-
_sendReinviteMessage(callSession:
|
|
342
|
+
_sendReinviteMessage(callSession: CallSession | null | undefined, isUpgrade: boolean) {
|
|
372
343
|
const sipSession = this.findSipSession(callSession);
|
|
373
344
|
logger.info('Sending reinvite message', {
|
|
374
345
|
id: callSession ? callSession.getId() : null,
|
|
375
346
|
isUpgrade,
|
|
376
347
|
});
|
|
377
|
-
|
|
378
348
|
// Have to send the message after a delay due to latency to update the remote peer
|
|
379
349
|
setTimeout(() => {
|
|
380
350
|
this.sendMessage(sipSession, JSON.stringify({
|
|
@@ -382,7 +352,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
382
352
|
content: {
|
|
383
353
|
type: ON_MESSAGE_TRACK_UPDATED,
|
|
384
354
|
update: isUpgrade ? 'upgrade' : 'downgrade',
|
|
385
|
-
sipCallId: this.getSipSessionId(sipSession),
|
|
355
|
+
sipCallId: sipSession && this.getSipSessionId(sipSession),
|
|
386
356
|
callId: callSession ? callSession.callId : null,
|
|
387
357
|
number: callSession ? callSession.number : null,
|
|
388
358
|
callerNumber: callSession ? callSession.callerNumber : null,
|
|
@@ -391,18 +361,21 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
391
361
|
}, 2500);
|
|
392
362
|
}
|
|
393
363
|
|
|
394
|
-
_bindEvents(sipSession:
|
|
395
|
-
if (sipSession
|
|
364
|
+
_bindEvents(sipSession: Invitation | Inviter) {
|
|
365
|
+
if (sipSession instanceof Invitation) {
|
|
396
366
|
// Monkey patch to know when canceled with the CANCEL message
|
|
397
367
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
398
|
-
sipSession._onCancel = (message: IncomingRequestMessage) => {
|
|
399
|
-
logger.trace('on sip session canceled', { callId: message.callId });
|
|
400
368
|
|
|
369
|
+
sipSession._onCancel = (message: IncomingRequestMessage) => {
|
|
370
|
+
logger.trace('on sip session canceled', {
|
|
371
|
+
callId: message.callId,
|
|
372
|
+
});
|
|
401
373
|
onCancel(message);
|
|
402
374
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
375
|
+
|
|
403
376
|
const callSession = this._createCallSession(sipSession);
|
|
404
|
-
delete this.callSessions[callSession.getId()];
|
|
405
377
|
|
|
378
|
+
delete this.callSessions[callSession.getId()];
|
|
406
379
|
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
407
380
|
};
|
|
408
381
|
} else if (sipSession instanceof Invitation) {
|
|
@@ -416,29 +389,36 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
416
389
|
// No need to trigger progress for an invitation (eg: when we answer the call).
|
|
417
390
|
return;
|
|
418
391
|
}
|
|
392
|
+
|
|
419
393
|
// When receiving a progress event, we know we are the caller so we have to force incoming to false
|
|
420
|
-
return this.eventEmitter.emit(
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
this.audioOutputVolume,
|
|
425
|
-
);
|
|
426
|
-
case SessionState.Terminating:
|
|
427
|
-
logger.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
394
|
+
return this.eventEmitter.emit(ON_PROGRESS, this._createCallSession(sipSession, null, {
|
|
395
|
+
incoming: false,
|
|
396
|
+
ringing: true,
|
|
397
|
+
}), this.audioOutputDeviceId, this.audioOutputVolume);
|
|
428
398
|
|
|
399
|
+
case SessionState.Terminating:
|
|
400
|
+
logger.info('WebRTC phone - call terminating', {
|
|
401
|
+
sipId: sipSession.id,
|
|
402
|
+
});
|
|
429
403
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
430
|
-
|
|
431
404
|
break;
|
|
432
|
-
|
|
433
|
-
|
|
405
|
+
|
|
406
|
+
case SessionState.Terminated:
|
|
407
|
+
{
|
|
408
|
+
logger.info('WebRTC phone - call terminated', {
|
|
409
|
+
sipId: sipSession.id,
|
|
410
|
+
});
|
|
434
411
|
|
|
435
412
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
436
413
|
const callSession = this._createCallSession(sipSession);
|
|
414
|
+
|
|
437
415
|
callSession.endTime = new Date();
|
|
416
|
+
|
|
438
417
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
439
418
|
|
|
440
419
|
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
441
420
|
}
|
|
421
|
+
|
|
442
422
|
default:
|
|
443
423
|
break;
|
|
444
424
|
}
|
|
@@ -449,12 +429,15 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
449
429
|
}
|
|
450
430
|
|
|
451
431
|
// Video events
|
|
452
|
-
const {
|
|
453
|
-
|
|
432
|
+
const {
|
|
433
|
+
// @ts-ignore
|
|
434
|
+
peerConnection,
|
|
435
|
+
} = sipSession.sessionDescriptionHandler;
|
|
436
|
+
|
|
437
|
+
peerConnection.ontrack = (rawEvent: any) => {
|
|
454
438
|
const event = rawEvent;
|
|
455
439
|
const [stream] = event.streams;
|
|
456
440
|
const kind = event && event.track && event.track.kind;
|
|
457
|
-
|
|
458
441
|
logger.info('on track stream called on the peer connection', {
|
|
459
442
|
callId: this.getSipSessionId(sipSession),
|
|
460
443
|
streamId: stream ? stream.id : null,
|
|
@@ -474,29 +457,31 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
474
457
|
return this.eventEmitter.emit(ON_VIDEO_STREAM, stream, event.track.id, event, sipSession);
|
|
475
458
|
};
|
|
476
459
|
|
|
477
|
-
peerConnection.onremovestream = event => {
|
|
460
|
+
peerConnection.onremovestream = (event: any) => {
|
|
478
461
|
logger.info('on remove stream called on the peer connection', {
|
|
479
462
|
id: event.stream.id,
|
|
480
463
|
tracks: event.stream.getTracks(),
|
|
481
464
|
});
|
|
482
|
-
|
|
483
465
|
this.eventEmitter.emit(ON_REMOVE_STREAM, event.stream);
|
|
484
466
|
};
|
|
485
467
|
}
|
|
486
468
|
|
|
487
|
-
async startScreenSharing(constraints:
|
|
488
|
-
logger.info('WebRTC - start screen sharing', {
|
|
489
|
-
|
|
469
|
+
async startScreenSharing(constraints: Record<string, any>, callSession?: CallSession): Promise<MediaStream> {
|
|
470
|
+
logger.info('WebRTC - start screen sharing', {
|
|
471
|
+
constraints,
|
|
472
|
+
id: callSession ? callSession.getId() : null,
|
|
473
|
+
});
|
|
490
474
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
475
|
+
|
|
491
476
|
if (!screenShareStream) {
|
|
492
477
|
throw new Error(`Can't create media stream for screensharing with: ${JSON.stringify(constraints)}`);
|
|
493
478
|
}
|
|
494
479
|
|
|
495
480
|
const screenTrack = screenShareStream.getVideoTracks()[0];
|
|
496
481
|
const sipSession = this.currentSipSession;
|
|
497
|
-
const pc = this.client.getPeerConnection(this.getSipSessionId(sipSession));
|
|
498
|
-
const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
499
|
-
const localStream = this.client.getLocalStream(this.getSipSessionId(sipSession));
|
|
482
|
+
const pc = sipSession && this.client.getPeerConnection(this.getSipSessionId(sipSession));
|
|
483
|
+
const sender = pc && pc.getSenders && pc.getSenders().find((s: any) => s && s.track && s.track.kind === 'video');
|
|
484
|
+
const localStream = sipSession && this.client.getLocalStream(this.getSipSessionId(sipSession));
|
|
500
485
|
const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
|
|
501
486
|
const hadVideo = !!videoTrack;
|
|
502
487
|
|
|
@@ -515,12 +500,12 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
515
500
|
sender.replaceTrack(screenTrack);
|
|
516
501
|
}
|
|
517
502
|
|
|
518
|
-
this._onScreenSharing(screenShareStream, sipSession, callSession, hadVideo, constraints.desktop);
|
|
503
|
+
this._onScreenSharing(screenShareStream, sipSession as Inviter | Invitation, callSession, hadVideo, constraints.desktop);
|
|
519
504
|
|
|
520
505
|
return screenShareStream;
|
|
521
506
|
}
|
|
522
507
|
|
|
523
|
-
async stopScreenSharing(restoreLocalStream
|
|
508
|
+
async stopScreenSharing(restoreLocalStream = true, callSession?: CallSession | null | undefined): Promise<OutgoingInviteRequest | void> {
|
|
524
509
|
if (!this.currentScreenShare) {
|
|
525
510
|
return;
|
|
526
511
|
}
|
|
@@ -528,57 +513,49 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
528
513
|
logger.info('WebRTC phone - stop screen sharing', {
|
|
529
514
|
restoreLocalStream,
|
|
530
515
|
});
|
|
531
|
-
|
|
532
|
-
let reinvited = false;
|
|
516
|
+
let reinvited: OutgoingInviteRequest | void;
|
|
533
517
|
|
|
534
518
|
try {
|
|
535
519
|
if (this.currentScreenShare.stream) {
|
|
536
|
-
this.currentScreenShare.stream.getTracks().forEach(track => track.stop());
|
|
520
|
+
this.currentScreenShare.stream.getTracks().forEach((track: MediaStreamTrack) => track.stop());
|
|
537
521
|
}
|
|
538
522
|
|
|
539
523
|
if (restoreLocalStream) {
|
|
540
524
|
const targetCallSession = callSession || this.currentCallSession;
|
|
541
525
|
const conference = this.isConference(targetCallSession);
|
|
542
|
-
|
|
543
526
|
// When stopping screenshare and we had video before that, we have to re-upgrade
|
|
544
527
|
// When upgrading directly to screenshare (eg: we don't have a videoLocalStream to replace)
|
|
545
528
|
// We have to downgrade to audio.
|
|
546
529
|
const screenshareStopped = this.currentScreenShare.hadVideo;
|
|
547
|
-
const constraints = {
|
|
530
|
+
const constraints = {
|
|
531
|
+
audio: false,
|
|
532
|
+
video: screenshareStopped,
|
|
533
|
+
};
|
|
548
534
|
|
|
549
535
|
// We have to remove the video sender to be able to re-upgrade to video in `sendReinvite` below
|
|
550
536
|
this._downgradeToAudio(targetCallSession, false);
|
|
537
|
+
|
|
551
538
|
// Wait for the track to be removed, unless the video sender won't have a null track in `_upgradeToVideo`.
|
|
552
539
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
553
|
-
|
|
554
540
|
reinvited = await this.sendReinvite(targetCallSession, constraints, conference);
|
|
555
541
|
}
|
|
556
|
-
} catch (e) {
|
|
542
|
+
} catch (e: any) {
|
|
557
543
|
console.warn(e);
|
|
558
544
|
}
|
|
559
545
|
|
|
560
546
|
const sipSession = this.currentSipSession;
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
callSession ? this._createCallSession(sipSession, callSession, { screensharing: false }) : null,
|
|
565
|
-
);
|
|
566
|
-
|
|
547
|
+
this.eventEmitter.emit(ON_SHARE_SCREEN_ENDED, callSession && sipSession ? this._createCallSession(sipSession, callSession, {
|
|
548
|
+
screensharing: false,
|
|
549
|
+
}) : null);
|
|
567
550
|
this.currentScreenShare = null;
|
|
568
|
-
|
|
569
551
|
return reinvited;
|
|
570
552
|
}
|
|
571
553
|
|
|
572
|
-
_onScreenSharing(screenStream:
|
|
573
|
-
sipSession: Session,
|
|
574
|
-
callSession: ?CallSession,
|
|
575
|
-
hadVideo: boolean,
|
|
576
|
-
desktop?: ?boolean = false) {
|
|
554
|
+
_onScreenSharing(screenStream: MediaStream, sipSession: Invitation | Inviter, callSession: CallSession | null | undefined, hadVideo: boolean, desktop?: boolean | null | undefined) {
|
|
577
555
|
const screenTrack = screenStream.getVideoTracks()[0];
|
|
578
556
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
579
557
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
580
|
-
const sender = pc && pc.getSenders && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
581
|
-
|
|
558
|
+
const sender = pc && pc.getSenders && pc.getSenders().find((s: any) => s && s.track && s.track.kind === 'video');
|
|
582
559
|
logger.info('WebRTC phone - on screensharing', {
|
|
583
560
|
hadVideo,
|
|
584
561
|
id: this.getSipSessionId(sipSession),
|
|
@@ -592,11 +569,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
592
569
|
id: this.getSipSessionId(sipSession),
|
|
593
570
|
screenTrack,
|
|
594
571
|
});
|
|
595
|
-
|
|
596
|
-
this.eventEmitter.emit(
|
|
597
|
-
ON_SHARE_SCREEN_ENDING,
|
|
598
|
-
this._createCallSession(sipSession, callSession),
|
|
599
|
-
);
|
|
572
|
+
this.eventEmitter.emit(ON_SHARE_SCREEN_ENDING, this._createCallSession(sipSession, callSession));
|
|
600
573
|
};
|
|
601
574
|
}
|
|
602
575
|
|
|
@@ -607,38 +580,41 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
607
580
|
sipSessionId,
|
|
608
581
|
desktop,
|
|
609
582
|
};
|
|
610
|
-
|
|
611
583
|
this.client.setLocalMediaStream(this.getSipSessionId(sipSession), screenStream);
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
this._createCallSession(sipSession, callSession, { screensharing: true }),
|
|
616
|
-
screenStream,
|
|
617
|
-
);
|
|
584
|
+
this.eventEmitter.emit(ON_SHARE_SCREEN_STARTED, this._createCallSession(sipSession, callSession, {
|
|
585
|
+
screensharing: true,
|
|
586
|
+
}), screenStream);
|
|
618
587
|
}
|
|
619
588
|
|
|
620
|
-
_onCallAccepted(sipSession:
|
|
621
|
-
logger.info('WebRTC phone - on call accepted', {
|
|
589
|
+
_onCallAccepted(sipSession: Inviter | Invitation, cameraEnabled: boolean): CallSession {
|
|
590
|
+
logger.info('WebRTC phone - on call accepted', {
|
|
591
|
+
sipId: sipSession.id,
|
|
592
|
+
cameraEnabled,
|
|
593
|
+
});
|
|
622
594
|
|
|
623
595
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
596
|
+
|
|
624
597
|
this.currentSipSession = sipSession;
|
|
625
598
|
this.currentCallSession = callSession;
|
|
626
|
-
|
|
627
599
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call accepted');
|
|
628
600
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
601
|
+
|
|
629
602
|
if (sipSessionId) {
|
|
630
603
|
this.removeIncomingSessions(sipSessionId);
|
|
631
604
|
}
|
|
632
605
|
|
|
633
606
|
callSession.answerTime = new Date();
|
|
607
|
+
|
|
634
608
|
this._updateCallSession(callSession);
|
|
635
|
-
this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
|
|
636
609
|
|
|
610
|
+
this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
|
|
637
611
|
return callSession;
|
|
638
612
|
}
|
|
639
613
|
|
|
640
614
|
changeAudioDevice(id: string) {
|
|
641
|
-
logger.info('WebRTC phone - change audio device', {
|
|
615
|
+
logger.info('WebRTC phone - change audio device', {
|
|
616
|
+
deviceId: id,
|
|
617
|
+
});
|
|
642
618
|
this.audioOutputDeviceId = id;
|
|
643
619
|
this.client.changeAudioOutputDevice(id);
|
|
644
620
|
}
|
|
@@ -648,52 +624,60 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
648
624
|
}
|
|
649
625
|
|
|
650
626
|
changeRingDevice(id: string) {
|
|
651
|
-
logger.info('WebRTC phone - changing ring device', {
|
|
652
|
-
|
|
627
|
+
logger.info('WebRTC phone - changing ring device', {
|
|
628
|
+
id,
|
|
629
|
+
});
|
|
653
630
|
this.audioRingDeviceId = id;
|
|
654
631
|
}
|
|
655
632
|
|
|
656
633
|
// volume is a value between 0 and 1
|
|
657
634
|
changeAudioVolume(volume: number) {
|
|
658
|
-
logger.info('WebRTC phone - changing audio volume', {
|
|
659
|
-
|
|
635
|
+
logger.info('WebRTC phone - changing audio volume', {
|
|
636
|
+
volume,
|
|
637
|
+
});
|
|
660
638
|
this.audioOutputVolume = volume;
|
|
661
639
|
this.client.changeAudioOutputVolume(volume);
|
|
662
640
|
}
|
|
663
641
|
|
|
664
642
|
// volume is a value between 0 and 1
|
|
665
643
|
changeRingVolume(volume: number) {
|
|
666
|
-
logger.info('WebRTC phone - changing ring volume', {
|
|
667
|
-
|
|
644
|
+
logger.info('WebRTC phone - changing ring volume', {
|
|
645
|
+
volume,
|
|
646
|
+
});
|
|
668
647
|
this.audioRingVolume = volume;
|
|
669
648
|
}
|
|
670
649
|
|
|
671
|
-
changeAudioInputDevice(id: string, force
|
|
672
|
-
logger.info('WebRTC phone - changeAudio input device', {
|
|
673
|
-
|
|
650
|
+
changeAudioInputDevice(id: string, force?: boolean) {
|
|
651
|
+
logger.info('WebRTC phone - changeAudio input device', {
|
|
652
|
+
deviceId: id,
|
|
653
|
+
});
|
|
674
654
|
return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
|
|
675
655
|
}
|
|
676
656
|
|
|
677
|
-
changeVideoInputDevice(id:
|
|
678
|
-
logger.info('WebRTC phone - change video input device', {
|
|
679
|
-
|
|
657
|
+
async changeVideoInputDevice(id: string): Promise<void | MediaStream | null | undefined> {
|
|
658
|
+
logger.info('WebRTC phone - change video input device', {
|
|
659
|
+
deviceId: id,
|
|
660
|
+
});
|
|
680
661
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
681
662
|
}
|
|
682
663
|
|
|
683
|
-
changeSessionVideoInputDevice(id:
|
|
684
|
-
logger.info('WebRTC phone - change session video input device', {
|
|
685
|
-
|
|
686
|
-
|
|
664
|
+
changeSessionVideoInputDevice(id: string | null | undefined) {
|
|
665
|
+
logger.info('WebRTC phone - change session video input device', {
|
|
666
|
+
deviceId: id,
|
|
667
|
+
});
|
|
668
|
+
return this.currentSipSession && this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
687
669
|
}
|
|
688
670
|
|
|
689
|
-
_onCallTerminated(sipSession:
|
|
690
|
-
logger.info('WebRTC phone - on call terminated', {
|
|
691
|
-
|
|
671
|
+
_onCallTerminated(sipSession: Invitation | Inviter): boolean {
|
|
672
|
+
logger.info('WebRTC phone - on call terminated', {
|
|
673
|
+
sipId: sipSession.id,
|
|
674
|
+
});
|
|
692
675
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
676
|
+
|
|
693
677
|
const callSession = this._createCallSession(sipSession);
|
|
678
|
+
|
|
694
679
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
695
680
|
const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
|
|
696
|
-
|
|
697
681
|
// If the terminated call was an incoming call, we have to re-trigger if it's was the first incoming call
|
|
698
682
|
// Otherwise, we have to re-trigger an incoming call event if another call is incoming
|
|
699
683
|
const shouldRetrigger = isCurrentSession ? this.incomingSessions.length : isCurrentIncomingCall;
|
|
@@ -719,14 +703,12 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
719
703
|
}
|
|
720
704
|
|
|
721
705
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
722
|
-
|
|
723
706
|
// Re-trigger incoming call event for remaining incoming calls
|
|
724
707
|
logger.info('WebRTC phone - check to re-trigger incoming call', {
|
|
725
708
|
sipId: sipSession.id,
|
|
726
709
|
shouldRetrigger,
|
|
727
710
|
hasIncomingCallSession,
|
|
728
711
|
});
|
|
729
|
-
|
|
730
712
|
this.client.onCallEnded(sipSession);
|
|
731
713
|
|
|
732
714
|
if (hasIncomingCallSession && shouldRetrigger) {
|
|
@@ -737,22 +719,19 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
737
719
|
if (!this.currentCallSession) {
|
|
738
720
|
this.eventEmitter.emit(ON_PLAY_RING_SOUND, this.audioRingDeviceId, this.audioRingVolume, nextCallSession);
|
|
739
721
|
} else {
|
|
740
|
-
this.eventEmitter.emit(ON_PLAY_INBOUND_CALL_SIGNAL_SOUND,
|
|
741
|
-
this.audioOutputDeviceId,
|
|
742
|
-
this.audioOutputVolume,
|
|
743
|
-
nextCallSession);
|
|
722
|
+
this.eventEmitter.emit(ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, this.audioOutputDeviceId, this.audioOutputVolume, nextCallSession);
|
|
744
723
|
}
|
|
745
724
|
}
|
|
746
725
|
|
|
747
|
-
|
|
748
|
-
this.eventEmitter.emit(ON_CALL_INCOMING, nextCallSession, nextCallSession.cameraEnabled);
|
|
726
|
+
this.eventEmitter.emit(ON_CALL_INCOMING, nextCallSession, nextCallSession?.cameraEnabled);
|
|
749
727
|
}, 100);
|
|
750
728
|
}
|
|
751
729
|
|
|
752
730
|
if (callSession.getId() in this.ignoredSessions) {
|
|
753
|
-
return;
|
|
731
|
+
return false;
|
|
754
732
|
}
|
|
755
733
|
|
|
734
|
+
// @ts-ignore
|
|
756
735
|
if (!sipSession.isCanceled) {
|
|
757
736
|
setTimeout(() => {
|
|
758
737
|
this.eventEmitter.emit(ON_PLAY_HANGUP_SOUND, this.audioOutputDeviceId, this.audioOutputVolume, callSession);
|
|
@@ -764,6 +743,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
764
743
|
|
|
765
744
|
setActiveSipSession(callSession: CallSession) {
|
|
766
745
|
const sipSessionId = this.findSipSession(callSession);
|
|
746
|
+
|
|
767
747
|
if (!sipSessionId) {
|
|
768
748
|
return;
|
|
769
749
|
}
|
|
@@ -780,17 +760,20 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
780
760
|
// Maybe due to https://github.com/react-native-webrtc/react-native-webrtc/issues/401
|
|
781
761
|
hasActiveRemoteVideoStream() {
|
|
782
762
|
const sipSession = this.currentSipSession;
|
|
763
|
+
|
|
783
764
|
if (!sipSession) {
|
|
784
765
|
return false;
|
|
785
766
|
}
|
|
786
767
|
|
|
787
|
-
const {
|
|
788
|
-
|
|
789
|
-
|
|
768
|
+
const {
|
|
769
|
+
// @ts-ignore
|
|
770
|
+
peerConnection,
|
|
771
|
+
} = sipSession.sessionDescriptionHandler;
|
|
772
|
+
const remoteStream: MediaStream = peerConnection.getRemoteStreams().find((stream: MediaStream) => !!stream.getVideoTracks().length);
|
|
790
773
|
return remoteStream && remoteStream.getVideoTracks().some(track => !track.muted);
|
|
791
774
|
}
|
|
792
775
|
|
|
793
|
-
callCount() {
|
|
776
|
+
callCount(): number {
|
|
794
777
|
return Object.keys(this.callSessions).length;
|
|
795
778
|
}
|
|
796
779
|
|
|
@@ -811,33 +794,30 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
811
794
|
}
|
|
812
795
|
|
|
813
796
|
// Deprecated
|
|
814
|
-
getLocalStreamForCall(callSession: CallSession):
|
|
797
|
+
getLocalStreamForCall(callSession: CallSession): MediaStream | null | undefined {
|
|
815
798
|
logger.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
816
|
-
|
|
817
799
|
return this.getLocalStream(callSession);
|
|
818
800
|
}
|
|
819
801
|
|
|
820
802
|
// Deprecated
|
|
821
|
-
getRemoteStreamForCall(callSession: CallSession):
|
|
803
|
+
getRemoteStreamForCall(callSession: CallSession): MediaStream | null | undefined {
|
|
822
804
|
logger.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
823
|
-
|
|
824
805
|
return this.getRemoteVideoStream(callSession);
|
|
825
806
|
}
|
|
826
807
|
|
|
827
|
-
getRemoteStreamsForCall(callSession: CallSession):
|
|
808
|
+
getRemoteStreamsForCall(callSession: CallSession): MediaStream | null | undefined {
|
|
828
809
|
logger.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
829
|
-
|
|
830
810
|
return this.getRemoteStream(callSession);
|
|
831
811
|
}
|
|
832
812
|
|
|
833
813
|
accept(callSession: CallSession, cameraEnabled?: boolean): Promise<string | null> {
|
|
834
|
-
logger.info('WebRTC phone - accept call', {
|
|
814
|
+
logger.info('WebRTC phone - accept call', {
|
|
815
|
+
id: callSession ? callSession.getId() : 'n/a',
|
|
816
|
+
cameraEnabled,
|
|
817
|
+
});
|
|
818
|
+
|
|
835
819
|
if (this.currentSipSession) {
|
|
836
|
-
this.holdSipSession(
|
|
837
|
-
this.currentSipSession,
|
|
838
|
-
this.currentCallSession,
|
|
839
|
-
true,
|
|
840
|
-
);
|
|
820
|
+
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
841
821
|
}
|
|
842
822
|
|
|
843
823
|
if (!callSession) {
|
|
@@ -846,34 +826,39 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
846
826
|
}
|
|
847
827
|
|
|
848
828
|
const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
|
|
829
|
+
|
|
849
830
|
if (sipSessionId && !(sipSessionId in this.callSessions)) {
|
|
850
|
-
logger.warn('Call session already ended or not found, can\'t accept it.', {
|
|
831
|
+
logger.warn('Call session already ended or not found, can\'t accept it.', {
|
|
832
|
+
sipSessionId,
|
|
833
|
+
});
|
|
851
834
|
return Promise.resolve(null);
|
|
852
835
|
}
|
|
853
836
|
|
|
854
837
|
if (callSession.getId() in this.acceptedSessions) {
|
|
855
|
-
logger.warn('CallSession already accepted.', {
|
|
838
|
+
logger.warn('CallSession already accepted.', {
|
|
839
|
+
id: callSession ? callSession.getId() : 'n/a',
|
|
840
|
+
});
|
|
856
841
|
return Promise.resolve(callSession.sipCallId);
|
|
857
842
|
}
|
|
858
843
|
|
|
859
844
|
this.shouldSendReinvite = false;
|
|
860
845
|
callSession.answerTime = new Date();
|
|
846
|
+
|
|
861
847
|
this._updateCallSession(callSession);
|
|
862
|
-
this.acceptedSessions[callSession.getId()] = true;
|
|
863
848
|
|
|
849
|
+
this.acceptedSessions[callSession.getId()] = true;
|
|
864
850
|
this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
|
|
851
|
+
const sipSession = this.client.getSipSession(callSession.getId()) as Invitation;
|
|
865
852
|
|
|
866
|
-
const sipSession = this.client.getSipSession(callSession.getId());
|
|
867
853
|
if (sipSession) {
|
|
868
854
|
if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
|
|
869
855
|
logger.warn('Trying to answer a terminated sipSession.');
|
|
870
|
-
|
|
871
856
|
return Promise.resolve(null);
|
|
872
857
|
}
|
|
873
858
|
|
|
874
|
-
logger.info('accept call, session found', {
|
|
875
|
-
|
|
876
|
-
|
|
859
|
+
logger.info('accept call, session found', {
|
|
860
|
+
sipId: sipSession.id,
|
|
861
|
+
});
|
|
877
862
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
878
863
|
return callSession.sipCallId;
|
|
879
864
|
}).catch(e => {
|
|
@@ -883,7 +868,16 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
883
868
|
});
|
|
884
869
|
}
|
|
885
870
|
|
|
886
|
-
|
|
871
|
+
const error = 'No CallSession found to accept.';
|
|
872
|
+
|
|
873
|
+
logger.warn(error, {
|
|
874
|
+
id: callSession ? callSession.getId() : 'n/a',
|
|
875
|
+
ids: this.client.getSipSessionIds(),
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
if (callSession) {
|
|
879
|
+
this.eventEmitter.emit(ON_CALL_ERROR, new Error(error), callSession);
|
|
880
|
+
}
|
|
887
881
|
|
|
888
882
|
return Promise.resolve(null);
|
|
889
883
|
}
|
|
@@ -893,80 +887,87 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
893
887
|
}
|
|
894
888
|
|
|
895
889
|
async reject(callSession: CallSession): Promise<void> {
|
|
896
|
-
logger.info('reject WebRTC called', {
|
|
897
|
-
|
|
890
|
+
logger.info('reject WebRTC called', {
|
|
891
|
+
id: callSession.getId(),
|
|
892
|
+
});
|
|
898
893
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
894
|
+
|
|
899
895
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
900
896
|
return;
|
|
901
897
|
}
|
|
902
898
|
|
|
903
899
|
this.shouldSendReinvite = false;
|
|
904
900
|
this.rejectedSessions[callSession.getId()] = true;
|
|
905
|
-
|
|
906
901
|
const sipSession = this.findSipSession(callSession);
|
|
907
|
-
if (sipSession) {
|
|
908
|
-
logger.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
909
902
|
|
|
903
|
+
if (sipSession) {
|
|
904
|
+
logger.info('WebRTC rejecting', {
|
|
905
|
+
sipId: sipSession.id,
|
|
906
|
+
});
|
|
910
907
|
this.client.hangup(sipSession);
|
|
911
908
|
}
|
|
912
909
|
}
|
|
913
910
|
|
|
914
911
|
async ignore(callSession: CallSession): Promise<void> {
|
|
915
|
-
logger.info('WebRTC ignore', {
|
|
916
|
-
|
|
912
|
+
logger.info('WebRTC ignore', {
|
|
913
|
+
id: callSession.getId(),
|
|
914
|
+
});
|
|
917
915
|
// kill the ring
|
|
918
916
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
919
917
|
this.ignoredSessions[callSession.getId()] = true;
|
|
920
918
|
callSession.ignore();
|
|
921
919
|
}
|
|
922
920
|
|
|
923
|
-
atxfer(callSession: CallSession):
|
|
924
|
-
const sipSession = this.findSipSession(callSession);
|
|
921
|
+
atxfer(callSession: CallSession): Record<string, any> | null | undefined {
|
|
922
|
+
const sipSession = this.findSipSession(callSession) as Inviter;
|
|
925
923
|
|
|
926
924
|
if (sipSession) {
|
|
927
|
-
logger.info('WebRTC atxfer', {
|
|
928
|
-
|
|
925
|
+
logger.info('WebRTC atxfer', {
|
|
926
|
+
sipId: sipSession.id,
|
|
927
|
+
});
|
|
929
928
|
return this.client.atxfer(sipSession);
|
|
930
929
|
}
|
|
931
930
|
}
|
|
932
931
|
|
|
933
|
-
hold(callSession: CallSession, withEvent
|
|
934
|
-
logger.info('WebRTC hold', {
|
|
935
|
-
|
|
932
|
+
hold(callSession: CallSession, withEvent = true): Promise<OutgoingInviteRequest | void> | null | undefined {
|
|
933
|
+
logger.info('WebRTC hold', {
|
|
934
|
+
id: callSession.getId(),
|
|
935
|
+
});
|
|
936
936
|
const sipSession = this.findSipSession(callSession);
|
|
937
|
-
|
|
938
937
|
return sipSession ? this.holdSipSession(sipSession, callSession, withEvent) : null;
|
|
939
938
|
}
|
|
940
939
|
|
|
941
940
|
// @Deprecated
|
|
942
|
-
unhold(callSession: CallSession, withEvent
|
|
941
|
+
unhold(callSession: CallSession, withEvent = true): Promise<MediaStream | void | null> {
|
|
943
942
|
console.warn('Please note that `phone.unhold()` is being deprecated; `phone.resume()` is the preferred method');
|
|
944
|
-
|
|
945
943
|
return this.resume(callSession, withEvent);
|
|
946
944
|
}
|
|
947
945
|
|
|
948
|
-
resume(callSession?: CallSession, withEvent
|
|
949
|
-
logger.info('WebRTC resume called', {
|
|
950
|
-
|
|
946
|
+
resume(callSession?: CallSession, withEvent = true): Promise<MediaStream | void | null> {
|
|
947
|
+
logger.info('WebRTC resume called', {
|
|
948
|
+
id: callSession ? callSession.getId() : null,
|
|
949
|
+
});
|
|
951
950
|
const sipSession = this.findSipSession(callSession);
|
|
951
|
+
|
|
952
952
|
if (!sipSession) {
|
|
953
953
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
954
954
|
}
|
|
955
955
|
|
|
956
|
-
logger.info('WebRTC resuming', {
|
|
956
|
+
logger.info('WebRTC resuming', {
|
|
957
|
+
sipId: sipSession.id,
|
|
958
|
+
});
|
|
957
959
|
|
|
958
960
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
959
961
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
960
|
-
logger.info('WebRTC hold call after resume', {
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
withEvent,
|
|
965
|
-
);
|
|
962
|
+
logger.info('WebRTC hold call after resume', {
|
|
963
|
+
id: this.currentSipSession.id,
|
|
964
|
+
});
|
|
965
|
+
this.holdSipSession(this.currentSipSession, this.currentCallSession, withEvent);
|
|
966
966
|
}
|
|
967
967
|
|
|
968
968
|
const promise = this.unholdSipSession(sipSession, callSession, withEvent);
|
|
969
969
|
this.currentSipSession = sipSession;
|
|
970
|
+
|
|
970
971
|
if (callSession) {
|
|
971
972
|
this.currentCallSession = callSession;
|
|
972
973
|
}
|
|
@@ -974,18 +975,17 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
974
975
|
return promise;
|
|
975
976
|
}
|
|
976
977
|
|
|
977
|
-
async holdSipSession(
|
|
978
|
-
sipSession: Session,
|
|
979
|
-
callSession: ?CallSession,
|
|
980
|
-
withEvent: boolean = true,
|
|
981
|
-
): Promise<any> {
|
|
978
|
+
async holdSipSession(sipSession: Inviter | Invitation, callSession: CallSession | null | undefined, withEvent = true): Promise<OutgoingInviteRequest | void> {
|
|
982
979
|
if (!sipSession) {
|
|
983
980
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
984
981
|
}
|
|
982
|
+
|
|
985
983
|
const sessionId = this.getSipSessionId(sipSession);
|
|
986
984
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
987
|
-
|
|
988
|
-
|
|
985
|
+
logger.info('WebRTC hold sip session', {
|
|
986
|
+
sipId: sipSession.id,
|
|
987
|
+
hasVideo,
|
|
988
|
+
});
|
|
989
989
|
|
|
990
990
|
// Stop screenshare if needed
|
|
991
991
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -999,8 +999,8 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
1001
|
const isConference = !!callSession && callSession.isConference();
|
|
1002
|
-
|
|
1003
1002
|
const promise = this.client.hold(sipSession, isConference, hasVideo);
|
|
1003
|
+
|
|
1004
1004
|
if (withEvent) {
|
|
1005
1005
|
this.eventEmitter.emit(ON_CALL_HELD, this._createCallSession(sipSession, callSession));
|
|
1006
1006
|
}
|
|
@@ -1008,21 +1008,20 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1008
1008
|
return promise;
|
|
1009
1009
|
}
|
|
1010
1010
|
|
|
1011
|
-
async unholdSipSession(
|
|
1012
|
-
sipSession: Session,
|
|
1013
|
-
callSession: ?CallSession,
|
|
1014
|
-
withEvent: boolean = true,
|
|
1015
|
-
): Promise<any> {
|
|
1011
|
+
async unholdSipSession(sipSession: Inviter | Invitation, callSession: CallSession | null | undefined, withEvent = true): Promise<MediaStream | void | null> {
|
|
1016
1012
|
if (!sipSession) {
|
|
1017
1013
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
1018
1014
|
}
|
|
1019
1015
|
|
|
1020
1016
|
const isConference = !!callSession && callSession.isConference();
|
|
1021
|
-
|
|
1022
1017
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1023
|
-
logger.info('WebRTC unhold sip session', {
|
|
1024
|
-
|
|
1025
|
-
|
|
1018
|
+
logger.info('WebRTC unhold sip session', {
|
|
1019
|
+
sessionId,
|
|
1020
|
+
isConference,
|
|
1021
|
+
});
|
|
1022
|
+
const {
|
|
1023
|
+
hasVideo,
|
|
1024
|
+
} = this.client.getHeldSession(sessionId) || {};
|
|
1026
1025
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
1027
1026
|
const wasDesktop = this.lastScreenShare && this.lastScreenShare.desktop;
|
|
1028
1027
|
const promise = this.client.unhold(sipSession, isConference);
|
|
@@ -1034,20 +1033,22 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1034
1033
|
screen: wasScreensharing,
|
|
1035
1034
|
desktop: wasDesktop,
|
|
1036
1035
|
};
|
|
1037
|
-
|
|
1038
1036
|
await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
1039
1037
|
}
|
|
1040
1038
|
|
|
1041
|
-
const onScreenSharing = stream => {
|
|
1039
|
+
const onScreenSharing = (stream: MediaStream | null | undefined) => {
|
|
1042
1040
|
const hadVideo = this.lastScreenShare && this.lastScreenShare.hadVideo;
|
|
1041
|
+
|
|
1043
1042
|
if (stream) {
|
|
1044
1043
|
this._onScreenSharing(stream, sipSession, callSession, hadVideo);
|
|
1045
1044
|
}
|
|
1045
|
+
|
|
1046
1046
|
this.lastScreenShare = null;
|
|
1047
1047
|
};
|
|
1048
1048
|
|
|
1049
1049
|
if (withEvent) {
|
|
1050
1050
|
const updatedCallSession = this._createCallSession(sipSession, callSession);
|
|
1051
|
+
|
|
1051
1052
|
// Deprecated event
|
|
1052
1053
|
this.eventEmitter.emit(ON_CALL_UNHELD, updatedCallSession);
|
|
1053
1054
|
this.eventEmitter.emit(ON_CALL_RESUMED, updatedCallSession);
|
|
@@ -1055,6 +1056,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1055
1056
|
|
|
1056
1057
|
return promise.then(() => {
|
|
1057
1058
|
const stream = callSession ? this.getLocalVideoStream(callSession) : null;
|
|
1059
|
+
|
|
1058
1060
|
if (wasScreensharing) {
|
|
1059
1061
|
onScreenSharing(stream);
|
|
1060
1062
|
}
|
|
@@ -1063,17 +1065,24 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1063
1065
|
});
|
|
1064
1066
|
}
|
|
1065
1067
|
|
|
1066
|
-
mute(callSession:
|
|
1067
|
-
logger.info('WebRTC mute called', {
|
|
1068
|
-
|
|
1068
|
+
mute(callSession: CallSession | null | undefined, withEvent = true): void {
|
|
1069
|
+
logger.info('WebRTC mute called', {
|
|
1070
|
+
id: callSession ? callSession.getId() : null,
|
|
1071
|
+
});
|
|
1069
1072
|
const sipSession = this.findSipSession(callSession);
|
|
1073
|
+
|
|
1070
1074
|
if (!sipSession) {
|
|
1071
1075
|
return;
|
|
1072
1076
|
}
|
|
1073
1077
|
|
|
1074
|
-
logger.info('WebRTC muting', {
|
|
1078
|
+
logger.info('WebRTC muting', {
|
|
1079
|
+
sipId: sipSession.id,
|
|
1080
|
+
});
|
|
1075
1081
|
this.client.mute(sipSession);
|
|
1076
|
-
|
|
1082
|
+
|
|
1083
|
+
const newCallSession = this._createCallSession(sipSession, callSession, {
|
|
1084
|
+
muted: true,
|
|
1085
|
+
});
|
|
1077
1086
|
|
|
1078
1087
|
if (this.currentCallSession && newCallSession.is(this.currentCallSession)) {
|
|
1079
1088
|
this.currentCallSession = newCallSession;
|
|
@@ -1084,17 +1093,24 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1084
1093
|
}
|
|
1085
1094
|
}
|
|
1086
1095
|
|
|
1087
|
-
unmute(callSession:
|
|
1088
|
-
logger.info('WebRTC unmute called', {
|
|
1089
|
-
|
|
1096
|
+
unmute(callSession: CallSession | null | undefined, withEvent = true): void {
|
|
1097
|
+
logger.info('WebRTC unmute called', {
|
|
1098
|
+
id: callSession ? callSession.getId() : null,
|
|
1099
|
+
});
|
|
1090
1100
|
const sipSession = this.findSipSession(callSession);
|
|
1101
|
+
|
|
1091
1102
|
if (!sipSession) {
|
|
1092
1103
|
return;
|
|
1093
1104
|
}
|
|
1094
1105
|
|
|
1095
|
-
logger.info('WebRTC unmuting', {
|
|
1106
|
+
logger.info('WebRTC unmuting', {
|
|
1107
|
+
sipId: sipSession.id,
|
|
1108
|
+
});
|
|
1096
1109
|
this.client.unmute(sipSession);
|
|
1097
|
-
|
|
1110
|
+
|
|
1111
|
+
const newCallSession = this._createCallSession(sipSession, callSession, {
|
|
1112
|
+
muted: false,
|
|
1113
|
+
});
|
|
1098
1114
|
|
|
1099
1115
|
if (this.currentCallSession && newCallSession.is(this.currentCallSession)) {
|
|
1100
1116
|
this.currentCallSession = newCallSession;
|
|
@@ -1107,6 +1123,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1107
1123
|
|
|
1108
1124
|
isAudioMuted(callSession: CallSession): boolean {
|
|
1109
1125
|
const sipSession = this.findSipSession(callSession);
|
|
1126
|
+
|
|
1110
1127
|
if (!sipSession) {
|
|
1111
1128
|
return true;
|
|
1112
1129
|
}
|
|
@@ -1116,42 +1133,57 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1116
1133
|
|
|
1117
1134
|
turnCameraOn(callSession?: CallSession): void {
|
|
1118
1135
|
const sipSession = this.findSipSession(callSession);
|
|
1136
|
+
|
|
1119
1137
|
if (!sipSession) {
|
|
1120
1138
|
return;
|
|
1121
1139
|
}
|
|
1122
|
-
logger.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
1123
1140
|
|
|
1141
|
+
logger.info('WebRTC turn camera on', {
|
|
1142
|
+
sipId: sipSession.id,
|
|
1143
|
+
});
|
|
1124
1144
|
this.client.toggleCameraOn(sipSession);
|
|
1125
|
-
|
|
1126
1145
|
this.eventEmitter.emit(ON_CAMERA_RESUMED, this._createCameraResumedCallSession(sipSession, callSession));
|
|
1127
1146
|
}
|
|
1128
1147
|
|
|
1129
1148
|
turnCameraOff(callSession?: CallSession): void {
|
|
1130
1149
|
const sipSession = this.findSipSession(callSession);
|
|
1150
|
+
|
|
1131
1151
|
if (!sipSession) {
|
|
1132
1152
|
return;
|
|
1133
1153
|
}
|
|
1134
|
-
logger.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
1135
1154
|
|
|
1155
|
+
logger.info('WebRTC turn camera off', {
|
|
1156
|
+
sipId: sipSession.id,
|
|
1157
|
+
});
|
|
1136
1158
|
this.client.toggleCameraOff(sipSession);
|
|
1137
1159
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
1138
1160
|
}
|
|
1139
1161
|
|
|
1140
|
-
sendKey(callSession:
|
|
1162
|
+
sendKey(callSession: CallSession | null | undefined, tone: string): void {
|
|
1141
1163
|
const sipSession = this.findSipSession(callSession);
|
|
1164
|
+
|
|
1142
1165
|
if (!sipSession) {
|
|
1143
1166
|
return;
|
|
1144
1167
|
}
|
|
1145
1168
|
|
|
1146
|
-
logger.info('WebRTC send key', {
|
|
1169
|
+
logger.info('WebRTC send key', {
|
|
1170
|
+
sipId: sipSession.id,
|
|
1171
|
+
tone,
|
|
1172
|
+
});
|
|
1147
1173
|
this.client.sendDTMF(sipSession, tone);
|
|
1148
1174
|
}
|
|
1149
1175
|
|
|
1150
1176
|
// Should be async to match CTIPhone definition
|
|
1151
1177
|
// @TODO: line is not used here
|
|
1152
|
-
async makeCall(number: string, line: any, cameraEnabled?: boolean,
|
|
1153
|
-
|
|
1154
|
-
|
|
1178
|
+
async makeCall(number: string, line: any, cameraEnabled?: boolean, audioOnly = false, conference = false): Promise<CallSession | null | undefined> {
|
|
1179
|
+
logger.info('make WebRTC call', {
|
|
1180
|
+
number,
|
|
1181
|
+
lineId: line ? line.id : null,
|
|
1182
|
+
cameraEnabled,
|
|
1183
|
+
audioOnly,
|
|
1184
|
+
conference,
|
|
1185
|
+
});
|
|
1186
|
+
|
|
1155
1187
|
if (!number) {
|
|
1156
1188
|
return Promise.resolve(null);
|
|
1157
1189
|
}
|
|
@@ -1159,39 +1191,43 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1159
1191
|
if (!this.client.isRegistered()) {
|
|
1160
1192
|
await this.client.register();
|
|
1161
1193
|
}
|
|
1194
|
+
|
|
1162
1195
|
if (this.currentSipSession) {
|
|
1163
|
-
this.holdSipSession(
|
|
1164
|
-
this.currentSipSession,
|
|
1165
|
-
this.currentCallSession,
|
|
1166
|
-
true,
|
|
1167
|
-
).catch(e => {
|
|
1196
|
+
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
1168
1197
|
logger.warn('Unable to hold current session when making another call', e);
|
|
1169
1198
|
});
|
|
1170
1199
|
}
|
|
1171
1200
|
|
|
1172
|
-
let sipSession:
|
|
1201
|
+
let sipSession: Inviter | Invitation;
|
|
1202
|
+
|
|
1173
1203
|
try {
|
|
1174
1204
|
sipSession = this.client.call(number, this.allowVideo ? cameraEnabled : false, audioOnly, conference);
|
|
1205
|
+
|
|
1175
1206
|
this._bindEvents(sipSession);
|
|
1176
|
-
} catch (error) {
|
|
1177
|
-
|
|
1178
|
-
|
|
1207
|
+
} catch (error: any) {
|
|
1208
|
+
logger.warn('make WebRTC call, error', {
|
|
1209
|
+
message: error.message,
|
|
1210
|
+
stack: error.stack,
|
|
1211
|
+
});
|
|
1179
1212
|
return Promise.resolve(null);
|
|
1180
1213
|
}
|
|
1214
|
+
|
|
1181
1215
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
1216
|
+
|
|
1182
1217
|
callSession.setIsConference(conference);
|
|
1183
1218
|
callSession.creationTime = new Date();
|
|
1219
|
+
|
|
1184
1220
|
this._updateCallSession(callSession);
|
|
1185
1221
|
|
|
1186
1222
|
this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
1187
|
-
|
|
1188
1223
|
this.currentSipSession = sipSession;
|
|
1189
1224
|
this.currentCallSession = callSession;
|
|
1190
|
-
|
|
1191
1225
|
this.eventEmitter.emit(ON_CALL_OUTGOING, callSession);
|
|
1192
1226
|
|
|
1193
1227
|
// If an invite promise exists, catch exceptions on it to trigger error like OverConstraintsError.
|
|
1228
|
+
// @ts-ignore
|
|
1194
1229
|
if (sipSession.invitePromise) {
|
|
1230
|
+
// @ts-ignore
|
|
1195
1231
|
sipSession.invitePromise.catch(error => {
|
|
1196
1232
|
this.eventEmitter.emit(ON_CALL_ERROR, error, callSession);
|
|
1197
1233
|
});
|
|
@@ -1200,21 +1236,23 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1200
1236
|
return Promise.resolve(callSession);
|
|
1201
1237
|
}
|
|
1202
1238
|
|
|
1203
|
-
transfer(callSession:
|
|
1239
|
+
transfer(callSession: CallSession | null | undefined, target: string): void {
|
|
1204
1240
|
const sipSession = this.findSipSession(callSession);
|
|
1241
|
+
|
|
1205
1242
|
if (!sipSession) {
|
|
1206
1243
|
return;
|
|
1207
1244
|
}
|
|
1208
1245
|
|
|
1209
|
-
logger.info('WebRTC transfer', {
|
|
1210
|
-
|
|
1246
|
+
logger.info('WebRTC transfer', {
|
|
1247
|
+
sipId: sipSession.id,
|
|
1248
|
+
target,
|
|
1249
|
+
});
|
|
1211
1250
|
this.client.transfer(sipSession, target);
|
|
1212
1251
|
}
|
|
1213
1252
|
|
|
1214
1253
|
async indirectTransfer(source: CallSession, destination: CallSession): Promise<boolean> {
|
|
1215
1254
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
1216
1255
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
1217
|
-
|
|
1218
1256
|
logger.info('WebRTC indirect transfer', {
|
|
1219
1257
|
sipId: sipSession ? sipSession.id : null,
|
|
1220
1258
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
@@ -1236,7 +1274,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1236
1274
|
},
|
|
1237
1275
|
};
|
|
1238
1276
|
|
|
1239
|
-
return sipSessionTarget.refer(sipSession, options);
|
|
1277
|
+
return sipSessionTarget.refer((sipSession as Session), options);
|
|
1240
1278
|
});
|
|
1241
1279
|
}
|
|
1242
1280
|
|
|
@@ -1246,25 +1284,26 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1246
1284
|
|
|
1247
1285
|
confirmCTIIndirectTransfer() {}
|
|
1248
1286
|
|
|
1249
|
-
async hangup(callSession
|
|
1287
|
+
async hangup(callSession?: CallSession | null): Promise<boolean> {
|
|
1250
1288
|
const sipSession = this.findSipSession(callSession);
|
|
1289
|
+
|
|
1251
1290
|
if (!sipSession) {
|
|
1252
|
-
console.error('Call is unknown to the WebRTC phone', callSession ? callSession.sipCallId : null,
|
|
1253
|
-
callSession ? callSession.callId : null);
|
|
1291
|
+
console.error('Call is unknown to the WebRTC phone', callSession ? callSession.sipCallId : null, callSession ? callSession.callId : null);
|
|
1254
1292
|
return false;
|
|
1255
1293
|
}
|
|
1256
1294
|
|
|
1257
|
-
logger.info('WebRTC hangup', {
|
|
1258
|
-
|
|
1295
|
+
logger.info('WebRTC hangup', {
|
|
1296
|
+
sipId: sipSession.id,
|
|
1297
|
+
});
|
|
1259
1298
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
1260
|
-
|
|
1261
1299
|
await this.client.hangup(sipSession);
|
|
1300
|
+
|
|
1262
1301
|
if (callSession) {
|
|
1263
1302
|
// Removal of `this.callSessions` will be done in `_onCallTerminated`.
|
|
1264
1303
|
this.endCurrentCall(callSession);
|
|
1265
1304
|
} else if (sipSessionId) {
|
|
1266
1305
|
if (callSession) {
|
|
1267
|
-
delete this.callSessions[
|
|
1306
|
+
delete this.callSessions[sipSessionId];
|
|
1268
1307
|
}
|
|
1269
1308
|
}
|
|
1270
1309
|
|
|
@@ -1272,34 +1311,33 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1272
1311
|
return true;
|
|
1273
1312
|
}
|
|
1274
1313
|
|
|
1275
|
-
async getStats(callSession:
|
|
1314
|
+
async getStats(callSession: CallSession | null | undefined): Promise<RTCStatsReport | null | undefined> {
|
|
1276
1315
|
const sipSession = this.findSipSession(callSession);
|
|
1277
|
-
|
|
1278
1316
|
return sipSession ? this.client.getStats(sipSession) : null;
|
|
1279
1317
|
}
|
|
1280
1318
|
|
|
1281
|
-
startNetworkMonitoring(callSession:
|
|
1319
|
+
startNetworkMonitoring(callSession: CallSession | null | undefined, interval = 1000) {
|
|
1282
1320
|
const sipSession = this.findSipSession(callSession);
|
|
1283
|
-
|
|
1284
1321
|
return sipSession ? this.client.startNetworkMonitoring(sipSession, interval) : null;
|
|
1285
1322
|
}
|
|
1286
1323
|
|
|
1287
|
-
stopNetworkMonitoring(callSession:
|
|
1324
|
+
stopNetworkMonitoring(callSession: CallSession | null | undefined) {
|
|
1288
1325
|
const sipSession = this.findSipSession(callSession);
|
|
1289
|
-
|
|
1290
1326
|
return sipSession ? this.client.stopNetworkMonitoring(sipSession) : null;
|
|
1291
1327
|
}
|
|
1292
1328
|
|
|
1293
|
-
forceCancel(sipSession:
|
|
1329
|
+
forceCancel(sipSession: Inviter): void {
|
|
1330
|
+
// @ts-ignore
|
|
1294
1331
|
if (!sipSession || !sipSession.outgoingInviteRequest) {
|
|
1295
1332
|
return;
|
|
1296
1333
|
}
|
|
1334
|
+
|
|
1335
|
+
// @ts-ignore
|
|
1297
1336
|
sipSession.outgoingInviteRequest.cancel();
|
|
1298
1337
|
}
|
|
1299
1338
|
|
|
1300
1339
|
endCurrentCall(callSession: CallSession): void {
|
|
1301
1340
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
1302
|
-
|
|
1303
1341
|
logger.info('Ending current call', {
|
|
1304
1342
|
id: callSession ? callSession.getId() : null,
|
|
1305
1343
|
isCurrent,
|
|
@@ -1315,7 +1353,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1315
1353
|
|
|
1316
1354
|
onConnectionMade(): void {}
|
|
1317
1355
|
|
|
1318
|
-
isConference(callSession:
|
|
1356
|
+
isConference(callSession: CallSession | null | undefined): boolean {
|
|
1319
1357
|
if (!callSession) {
|
|
1320
1358
|
return false;
|
|
1321
1359
|
}
|
|
@@ -1323,23 +1361,19 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1323
1361
|
return this.client && this.client.isConference(callSession.sipCallId);
|
|
1324
1362
|
}
|
|
1325
1363
|
|
|
1326
|
-
async close(force
|
|
1364
|
+
async close(force = false): Promise<void> {
|
|
1327
1365
|
logger.info('WebRTC close');
|
|
1328
1366
|
|
|
1329
1367
|
try {
|
|
1330
|
-
await Promise.race([
|
|
1331
|
-
|
|
1332
|
-
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
1333
|
-
]);
|
|
1334
|
-
} catch (e) {
|
|
1368
|
+
await Promise.race([this.unregister(), new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000))]);
|
|
1369
|
+
} catch (e: any) {
|
|
1335
1370
|
logger.error('WebRTC close, unregister error', e);
|
|
1336
1371
|
}
|
|
1337
1372
|
|
|
1338
1373
|
this.client.close(force);
|
|
1339
1374
|
this.unbind();
|
|
1340
|
-
|
|
1341
1375
|
this.incomingSessions = [];
|
|
1342
|
-
this.currentSipSession =
|
|
1376
|
+
this.currentSipSession = undefined;
|
|
1343
1377
|
this.currentCallSession = null;
|
|
1344
1378
|
this.shouldSendReinvite = false;
|
|
1345
1379
|
this.rejectedSessions = {};
|
|
@@ -1359,7 +1393,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1359
1393
|
this.ringingEnabled = false;
|
|
1360
1394
|
}
|
|
1361
1395
|
|
|
1362
|
-
getCurrentCallSession():
|
|
1396
|
+
getCurrentCallSession(): CallSession | null | undefined {
|
|
1363
1397
|
if (!this.currentSipSession) {
|
|
1364
1398
|
return null;
|
|
1365
1399
|
}
|
|
@@ -1371,13 +1405,14 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1371
1405
|
return this.incomingSessions.length > 0;
|
|
1372
1406
|
}
|
|
1373
1407
|
|
|
1374
|
-
getIncomingCallSession():
|
|
1408
|
+
getIncomingCallSession(): CallSession | null | undefined {
|
|
1375
1409
|
if (!this.hasIncomingCallSession()) {
|
|
1376
1410
|
return null;
|
|
1377
1411
|
}
|
|
1378
1412
|
|
|
1379
1413
|
const sessionId = this.incomingSessions[0];
|
|
1380
1414
|
const sipSession = this.client.getSipSession(sessionId);
|
|
1415
|
+
|
|
1381
1416
|
if (!sipSession) {
|
|
1382
1417
|
return null;
|
|
1383
1418
|
}
|
|
@@ -1385,41 +1420,42 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1385
1420
|
return this._createCallSession(sipSession);
|
|
1386
1421
|
}
|
|
1387
1422
|
|
|
1388
|
-
|
|
1423
|
+
// eslint-disable-next-line @typescript-eslint/default-param-last
|
|
1424
|
+
sendMessage(sipSession: Invitation | Inviter | null = null, body: string, contentType = 'text/plain'): void {
|
|
1389
1425
|
return this.client.sendMessage(sipSession, body, contentType);
|
|
1390
1426
|
}
|
|
1391
1427
|
|
|
1392
|
-
getLocalStream(callSession: CallSession):
|
|
1428
|
+
getLocalStream(callSession: CallSession): MediaStream | null | undefined {
|
|
1393
1429
|
return callSession ? this.client.getLocalStream(callSession.sipCallId) : null;
|
|
1394
1430
|
}
|
|
1395
1431
|
|
|
1396
|
-
getLocalVideoStream(callSession: CallSession):
|
|
1432
|
+
getLocalVideoStream(callSession: CallSession): MediaStream | null | undefined {
|
|
1397
1433
|
return callSession ? this.client.getLocalVideoStream(callSession.sipCallId) : null;
|
|
1398
1434
|
}
|
|
1399
1435
|
|
|
1400
1436
|
// Deprecated
|
|
1401
|
-
getLocalMediaStream(callSession: CallSession) {
|
|
1437
|
+
getLocalMediaStream(callSession: CallSession): MediaStream | null | undefined {
|
|
1402
1438
|
logger.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
1403
1439
|
return this.getLocalStream(callSession);
|
|
1404
1440
|
}
|
|
1405
1441
|
|
|
1406
|
-
hasLocalVideo(callSession: CallSession) {
|
|
1407
|
-
return callSession ? this.client.hasLocalVideo(callSession.sipCallId) :
|
|
1442
|
+
hasLocalVideo(callSession: CallSession): boolean {
|
|
1443
|
+
return callSession ? this.client.hasLocalVideo(callSession.sipCallId) : false;
|
|
1408
1444
|
}
|
|
1409
1445
|
|
|
1410
|
-
hasALocalVideoTrack(callSession: CallSession) {
|
|
1411
|
-
return callSession ? this.client.hasALocalVideoTrack(callSession.sipCallId) :
|
|
1446
|
+
hasALocalVideoTrack(callSession: CallSession): boolean {
|
|
1447
|
+
return callSession ? this.client.hasALocalVideoTrack(callSession.sipCallId) : false;
|
|
1412
1448
|
}
|
|
1413
1449
|
|
|
1414
|
-
getRemoteStream(callSession: CallSession):
|
|
1450
|
+
getRemoteStream(callSession: CallSession): MediaStream | null | undefined {
|
|
1415
1451
|
return callSession ? this.client.getRemoteStream(callSession.sipCallId) : null;
|
|
1416
1452
|
}
|
|
1417
1453
|
|
|
1418
|
-
getRemoteVideoStream(callSession: CallSession):
|
|
1454
|
+
getRemoteVideoStream(callSession: CallSession): MediaStream | null | undefined {
|
|
1419
1455
|
return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
|
|
1420
1456
|
}
|
|
1421
1457
|
|
|
1422
|
-
getRemoteVideoStreamFromPc(callSession: CallSession):
|
|
1458
|
+
getRemoteVideoStreamFromPc(callSession: CallSession): MediaStream | null | undefined {
|
|
1423
1459
|
return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
|
|
1424
1460
|
}
|
|
1425
1461
|
|
|
@@ -1427,24 +1463,29 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1427
1463
|
return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
|
|
1428
1464
|
}
|
|
1429
1465
|
|
|
1430
|
-
setMediaConstraints(media: MediaStreamConstraints) {
|
|
1466
|
+
setMediaConstraints(media: MediaStreamConstraints): void {
|
|
1431
1467
|
this.client.setMediaConstraints(media);
|
|
1432
1468
|
}
|
|
1433
1469
|
|
|
1434
|
-
isVideoRemotelyHeld(callSession: CallSession) {
|
|
1435
|
-
return callSession ? this.client.isVideoRemotelyHeld(callSession.sipCallId) :
|
|
1470
|
+
isVideoRemotelyHeld(callSession: CallSession): boolean {
|
|
1471
|
+
return callSession ? this.client.isVideoRemotelyHeld(callSession.sipCallId) : false;
|
|
1436
1472
|
}
|
|
1437
1473
|
|
|
1438
1474
|
bindClientEvents() {
|
|
1439
1475
|
this.client.unbind();
|
|
1440
|
-
|
|
1441
|
-
this.client.on(this.client.INVITE, (sipSession: Session, wantsToDoVideo: boolean) => {
|
|
1476
|
+
this.client.on(this.client.INVITE, (sipSession: Invitation | Inviter, wantsToDoVideo: boolean) => {
|
|
1442
1477
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
1443
1478
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
1444
|
-
logger.info('WebRTC invite received', {
|
|
1479
|
+
logger.info('WebRTC invite received', {
|
|
1480
|
+
sipId: sipSession.id,
|
|
1481
|
+
withVideo,
|
|
1482
|
+
autoAnswer,
|
|
1483
|
+
});
|
|
1445
1484
|
|
|
1446
1485
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
1486
|
+
|
|
1447
1487
|
this.incomingSessions.push(callSession.getId());
|
|
1488
|
+
|
|
1448
1489
|
this._bindEvents(sipSession);
|
|
1449
1490
|
|
|
1450
1491
|
this.client.storeSipSession(sipSession);
|
|
@@ -1454,18 +1495,15 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1454
1495
|
this.eventEmitter.emit(ON_PLAY_RING_SOUND, this.audioRingDeviceId, this.audioRingVolume, callSession);
|
|
1455
1496
|
}
|
|
1456
1497
|
} else {
|
|
1457
|
-
this.eventEmitter.emit(ON_PLAY_INBOUND_CALL_SIGNAL_SOUND,
|
|
1458
|
-
this.audioOutputDeviceId,
|
|
1459
|
-
this.audioOutputVolume,
|
|
1460
|
-
callSession);
|
|
1498
|
+
this.eventEmitter.emit(ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, this.audioOutputDeviceId, this.audioOutputVolume, callSession);
|
|
1461
1499
|
}
|
|
1462
1500
|
|
|
1463
1501
|
callSession.creationTime = new Date();
|
|
1502
|
+
|
|
1464
1503
|
this._updateCallSession(callSession);
|
|
1465
1504
|
|
|
1466
1505
|
this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
|
|
1467
1506
|
});
|
|
1468
|
-
|
|
1469
1507
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
1470
1508
|
logger.info('WebRTC on reinvite', {
|
|
1471
1509
|
sessionId: args[0].id,
|
|
@@ -1473,9 +1511,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1473
1511
|
updatedCalleeName: args[2],
|
|
1474
1512
|
updatedNumber: args[3],
|
|
1475
1513
|
});
|
|
1476
|
-
|
|
1477
1514
|
const sipSession = args[0];
|
|
1478
|
-
|
|
1479
1515
|
// Give some time for the stream to be mounted.
|
|
1480
1516
|
// if `_createCallSession` is called too soon `hasVideo` will return false because the stream doesn't exists yet
|
|
1481
1517
|
setTimeout(() => {
|
|
@@ -1485,15 +1521,18 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1485
1521
|
this.eventEmitter.emit.apply(this.eventEmitter, [this.client.ON_REINVITE, ...args]);
|
|
1486
1522
|
}, 2000);
|
|
1487
1523
|
});
|
|
1488
|
-
|
|
1489
|
-
this.client.on(this.client.ACCEPTED, (sipSession: Session) => {
|
|
1524
|
+
this.client.on(this.client.ACCEPTED, (sipSession: Inviter | Invitation) => {
|
|
1490
1525
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1491
|
-
const hasSession = sessionId in this.callSessions;
|
|
1492
|
-
|
|
1493
|
-
|
|
1526
|
+
const hasSession = (sessionId in this.callSessions);
|
|
1527
|
+
logger.info('WebRTC call accepted', {
|
|
1528
|
+
sipId: sessionId,
|
|
1529
|
+
hasSession,
|
|
1530
|
+
});
|
|
1494
1531
|
|
|
1495
1532
|
if (!hasSession) {
|
|
1496
|
-
logger.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', {
|
|
1533
|
+
logger.warn('Call accepted ignored, session is no longer present in the WebRtcPhone', {
|
|
1534
|
+
sessionId,
|
|
1535
|
+
});
|
|
1497
1536
|
return;
|
|
1498
1537
|
}
|
|
1499
1538
|
|
|
@@ -1504,36 +1543,36 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1504
1543
|
}
|
|
1505
1544
|
});
|
|
1506
1545
|
this.client.on('ended', () => {});
|
|
1507
|
-
|
|
1508
1546
|
this.client.on(this.client.ON_ERROR, e => {
|
|
1509
1547
|
logger.error('WebRTC error', e);
|
|
1510
1548
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
1511
1549
|
});
|
|
1512
|
-
|
|
1513
1550
|
this.client.on(this.client.REJECTED, session => {
|
|
1514
1551
|
logger.info('WebRTC call rejected', session.id);
|
|
1552
|
+
|
|
1515
1553
|
const callSession = this._createCallSession(session);
|
|
1554
|
+
|
|
1516
1555
|
callSession.endTime = new Date();
|
|
1556
|
+
|
|
1517
1557
|
this._updateCallSession(callSession);
|
|
1518
1558
|
|
|
1519
1559
|
this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
|
|
1520
1560
|
});
|
|
1521
|
-
|
|
1522
1561
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
1523
1562
|
logger.info('WebRTC unregistered');
|
|
1524
1563
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
1525
1564
|
});
|
|
1526
|
-
|
|
1527
1565
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
1528
1566
|
logger.info('WebRTC disconnected');
|
|
1529
1567
|
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
1530
1568
|
});
|
|
1531
1569
|
this.client.on(this.client.ON_EARLY_MEDIA, session => {
|
|
1532
1570
|
logger.info('WebRTC early media');
|
|
1571
|
+
|
|
1533
1572
|
const callSession = this._createCallSession(session);
|
|
1573
|
+
|
|
1534
1574
|
this.eventEmitter.emit(ON_EARLY_MEDIA, callSession);
|
|
1535
1575
|
});
|
|
1536
|
-
|
|
1537
1576
|
this.client.on(this.client.REGISTERED, () => {
|
|
1538
1577
|
logger.info('WebRTC registered', {
|
|
1539
1578
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
@@ -1545,31 +1584,30 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1545
1584
|
|
|
1546
1585
|
// If the phone registered with a current callSession (eg: when switching network):
|
|
1547
1586
|
// send a reinvite to renegociate ICE with new IP
|
|
1548
|
-
if (this.shouldSendReinvite && this.currentSipSession
|
|
1549
|
-
&& this.currentSipSession.state === SessionState.Established) {
|
|
1587
|
+
if (this.shouldSendReinvite && this.currentSipSession && this.currentSipSession.state === SessionState.Established) {
|
|
1550
1588
|
this.shouldSendReinvite = false;
|
|
1551
|
-
|
|
1589
|
+
// @ts-ignore
|
|
1590
|
+
const pc = this.currentSipSession?.sessionDescriptionHandler?.peerConnection;
|
|
1552
1591
|
const isConference = pc ? pc.sfu : false;
|
|
1553
1592
|
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
1554
1593
|
|
|
1555
1594
|
try {
|
|
1556
1595
|
// Send reinvite with iceRestart
|
|
1557
1596
|
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
1558
|
-
} catch (e) {
|
|
1559
|
-
logger.error('WebRTC reinvite after register, error', {
|
|
1597
|
+
} catch (e: any) {
|
|
1598
|
+
logger.error('WebRTC reinvite after register, error', {
|
|
1599
|
+
message: e.message,
|
|
1600
|
+
stack: e.stack,
|
|
1601
|
+
});
|
|
1560
1602
|
}
|
|
1561
1603
|
}
|
|
1562
1604
|
});
|
|
1563
|
-
|
|
1564
1605
|
this.client.on(this.client.CONNECTED, () => {
|
|
1565
1606
|
logger.info('WebRTC client connected');
|
|
1566
|
-
|
|
1567
1607
|
this.stopHeartbeat();
|
|
1568
1608
|
});
|
|
1569
|
-
|
|
1570
1609
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
1571
1610
|
logger.info('WebRTC client disconnected');
|
|
1572
|
-
|
|
1573
1611
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
1574
1612
|
|
|
1575
1613
|
// Do not trigger heartbeat if already running
|
|
@@ -1580,71 +1618,62 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1580
1618
|
// Tell to send reinvite when reconnecting
|
|
1581
1619
|
this.shouldSendReinvite = true;
|
|
1582
1620
|
});
|
|
1583
|
-
|
|
1584
1621
|
this.client.on(this.client.ON_TRACK, (session, event) => {
|
|
1585
1622
|
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
1586
1623
|
});
|
|
1587
|
-
|
|
1588
1624
|
this.client.on('onVideoInputChange', stream => {
|
|
1589
1625
|
this.eventEmitter.emit(ON_VIDEO_INPUT_CHANGE, stream);
|
|
1590
1626
|
});
|
|
1591
|
-
|
|
1592
1627
|
this.client.on(this.client.MESSAGE, (message: Message) => {
|
|
1593
1628
|
this._onMessage(message);
|
|
1629
|
+
|
|
1594
1630
|
this.eventEmitter.emit(ON_MESSAGE, message);
|
|
1595
1631
|
});
|
|
1596
|
-
|
|
1597
1632
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
1598
1633
|
const callSession = this.getCallSession(this.getSipSessionId(session));
|
|
1599
|
-
|
|
1600
1634
|
this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
1601
1635
|
});
|
|
1602
|
-
|
|
1603
1636
|
// Used when upgrading directly in screenshare mode
|
|
1604
|
-
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession:
|
|
1637
|
+
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession: Inviter | Invitation, response: any, desktop: boolean) => {
|
|
1605
1638
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
1606
1639
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
1607
1640
|
const callSession = this.callSessions[sipSessionId];
|
|
1608
|
-
|
|
1609
1641
|
logger.info('Updrading directly in screensharing mode', {
|
|
1610
1642
|
sipSessionId,
|
|
1611
|
-
tracks: localStream
|
|
1643
|
+
tracks: localStream?.getTracks() || null,
|
|
1612
1644
|
});
|
|
1613
1645
|
|
|
1614
|
-
this._onScreenSharing(localStream, sipSession, callSession, false, desktop);
|
|
1646
|
+
this._onScreenSharing(localStream as MediaStream, sipSession, callSession, false, desktop);
|
|
1615
1647
|
});
|
|
1616
1648
|
}
|
|
1617
1649
|
|
|
1618
1650
|
// Find a corresponding sipSession from a CallSession
|
|
1619
|
-
findSipSession(callSession:
|
|
1651
|
+
findSipSession(callSession: CallSession | null | undefined): Invitation | Inviter | null | undefined {
|
|
1620
1652
|
const keys = this.client.getSipSessionIds();
|
|
1621
1653
|
const keyIndex = keys.findIndex(sessionId => callSession && callSession.isId(sessionId));
|
|
1622
1654
|
|
|
1623
1655
|
if (keyIndex === -1) {
|
|
1624
|
-
const currentSipSessionId = this.currentSipSession
|
|
1625
|
-
? this.getSipSessionId(this.currentSipSession)
|
|
1626
|
-
: this.client.getSipSessionIds()[0];
|
|
1656
|
+
const currentSipSessionId = this.currentSipSession ? this.getSipSessionId(this.currentSipSession) : this.client.getSipSessionIds()[0];
|
|
1627
1657
|
return currentSipSessionId ? this.client.getSipSession(currentSipSessionId) : null;
|
|
1628
1658
|
}
|
|
1629
1659
|
|
|
1630
1660
|
return this.client.getSipSession(keys[keyIndex]);
|
|
1631
1661
|
}
|
|
1632
1662
|
|
|
1633
|
-
getCallSession(sipSessionId: string):
|
|
1663
|
+
getCallSession(sipSessionId: string): CallSession | null | undefined {
|
|
1634
1664
|
return this.callSessions[sipSessionId];
|
|
1635
1665
|
}
|
|
1636
1666
|
|
|
1637
|
-
getSipSessionId(sipSession:
|
|
1667
|
+
getSipSessionId(sipSession: Inviter | Invitation): string {
|
|
1638
1668
|
return this.client.getSipSessionId(sipSession);
|
|
1639
1669
|
}
|
|
1640
1670
|
|
|
1641
|
-
getSipSessionIdFromCallSession(callSession: CallSession) {
|
|
1671
|
+
getSipSessionIdFromCallSession(callSession: CallSession): string | null {
|
|
1642
1672
|
const sipSession = this.findSipSession(callSession);
|
|
1643
|
-
|
|
1644
1673
|
return sipSession ? this.getSipSessionId(sipSession) : null;
|
|
1645
1674
|
}
|
|
1646
1675
|
|
|
1647
|
-
_updateCallSession(callSession: CallSession) {
|
|
1676
|
+
_updateCallSession(callSession: CallSession): void {
|
|
1648
1677
|
const sipSessionId = this.getSipSessionIdFromCallSession(callSession);
|
|
1649
1678
|
|
|
1650
1679
|
if (sipSessionId) {
|
|
@@ -1652,7 +1681,8 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1652
1681
|
}
|
|
1653
1682
|
}
|
|
1654
1683
|
|
|
1655
|
-
_onMessage(message: Message) {
|
|
1684
|
+
_onMessage(message: Message): void {
|
|
1685
|
+
// @ts-ignore
|
|
1656
1686
|
if (!message || message.method !== 'MESSAGE') {
|
|
1657
1687
|
return;
|
|
1658
1688
|
}
|
|
@@ -1660,19 +1690,24 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1660
1690
|
let body;
|
|
1661
1691
|
|
|
1662
1692
|
try {
|
|
1693
|
+
// @ts-ignore
|
|
1663
1694
|
body = JSON.parse(message.body);
|
|
1664
|
-
} catch (e) {
|
|
1695
|
+
} catch (e: any) {
|
|
1665
1696
|
return;
|
|
1666
1697
|
}
|
|
1667
1698
|
|
|
1668
|
-
const {
|
|
1699
|
+
const {
|
|
1700
|
+
type,
|
|
1701
|
+
content,
|
|
1702
|
+
} = body;
|
|
1669
1703
|
|
|
1670
1704
|
switch (type) {
|
|
1671
1705
|
case MESSAGE_TYPE_CHAT:
|
|
1672
1706
|
this.eventEmitter.emit(ON_CHAT, content);
|
|
1673
1707
|
break;
|
|
1674
1708
|
|
|
1675
|
-
case MESSAGE_TYPE_SIGNAL:
|
|
1709
|
+
case MESSAGE_TYPE_SIGNAL:
|
|
1710
|
+
{
|
|
1676
1711
|
this.eventEmitter.emit(ON_SIGNAL, content);
|
|
1677
1712
|
break;
|
|
1678
1713
|
}
|
|
@@ -1681,12 +1716,7 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1681
1716
|
}
|
|
1682
1717
|
}
|
|
1683
1718
|
|
|
1684
|
-
_createIncomingCallSession(
|
|
1685
|
-
sipSession: Session,
|
|
1686
|
-
cameraEnabled: boolean,
|
|
1687
|
-
fromSession?: ?CallSession,
|
|
1688
|
-
autoAnswer: boolean = false,
|
|
1689
|
-
): CallSession {
|
|
1719
|
+
_createIncomingCallSession(sipSession: Invitation | Inviter, cameraEnabled: boolean, fromSession?: CallSession | null | undefined, autoAnswer = false): CallSession {
|
|
1690
1720
|
return this._createCallSession(sipSession, fromSession, {
|
|
1691
1721
|
incoming: true,
|
|
1692
1722
|
ringing: true,
|
|
@@ -1695,82 +1725,80 @@ export default class WebRTCPhone extends Emitter implements Phone {
|
|
|
1695
1725
|
});
|
|
1696
1726
|
}
|
|
1697
1727
|
|
|
1698
|
-
_createOutgoingCallSession(
|
|
1699
|
-
sipSession
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1728
|
+
_createOutgoingCallSession(sipSession: Invitation | Inviter, cameraEnabled: boolean, fromSession?: CallSession): CallSession {
|
|
1729
|
+
return this._createCallSession(sipSession, fromSession, {
|
|
1730
|
+
incoming: false,
|
|
1731
|
+
ringing: true,
|
|
1732
|
+
cameraEnabled,
|
|
1733
|
+
});
|
|
1704
1734
|
}
|
|
1705
1735
|
|
|
1706
|
-
_createAcceptedCallSession(
|
|
1707
|
-
sipSession: Session,
|
|
1708
|
-
cameraEnabled?: boolean,
|
|
1709
|
-
fromSession?: CallSession,
|
|
1710
|
-
): CallSession {
|
|
1736
|
+
_createAcceptedCallSession(sipSession: Invitation | Inviter, cameraEnabled?: boolean, fromSession?: CallSession): CallSession {
|
|
1711
1737
|
return this._createCallSession(sipSession, fromSession, {
|
|
1712
1738
|
cameraEnabled: cameraEnabled !== undefined ? cameraEnabled : false,
|
|
1713
1739
|
});
|
|
1714
1740
|
}
|
|
1715
1741
|
|
|
1716
|
-
_createMutedCallSession(sipSession:
|
|
1742
|
+
_createMutedCallSession(sipSession: Invitation | Inviter, fromSession?: CallSession): CallSession {
|
|
1717
1743
|
return this._createCallSession(sipSession, fromSession, {
|
|
1718
1744
|
muted: true,
|
|
1719
1745
|
});
|
|
1720
1746
|
}
|
|
1721
1747
|
|
|
1722
|
-
_createUnmutedCallSession(sipSession:
|
|
1748
|
+
_createUnmutedCallSession(sipSession: Invitation | Inviter, fromSession?: CallSession): CallSession {
|
|
1723
1749
|
return this._createCallSession(sipSession, fromSession, {
|
|
1724
1750
|
muted: false,
|
|
1725
1751
|
});
|
|
1726
1752
|
}
|
|
1727
1753
|
|
|
1728
|
-
_createCameraResumedCallSession(sipSession:
|
|
1754
|
+
_createCameraResumedCallSession(sipSession: Invitation | Inviter, fromSession?: CallSession): CallSession {
|
|
1729
1755
|
return this._createCallSession(sipSession, fromSession, {
|
|
1730
1756
|
videoMuted: false,
|
|
1731
1757
|
});
|
|
1732
1758
|
}
|
|
1733
1759
|
|
|
1734
|
-
_createCameraDisabledCallSession(sipSession:
|
|
1760
|
+
_createCameraDisabledCallSession(sipSession: Invitation | Inviter, fromSession?: CallSession): CallSession {
|
|
1735
1761
|
return this._createCallSession(sipSession, fromSession, {
|
|
1736
1762
|
videoMuted: true,
|
|
1737
1763
|
});
|
|
1738
1764
|
}
|
|
1739
1765
|
|
|
1740
|
-
_createCallSession(sipSession:
|
|
1766
|
+
_createCallSession(sipSession: Invitation | Inviter, fromSession?: CallSession | null | undefined, extra: Record<string, any> = {}): CallSession {
|
|
1741
1767
|
// eslint-disable-next-line
|
|
1742
1768
|
const identity = sipSession ? sipSession.remoteIdentity || sipSession.assertedIdentity : null;
|
|
1769
|
+
// @ts-ignore
|
|
1743
1770
|
const number = identity ? identity.uri._normal.user : null;
|
|
1744
|
-
const {
|
|
1771
|
+
const {
|
|
1772
|
+
state,
|
|
1773
|
+
} = sipSession || {};
|
|
1745
1774
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1746
1775
|
fromSession = fromSession || this.callSessions[sessionId];
|
|
1747
|
-
|
|
1748
1776
|
const callSession = new CallSession({
|
|
1749
1777
|
callId: fromSession && fromSession.callId,
|
|
1750
1778
|
sipCallId: sessionId,
|
|
1751
1779
|
sipStatus: state,
|
|
1752
1780
|
displayName: identity ? identity.displayName || number : number,
|
|
1781
|
+
// @ts-ignore: @HEADSUP: startTime should be a number, not a date
|
|
1753
1782
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
1754
1783
|
creationTime: fromSession ? fromSession.creationTime : null,
|
|
1755
1784
|
answerTime: fromSession ? fromSession.answerTime : null,
|
|
1756
1785
|
endTime: fromSession ? fromSession.endTime : null,
|
|
1757
1786
|
answered: state === SessionState.Established,
|
|
1758
1787
|
paused: this.client.isCallHeld(sipSession),
|
|
1759
|
-
isCaller: fromSession ? fromSession.isCaller :
|
|
1788
|
+
isCaller: fromSession ? fromSession.isCaller : 'incoming' in extra ? !extra.incoming : false,
|
|
1760
1789
|
cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId),
|
|
1761
1790
|
number,
|
|
1762
1791
|
ringing: false,
|
|
1763
1792
|
muted: fromSession ? fromSession.isMuted() : this.client.isAudioMuted(sipSession),
|
|
1764
1793
|
videoMuted: fromSession ? fromSession.isVideoMuted() : false,
|
|
1765
1794
|
recording: fromSession ? fromSession.isRecording() : false,
|
|
1766
|
-
recordingPaused: false,
|
|
1795
|
+
recordingPaused: false,
|
|
1767
1796
|
sipSession,
|
|
1768
1797
|
conference: !!fromSession && fromSession.isConference(),
|
|
1769
1798
|
...extra,
|
|
1770
1799
|
});
|
|
1771
|
-
|
|
1772
1800
|
this.callSessions[callSession.getId()] = callSession;
|
|
1773
|
-
|
|
1774
1801
|
return callSession;
|
|
1775
1802
|
}
|
|
1803
|
+
|
|
1776
1804
|
}
|