voice-react-native-sdk 1.6.2-fork.4
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/LICENSE +206 -0
- package/README.md +179 -0
- package/android/build.gradle +113 -0
- package/android/gradle.properties +29 -0
- package/android/src/main/AndroidManifest.xml +30 -0
- package/android/src/main/java/com/twiliovoicereactnative/AudioSwitchManager.java +141 -0
- package/android/src/main/java/com/twiliovoicereactnative/CallListenerProxy.java +186 -0
- package/android/src/main/java/com/twiliovoicereactnative/CallMessageListenerProxy.java +103 -0
- package/android/src/main/java/com/twiliovoicereactnative/CallRecordDatabase.java +183 -0
- package/android/src/main/java/com/twiliovoicereactnative/CommonConstants.java +195 -0
- package/android/src/main/java/com/twiliovoicereactnative/ConfigurationProperties.java +41 -0
- package/android/src/main/java/com/twiliovoicereactnative/Constants.java +23 -0
- package/android/src/main/java/com/twiliovoicereactnative/ExpoActivityLifecycleListener.java +27 -0
- package/android/src/main/java/com/twiliovoicereactnative/ExpoApplicationLifecycleListener.java +14 -0
- package/android/src/main/java/com/twiliovoicereactnative/ExpoModule.kt +36 -0
- package/android/src/main/java/com/twiliovoicereactnative/ExpoPackage.java +20 -0
- package/android/src/main/java/com/twiliovoicereactnative/JSEventEmitter.java +98 -0
- package/android/src/main/java/com/twiliovoicereactnative/MediaPlayerManager.java +58 -0
- package/android/src/main/java/com/twiliovoicereactnative/NotificationUtility.java +363 -0
- package/android/src/main/java/com/twiliovoicereactnative/ReactNativeArgumentsSerializer.java +276 -0
- package/android/src/main/java/com/twiliovoicereactnative/SDKLog.java +74 -0
- package/android/src/main/java/com/twiliovoicereactnative/StatsListenerProxy.java +178 -0
- package/android/src/main/java/com/twiliovoicereactnative/TwilioVoiceReactNativeModule.java +778 -0
- package/android/src/main/java/com/twiliovoicereactnative/TwilioVoiceReactNativePackage.java +28 -0
- package/android/src/main/java/com/twiliovoicereactnative/VoiceActivityProxy.java +101 -0
- package/android/src/main/java/com/twiliovoicereactnative/VoiceApplicationProxy.java +133 -0
- package/android/src/main/java/com/twiliovoicereactnative/VoiceFirebaseMessagingService.java +88 -0
- package/android/src/main/java/com/twiliovoicereactnative/VoiceService.java +403 -0
- package/android/src/main/res/drawable/answered_call_small_icon.png +0 -0
- package/android/src/main/res/drawable/ic_launcher_round.png +0 -0
- package/android/src/main/res/drawable/ic_launcher_sdk.png +0 -0
- package/android/src/main/res/drawable/incoming_call_small_icon.png +0 -0
- package/android/src/main/res/drawable/outgoing_call_small_icon.png +0 -0
- package/android/src/main/res/raw/disconnect.wav +0 -0
- package/android/src/main/res/raw/incoming.wav +0 -0
- package/android/src/main/res/raw/outgoing.wav +0 -0
- package/android/src/main/res/raw/ringtone.wav +0 -0
- package/android/src/main/res/raw/silent.wav +0 -0
- package/android/src/main/res/values/colors.xml +11 -0
- package/android/src/main/res/values/config.xml +5 -0
- package/android/src/main/res/values/dimens.xml +7 -0
- package/android/src/main/res/values/strings.xml +25 -0
- package/android/src/main/res/values/styles.xml +10 -0
- package/android/src/main/res/values-night/colors.xml +11 -0
- package/expo-config-plugin/android.js +191 -0
- package/expo-config-plugin/ios.js +22 -0
- package/expo-module.config.json +6 -0
- package/ios/TwilioVoicePushRegistry.h +19 -0
- package/ios/TwilioVoicePushRegistry.m +72 -0
- package/ios/TwilioVoiceReactNative+CallInvite.m +56 -0
- package/ios/TwilioVoiceReactNative+CallKit.m +533 -0
- package/ios/TwilioVoiceReactNative+CallMessage.m +81 -0
- package/ios/TwilioVoiceReactNative.h +74 -0
- package/ios/TwilioVoiceReactNative.m +1046 -0
- package/ios/TwilioVoiceReactNative.xcodeproj/project.pbxproj +328 -0
- package/ios/TwilioVoiceReactNativeConstants.h +200 -0
- package/ios/Utilities/TwilioVoiceStatsReport.h +175 -0
- package/lib/commonjs/AudioDevice.js +101 -0
- package/lib/commonjs/AudioDevice.js.map +1 -0
- package/lib/commonjs/Call.js +765 -0
- package/lib/commonjs/Call.js.map +1 -0
- package/lib/commonjs/CallInvite.js +452 -0
- package/lib/commonjs/CallInvite.js.map +1 -0
- package/lib/commonjs/CallMessage/CallMessage.js +54 -0
- package/lib/commonjs/CallMessage/CallMessage.js.map +1 -0
- package/lib/commonjs/CallMessage/IncomingCallMessage.js +120 -0
- package/lib/commonjs/CallMessage/IncomingCallMessage.js.map +1 -0
- package/lib/commonjs/CallMessage/OutgoingCallMessage.js +148 -0
- package/lib/commonjs/CallMessage/OutgoingCallMessage.js.map +1 -0
- package/lib/commonjs/ExpoModule.js +69 -0
- package/lib/commonjs/ExpoModule.js.map +1 -0
- package/lib/commonjs/Voice.js +611 -0
- package/lib/commonjs/Voice.js.map +1 -0
- package/lib/commonjs/common.js +26 -0
- package/lib/commonjs/common.js.map +1 -0
- package/lib/commonjs/constants.js +158 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/error/InvalidArgumentError.js +32 -0
- package/lib/commonjs/error/InvalidArgumentError.js.map +1 -0
- package/lib/commonjs/error/InvalidStateError.js +33 -0
- package/lib/commonjs/error/InvalidStateError.js.map +1 -0
- package/lib/commonjs/error/TwilioError.js +38 -0
- package/lib/commonjs/error/TwilioError.js.map +1 -0
- package/lib/commonjs/error/UnsupportedPlatformError.js +33 -0
- package/lib/commonjs/error/UnsupportedPlatformError.js.map +1 -0
- package/lib/commonjs/error/generated.js +2343 -0
- package/lib/commonjs/error/generated.js.map +1 -0
- package/lib/commonjs/error/index.js +112 -0
- package/lib/commonjs/error/index.js.map +1 -0
- package/lib/commonjs/error/utility.js +37 -0
- package/lib/commonjs/error/utility.js.map +1 -0
- package/lib/commonjs/index.js +95 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/type/AudioDevice.js +6 -0
- package/lib/commonjs/type/AudioDevice.js.map +1 -0
- package/lib/commonjs/type/Call.js +6 -0
- package/lib/commonjs/type/Call.js.map +1 -0
- package/lib/commonjs/type/CallInvite.js +6 -0
- package/lib/commonjs/type/CallInvite.js.map +1 -0
- package/lib/commonjs/type/CallKit.js +30 -0
- package/lib/commonjs/type/CallKit.js.map +1 -0
- package/lib/commonjs/type/CallMessage.js +6 -0
- package/lib/commonjs/type/CallMessage.js.map +1 -0
- package/lib/commonjs/type/Error.js +6 -0
- package/lib/commonjs/type/Error.js.map +1 -0
- package/lib/commonjs/type/NativeModule.js +6 -0
- package/lib/commonjs/type/NativeModule.js.map +1 -0
- package/lib/commonjs/type/RTCStats.js +29 -0
- package/lib/commonjs/type/RTCStats.js.map +1 -0
- package/lib/commonjs/type/Voice.js +6 -0
- package/lib/commonjs/type/Voice.js.map +1 -0
- package/lib/commonjs/type/common.js +2 -0
- package/lib/commonjs/type/common.js.map +1 -0
- package/lib/module/AudioDevice.js +97 -0
- package/lib/module/AudioDevice.js.map +1 -0
- package/lib/module/Call.js +766 -0
- package/lib/module/Call.js.map +1 -0
- package/lib/module/CallInvite.js +450 -0
- package/lib/module/CallInvite.js.map +1 -0
- package/lib/module/CallMessage/CallMessage.js +51 -0
- package/lib/module/CallMessage/CallMessage.js.map +1 -0
- package/lib/module/CallMessage/IncomingCallMessage.js +116 -0
- package/lib/module/CallMessage/IncomingCallMessage.js.map +1 -0
- package/lib/module/CallMessage/OutgoingCallMessage.js +154 -0
- package/lib/module/CallMessage/OutgoingCallMessage.js.map +1 -0
- package/lib/module/ExpoModule.js +58 -0
- package/lib/module/ExpoModule.js.map +1 -0
- package/lib/module/Voice.js +598 -0
- package/lib/module/Voice.js.map +1 -0
- package/lib/module/common.js +11 -0
- package/lib/module/common.js.map +1 -0
- package/lib/module/constants.js +151 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/error/InvalidArgumentError.js +23 -0
- package/lib/module/error/InvalidArgumentError.js.map +1 -0
- package/lib/module/error/InvalidStateError.js +24 -0
- package/lib/module/error/InvalidStateError.js.map +1 -0
- package/lib/module/error/TwilioError.js +29 -0
- package/lib/module/error/TwilioError.js.map +1 -0
- package/lib/module/error/UnsupportedPlatformError.js +24 -0
- package/lib/module/error/UnsupportedPlatformError.js.map +1 -0
- package/lib/module/error/generated.js +2315 -0
- package/lib/module/error/generated.js.map +1 -0
- package/lib/module/error/index.js +6 -0
- package/lib/module/error/index.js.map +1 -0
- package/lib/module/error/utility.js +27 -0
- package/lib/module/error/utility.js.map +1 -0
- package/lib/module/index.js +23 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/type/AudioDevice.js +2 -0
- package/lib/module/type/AudioDevice.js.map +1 -0
- package/lib/module/type/Call.js +2 -0
- package/lib/module/type/Call.js.map +1 -0
- package/lib/module/type/CallInvite.js +2 -0
- package/lib/module/type/CallInvite.js.map +1 -0
- package/lib/module/type/CallKit.js +22 -0
- package/lib/module/type/CallKit.js.map +1 -0
- package/lib/module/type/CallMessage.js +2 -0
- package/lib/module/type/CallMessage.js.map +1 -0
- package/lib/module/type/Error.js +2 -0
- package/lib/module/type/Error.js.map +1 -0
- package/lib/module/type/NativeModule.js +2 -0
- package/lib/module/type/NativeModule.js.map +1 -0
- package/lib/module/type/RTCStats.js +21 -0
- package/lib/module/type/RTCStats.js.map +1 -0
- package/lib/module/type/Voice.js +2 -0
- package/lib/module/type/Voice.js.map +1 -0
- package/lib/module/type/common.js +2 -0
- package/lib/module/type/common.js.map +1 -0
- package/lib/typescript/AudioDevice.d.ts +74 -0
- package/lib/typescript/Call.d.ts +874 -0
- package/lib/typescript/CallInvite.d.ts +484 -0
- package/lib/typescript/CallMessage/CallMessage.d.ts +53 -0
- package/lib/typescript/CallMessage/IncomingCallMessage.d.ts +75 -0
- package/lib/typescript/CallMessage/OutgoingCallMessage.d.ts +198 -0
- package/lib/typescript/ExpoModule.d.ts +13 -0
- package/lib/typescript/Voice.d.ts +620 -0
- package/lib/typescript/common.d.ts +11 -0
- package/lib/typescript/constants.d.ts +148 -0
- package/lib/typescript/error/InvalidArgumentError.d.ts +11 -0
- package/lib/typescript/error/InvalidStateError.d.ts +12 -0
- package/lib/typescript/error/TwilioError.d.ts +14 -0
- package/lib/typescript/error/UnsupportedPlatformError.d.ts +12 -0
- package/lib/typescript/error/generated.d.ts +1558 -0
- package/lib/typescript/error/index.d.ts +5 -0
- package/lib/typescript/error/utility.d.ts +12 -0
- package/lib/typescript/index.d.ts +18 -0
- package/lib/typescript/type/AudioDevice.d.ts +15 -0
- package/lib/typescript/type/Call.d.ts +59 -0
- package/lib/typescript/type/CallInvite.d.ts +40 -0
- package/lib/typescript/type/CallKit.d.ts +60 -0
- package/lib/typescript/type/CallMessage.d.ts +20 -0
- package/lib/typescript/type/Error.d.ts +9 -0
- package/lib/typescript/type/NativeModule.d.ts +59 -0
- package/lib/typescript/type/RTCStats.d.ts +91 -0
- package/lib/typescript/type/Voice.d.ts +16 -0
- package/lib/typescript/type/common.d.ts +15 -0
- package/package.json +167 -0
- package/src/AudioDevice.tsx +88 -0
- package/src/Call.tsx +1343 -0
- package/src/CallInvite.tsx +757 -0
- package/src/CallMessage/CallMessage.ts +83 -0
- package/src/CallMessage/IncomingCallMessage.ts +104 -0
- package/src/CallMessage/OutgoingCallMessage.ts +308 -0
- package/src/ExpoModule.ts +59 -0
- package/src/Voice.tsx +1010 -0
- package/src/common.ts +16 -0
- package/src/constants.ts +193 -0
- package/src/error/InvalidArgumentError.ts +19 -0
- package/src/error/InvalidStateError.ts +19 -0
- package/src/error/TwilioError.ts +22 -0
- package/src/error/UnsupportedPlatformError.ts +19 -0
- package/src/error/generated.ts +2277 -0
- package/src/error/index.ts +18 -0
- package/src/error/utility.ts +36 -0
- package/src/index.tsx +24 -0
- package/src/type/AudioDevice.ts +18 -0
- package/src/type/Call.ts +102 -0
- package/src/type/CallInvite.ts +59 -0
- package/src/type/CallKit.ts +61 -0
- package/src/type/CallMessage.ts +31 -0
- package/src/type/Error.ts +11 -0
- package/src/type/NativeModule.ts +93 -0
- package/src/type/RTCStats.ts +99 -0
- package/src/type/Voice.ts +31 -0
- package/src/type/common.ts +16 -0
- package/twilio-voice-react-native.podspec +22 -0
|
@@ -0,0 +1,766 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright © 2022 Twilio, Inc. All rights reserved. Licensed under the Twilio
|
|
5
|
+
* license.
|
|
6
|
+
*
|
|
7
|
+
* See LICENSE in the project root for license information.
|
|
8
|
+
*/
|
|
9
|
+
import { EventEmitter } from 'eventemitter3';
|
|
10
|
+
import { NativeModule, NativeEventEmitter } from './common';
|
|
11
|
+
import { Constants } from './constants';
|
|
12
|
+
import { InvalidArgumentError } from './error/InvalidArgumentError';
|
|
13
|
+
import { constructTwilioError } from './error/utility';
|
|
14
|
+
import { validateCallMessage } from './CallMessage/CallMessage';
|
|
15
|
+
import { IncomingCallMessage } from './CallMessage/IncomingCallMessage';
|
|
16
|
+
import { OutgoingCallMessage } from './CallMessage/OutgoingCallMessage';
|
|
17
|
+
/**
|
|
18
|
+
* Defines strict typings for all events emitted by {@link (Call:class)
|
|
19
|
+
* | Call objects}.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Note that the `on` function is an alias for the `addListener` function.
|
|
23
|
+
* They share identical functionality and either may be used interchangeably.
|
|
24
|
+
*
|
|
25
|
+
* - See also the {@link (Call:class) | Call class}.
|
|
26
|
+
* - See also the {@link (Call:namespace) | Call namespace}.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Provides access to information about a call, including the call parameters,
|
|
33
|
+
* and exposes functionality for a call such as disconnecting, muting, and
|
|
34
|
+
* holding.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Note that the call information is fetched as soon as possible from the native
|
|
38
|
+
* layer, but there is no guarantee that all information is immediately
|
|
39
|
+
* available. Methods such as `Call.getFrom()` or `Call.getTo()` may return
|
|
40
|
+
* `undefined`.
|
|
41
|
+
*
|
|
42
|
+
* As call events are received from the native layer, call information will
|
|
43
|
+
* propagate from the native layer to the JS layer and become available.
|
|
44
|
+
* Therefore, it is good practice to read information from the call after an
|
|
45
|
+
* event occurs, or as events occur.
|
|
46
|
+
*
|
|
47
|
+
* - See the {@link (Call:namespace).Event} enum for events emitted by `Call`
|
|
48
|
+
* objects.
|
|
49
|
+
* - See the {@link (Call:interface) | Call interface} for overloaded event
|
|
50
|
+
* listening methods.
|
|
51
|
+
* - See the {@link (Call:namespace) | Call namespace} for types and
|
|
52
|
+
* enumerations used by this class.
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export class Call extends EventEmitter {
|
|
57
|
+
/**
|
|
58
|
+
* The `Uuid` of this call. Used to identify calls between the JS and native
|
|
59
|
+
* layer so we can associate events and native functionality between the
|
|
60
|
+
* layers.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Call custom parameters.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Call `from` parameter.
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Initial `connected` timestamp. Milliseconds since epoch.
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A boolean representing if the call is currently muted.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A boolean representing if the call is currently on hold.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A string representing the SID of this call.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The current state of the call.
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* See {@link (Call:namespace).State}.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Call `to` parameter.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Handlers for native call events. Set upon construction so we can
|
|
100
|
+
* dynamically bind events to handlers.
|
|
101
|
+
*
|
|
102
|
+
* @privateRemarks
|
|
103
|
+
* This is done by the constructor so this mapping isn't made every time the
|
|
104
|
+
* {@link (Call:class)._handleNativeEvent} function is invoked.
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Constructor for the {@link (Call:class) | Call class}. This should not be
|
|
109
|
+
* invoked by third-party code. All instances of the
|
|
110
|
+
* {@link (Call:class) | Call class} should be made by the SDK and emitted by
|
|
111
|
+
* {@link (Voice:class) | Voice objects}.
|
|
112
|
+
*
|
|
113
|
+
* @param nativeCallInfo - An object containing all of the data from the
|
|
114
|
+
* native layer necessary to fully describe a call, as well as invoke native
|
|
115
|
+
* functionality for the call.
|
|
116
|
+
*
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
constructor({
|
|
120
|
+
uuid,
|
|
121
|
+
customParameters,
|
|
122
|
+
from,
|
|
123
|
+
sid,
|
|
124
|
+
state,
|
|
125
|
+
to,
|
|
126
|
+
isMuted,
|
|
127
|
+
isOnHold,
|
|
128
|
+
initialConnectedTimestamp
|
|
129
|
+
}) {
|
|
130
|
+
super();
|
|
131
|
+
|
|
132
|
+
_defineProperty(this, "_uuid", void 0);
|
|
133
|
+
|
|
134
|
+
_defineProperty(this, "_customParameters", void 0);
|
|
135
|
+
|
|
136
|
+
_defineProperty(this, "_from", void 0);
|
|
137
|
+
|
|
138
|
+
_defineProperty(this, "_initialConnectedTimestamp", void 0);
|
|
139
|
+
|
|
140
|
+
_defineProperty(this, "_isMuted", void 0);
|
|
141
|
+
|
|
142
|
+
_defineProperty(this, "_isOnHold", void 0);
|
|
143
|
+
|
|
144
|
+
_defineProperty(this, "_sid", void 0);
|
|
145
|
+
|
|
146
|
+
_defineProperty(this, "_state", void 0);
|
|
147
|
+
|
|
148
|
+
_defineProperty(this, "_to", void 0);
|
|
149
|
+
|
|
150
|
+
_defineProperty(this, "_nativeEventHandler", void 0);
|
|
151
|
+
|
|
152
|
+
_defineProperty(this, "_handleNativeEvent", nativeCallEvent => {
|
|
153
|
+
const {
|
|
154
|
+
type,
|
|
155
|
+
call: callInfo
|
|
156
|
+
} = nativeCallEvent;
|
|
157
|
+
const handler = this._nativeEventHandler[type];
|
|
158
|
+
|
|
159
|
+
if (typeof handler === 'undefined') {
|
|
160
|
+
throw new Error(`Unknown call event type received from the native layer: "${type}".`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (callInfo.uuid === this._uuid) {
|
|
164
|
+
handler(nativeCallEvent);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
_defineProperty(this, "_handleConnectedEvent", nativeCallEvent => {
|
|
169
|
+
if (nativeCallEvent.type !== Constants.CallEventConnected) {
|
|
170
|
+
throw new Error('Incorrect "call#connected" handler called for type ' + `"${nativeCallEvent.type}".`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
this._update(nativeCallEvent);
|
|
174
|
+
|
|
175
|
+
this.emit(Call.Event.Connected);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
_defineProperty(this, "_handleConnectFailureEvent", nativeCallEvent => {
|
|
179
|
+
if (nativeCallEvent.type !== Constants.CallEventConnectFailure) {
|
|
180
|
+
throw new Error('Incorrect "call#connectFailure" handler called for type ' + `"${nativeCallEvent.type}".`);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
this._update(nativeCallEvent);
|
|
184
|
+
|
|
185
|
+
const {
|
|
186
|
+
message,
|
|
187
|
+
code
|
|
188
|
+
} = nativeCallEvent.error;
|
|
189
|
+
const error = constructTwilioError(message, code);
|
|
190
|
+
this.emit(Call.Event.ConnectFailure, error);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
_defineProperty(this, "_handleDisconnectedEvent", nativeCallEvent => {
|
|
194
|
+
if (nativeCallEvent.type !== Constants.CallEventDisconnected) {
|
|
195
|
+
throw new Error('Incorrect "call#disconnected" handler called for type ' + `"${nativeCallEvent.type}".`);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
this._update(nativeCallEvent);
|
|
199
|
+
|
|
200
|
+
if (nativeCallEvent.error) {
|
|
201
|
+
const {
|
|
202
|
+
message,
|
|
203
|
+
code
|
|
204
|
+
} = nativeCallEvent.error;
|
|
205
|
+
const error = constructTwilioError(message, code);
|
|
206
|
+
this.emit(Call.Event.Disconnected, error);
|
|
207
|
+
} else {
|
|
208
|
+
this.emit(Call.Event.Disconnected);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
_defineProperty(this, "_handleReconnectingEvent", nativeCallEvent => {
|
|
213
|
+
if (nativeCallEvent.type !== Constants.CallEventReconnecting) {
|
|
214
|
+
throw new Error('Incorrect "call#reconnecting" handler called for type ' + `"${nativeCallEvent.type}".`);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
this._update(nativeCallEvent);
|
|
218
|
+
|
|
219
|
+
const {
|
|
220
|
+
message,
|
|
221
|
+
code
|
|
222
|
+
} = nativeCallEvent.error;
|
|
223
|
+
const error = constructTwilioError(message, code);
|
|
224
|
+
this.emit(Call.Event.Reconnecting, error);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
_defineProperty(this, "_handleReconnectedEvent", nativeCallEvent => {
|
|
228
|
+
if (nativeCallEvent.type !== Constants.CallEventReconnected) {
|
|
229
|
+
throw new Error('Incorrect "call#reconnected" handler called for type ' + `"${nativeCallEvent.type}".`);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
this._update(nativeCallEvent);
|
|
233
|
+
|
|
234
|
+
this.emit(Call.Event.Reconnected);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
_defineProperty(this, "_handleRingingEvent", nativeCallEvent => {
|
|
238
|
+
if (nativeCallEvent.type !== Constants.CallEventRinging) {
|
|
239
|
+
throw new Error('Incorrect "call#ringing" handler called for type ' + `"${nativeCallEvent.type}".`);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
this._update(nativeCallEvent);
|
|
243
|
+
|
|
244
|
+
this.emit(Call.Event.Ringing);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
_defineProperty(this, "_handleQualityWarningsChangedEvent", nativeCallEvent => {
|
|
248
|
+
if (nativeCallEvent.type !== Constants.CallEventQualityWarningsChanged) {
|
|
249
|
+
throw new Error('Incorrect "call#qualityWarnings" handler called for type ' + `"${nativeCallEvent.type}".`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
this._update(nativeCallEvent);
|
|
253
|
+
|
|
254
|
+
const currentWarnings = nativeCallEvent[Constants.CallEventCurrentWarnings];
|
|
255
|
+
const previousWarnings = nativeCallEvent[Constants.CallEventPreviousWarnings];
|
|
256
|
+
this.emit(Call.Event.QualityWarningsChanged, currentWarnings, previousWarnings);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
_defineProperty(this, "_handleMessageReceivedEvent", nativeCallEvent => {
|
|
260
|
+
if (nativeCallEvent.type !== Constants.CallEventMessageReceived) {
|
|
261
|
+
throw new Error('Incorrect "call#Received" handler called for type' + `"${nativeCallEvent.type}`);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
this._update(nativeCallEvent);
|
|
265
|
+
|
|
266
|
+
const {
|
|
267
|
+
callMessage: callMessageInfo
|
|
268
|
+
} = nativeCallEvent;
|
|
269
|
+
const incomingCallMessage = new IncomingCallMessage(callMessageInfo);
|
|
270
|
+
this.emit(Call.Event.MessageReceived, incomingCallMessage);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
this._uuid = uuid;
|
|
274
|
+
this._customParameters = { ...customParameters
|
|
275
|
+
};
|
|
276
|
+
this._from = from;
|
|
277
|
+
this._sid = sid;
|
|
278
|
+
this._state = typeof state === 'string' ? state : Call.State.Connecting;
|
|
279
|
+
this._to = to;
|
|
280
|
+
this._isMuted = isMuted;
|
|
281
|
+
this._isOnHold = isOnHold;
|
|
282
|
+
this._initialConnectedTimestamp = initialConnectedTimestamp ? new Date(initialConnectedTimestamp) : undefined;
|
|
283
|
+
this._nativeEventHandler = {
|
|
284
|
+
/**
|
|
285
|
+
* Call State
|
|
286
|
+
*/
|
|
287
|
+
[Constants.CallEventConnected]: this._handleConnectedEvent,
|
|
288
|
+
[Constants.CallEventConnectFailure]: this._handleConnectFailureEvent,
|
|
289
|
+
[Constants.CallEventDisconnected]: this._handleDisconnectedEvent,
|
|
290
|
+
[Constants.CallEventReconnected]: this._handleReconnectedEvent,
|
|
291
|
+
[Constants.CallEventReconnecting]: this._handleReconnectingEvent,
|
|
292
|
+
[Constants.CallEventRinging]: this._handleRingingEvent,
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Call Quality
|
|
296
|
+
*/
|
|
297
|
+
[Constants.CallEventQualityWarningsChanged]: this._handleQualityWarningsChangedEvent,
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Call Message
|
|
301
|
+
*/
|
|
302
|
+
[Constants.CallEventMessageReceived]: this._handleMessageReceivedEvent
|
|
303
|
+
};
|
|
304
|
+
NativeEventEmitter.addListener(Constants.ScopeCall, this._handleNativeEvent);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* This intermediate native call event handler acts as a "gate", only
|
|
308
|
+
* executing the actual call event handler (such as `Connected`) if this call
|
|
309
|
+
* object matches the `Uuid` of the call that had an event raised.
|
|
310
|
+
* @param nativeCallEvent - A call event directly from the native layer.
|
|
311
|
+
*/
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Helper function to update the state of the call when a call event occurs
|
|
316
|
+
* that necessitates an update, i.e. upon a
|
|
317
|
+
* {@link (Call:namespace).Event.Connected | Connected event} we want to
|
|
318
|
+
* update the state of the call to also reflect the
|
|
319
|
+
* {@link (Call:namespace).State.Connected | Connected state}.
|
|
320
|
+
* @param nativeCallEvent - The native call event.
|
|
321
|
+
*/
|
|
322
|
+
_update({
|
|
323
|
+
type,
|
|
324
|
+
call: {
|
|
325
|
+
from,
|
|
326
|
+
initialConnectedTimestamp,
|
|
327
|
+
sid,
|
|
328
|
+
to
|
|
329
|
+
}
|
|
330
|
+
}) {
|
|
331
|
+
const newState = eventTypeStateMap[type];
|
|
332
|
+
|
|
333
|
+
if (typeof newState === 'string') {
|
|
334
|
+
this._state = newState;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
this._from = from;
|
|
338
|
+
this._initialConnectedTimestamp = initialConnectedTimestamp ? new Date(initialConnectedTimestamp) : undefined;
|
|
339
|
+
this._sid = sid;
|
|
340
|
+
this._to = to;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Handler for the the {@link (Call:namespace).Event.Connected} event.
|
|
344
|
+
* @param nativeCallEvent - The native call event.
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Disconnect this side of the call.
|
|
350
|
+
* @returns
|
|
351
|
+
* A `Promise` that
|
|
352
|
+
* - Resolves when the call has disconnected.
|
|
353
|
+
* - Rejects if the native layer cannot disconnect the call.
|
|
354
|
+
*/
|
|
355
|
+
disconnect() {
|
|
356
|
+
return NativeModule.call_disconnect(this._uuid);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Get the mute status of this side of the call.
|
|
360
|
+
* @returns
|
|
361
|
+
* - A boolean representing the muted status of the call.
|
|
362
|
+
* - `undefined` if the call state has not yet been received from the native
|
|
363
|
+
* layer.
|
|
364
|
+
*/
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
isMuted() {
|
|
368
|
+
return this._isMuted;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Get the hold status of this side of the call.
|
|
372
|
+
* @returns
|
|
373
|
+
* - A boolean representing the hold status of the call.
|
|
374
|
+
* - `undefined` if the call state has not yet been received from the native
|
|
375
|
+
* layer.
|
|
376
|
+
*/
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
isOnHold() {
|
|
380
|
+
return this._isOnHold;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Return a `Record` of custom parameters given to this call.
|
|
384
|
+
* @returns
|
|
385
|
+
* - A `Record` of custom parameters.
|
|
386
|
+
*/
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
getCustomParameters() {
|
|
390
|
+
return this._customParameters;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Get the value of the `from` parameter given to this call.
|
|
394
|
+
* @returns
|
|
395
|
+
* - A `String` representing the `from` parameter.
|
|
396
|
+
* - `undefined` if the call information has not yet been received from the
|
|
397
|
+
* native layer.
|
|
398
|
+
*/
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
getFrom() {
|
|
402
|
+
return this._from;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Get the timestamp (milliseconds since epoch) of the call connected event.
|
|
406
|
+
* @returns
|
|
407
|
+
* - A `number` representing the timestamp.
|
|
408
|
+
* - `undefined` if the call has not yet connected.
|
|
409
|
+
*/
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
getInitialConnectedTimestamp() {
|
|
413
|
+
return this._initialConnectedTimestamp;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Get the call `SID`.
|
|
417
|
+
* @returns
|
|
418
|
+
* - A `String` representing the `SID` of the call.
|
|
419
|
+
* - `undefined` if the call information has not yet been received from the
|
|
420
|
+
* native layer.
|
|
421
|
+
*/
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
getSid() {
|
|
425
|
+
return this._sid;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Get the state of the call object, such as {@link (Call:namespace).State.Connected} or
|
|
429
|
+
* {@link (Call:namespace).State.Disconnected}.
|
|
430
|
+
* @returns
|
|
431
|
+
* - A {@link (Call:namespace).State}.
|
|
432
|
+
*/
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
getState() {
|
|
436
|
+
return this._state;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Gets the `PeerConnection` `WebRTC` stats for the ongoing call.
|
|
440
|
+
* @returns
|
|
441
|
+
* A `Promise` that
|
|
442
|
+
* - Resolves with a {@link RTCStats.StatsReport} object representing the
|
|
443
|
+
* `WebRTC` `PeerConnection` stats of a call.
|
|
444
|
+
* - Rejects when a {@link RTCStats.StatsReport} cannot be generated for a
|
|
445
|
+
* call.
|
|
446
|
+
*/
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
getStats() {
|
|
450
|
+
return NativeModule.call_getStats(this._uuid);
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Get the value of the `to` parameter given to this call.
|
|
454
|
+
* @returns
|
|
455
|
+
* - A `String` representing the `to` parameter.
|
|
456
|
+
* - `undefined` if the call information has not yet been received from the
|
|
457
|
+
* native layer.
|
|
458
|
+
*/
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
getTo() {
|
|
462
|
+
return this._to;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Put this end of the call on hold or not on hold.
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
* To put a call on hold
|
|
469
|
+
* ```typescript
|
|
470
|
+
* call.hold(true);
|
|
471
|
+
* ```
|
|
472
|
+
* @example
|
|
473
|
+
* To take a call off hold
|
|
474
|
+
* ```typescript
|
|
475
|
+
* call.hold(false);
|
|
476
|
+
* ```
|
|
477
|
+
*
|
|
478
|
+
* @param hold - A `boolean` representing whether or not to put this end of
|
|
479
|
+
* the call on hold.
|
|
480
|
+
*
|
|
481
|
+
* @returns
|
|
482
|
+
* A `Promise` that
|
|
483
|
+
* - Resolves with the hold status when the call is put on hold or not on
|
|
484
|
+
* hold.
|
|
485
|
+
* - Rejects when the call is not able to be put on hold or not on hold.
|
|
486
|
+
*/
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
async hold(hold) {
|
|
490
|
+
this._isOnHold = await NativeModule.call_hold(this._uuid, hold);
|
|
491
|
+
return this._isOnHold;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Mute or unmute this end of the call.
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* To mute a call
|
|
498
|
+
* ```typescript
|
|
499
|
+
* call.mute(true);
|
|
500
|
+
* ```
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* To unmute a call
|
|
504
|
+
* ```typescript
|
|
505
|
+
* call.mute(false);
|
|
506
|
+
* ```
|
|
507
|
+
*
|
|
508
|
+
* @param mute - A `boolean` representing whether or not to mute this end of
|
|
509
|
+
* the call.
|
|
510
|
+
*
|
|
511
|
+
* @returns
|
|
512
|
+
* A `Promise` that
|
|
513
|
+
* - Resolves with the muted status of the call when the call is muted or
|
|
514
|
+
* unmuted.
|
|
515
|
+
* - Rejects when the call is not able to be muted or unmuted.
|
|
516
|
+
*/
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
async mute(mute) {
|
|
520
|
+
this._isMuted = await NativeModule.call_mute(this._uuid, mute);
|
|
521
|
+
return this._isMuted;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Send DTMF digits.
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* To send the `0` dialtone:
|
|
528
|
+
* ```typescript
|
|
529
|
+
* call.sendDigits('0');
|
|
530
|
+
* ```
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* To send the `0` and then `1` dialtone:
|
|
534
|
+
* ```typescript
|
|
535
|
+
* call.sendDigits('01');
|
|
536
|
+
* ```
|
|
537
|
+
*
|
|
538
|
+
* @param digits - A sequence of DTMF digits in a string.
|
|
539
|
+
*
|
|
540
|
+
* @returns
|
|
541
|
+
* A `Promise` that
|
|
542
|
+
* - Resolves when the DTMF digits have been sent.
|
|
543
|
+
* - Rejects when DTMF tones are not able to be sent.
|
|
544
|
+
*/
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
sendDigits(digits) {
|
|
548
|
+
return NativeModule.call_sendDigits(this._uuid, digits);
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Send a CallMessage.
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* To send a user-defined-message
|
|
555
|
+
* ```typescript
|
|
556
|
+
* const outgoingCallMessage: OutgoingCallMessage = await call.sendMessage({
|
|
557
|
+
* content: { key1: 'This is a messsage from the parent call' },
|
|
558
|
+
* contentType: 'application/json',
|
|
559
|
+
* messageType: 'user-defined-message'
|
|
560
|
+
* });
|
|
561
|
+
*
|
|
562
|
+
* outgoingCallMessage.addListener(OutgoingCallMessage.Event.Failure, (error) => {
|
|
563
|
+
* // outgoingCallMessage failed, handle error
|
|
564
|
+
* });
|
|
565
|
+
*
|
|
566
|
+
* outgoingCallMessage.addListener(OutgoingCallMessage.Event.Sent, () => {
|
|
567
|
+
* // outgoingCallMessage sent
|
|
568
|
+
* });
|
|
569
|
+
* ```
|
|
570
|
+
*
|
|
571
|
+
* @param message - The call message to send.
|
|
572
|
+
*
|
|
573
|
+
* @returns
|
|
574
|
+
* A `Promise` that
|
|
575
|
+
* - Resolves with the OutgoingCallMessage object.
|
|
576
|
+
* - Rejects when the message is unable to be sent.
|
|
577
|
+
*/
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
async sendMessage(message) {
|
|
581
|
+
const {
|
|
582
|
+
content,
|
|
583
|
+
contentType,
|
|
584
|
+
messageType
|
|
585
|
+
} = validateCallMessage(message);
|
|
586
|
+
const voiceEventSid = await NativeModule.call_sendMessage(this._uuid, content, contentType, messageType);
|
|
587
|
+
const outgoingCallMessage = new OutgoingCallMessage({
|
|
588
|
+
content,
|
|
589
|
+
contentType,
|
|
590
|
+
messageType,
|
|
591
|
+
voiceEventSid
|
|
592
|
+
});
|
|
593
|
+
return outgoingCallMessage;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Post feedback about a call.
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* To report that a call had very significant audio latency:
|
|
600
|
+
* ```typescript
|
|
601
|
+
* call.postFeedback(Call.Score.Five, Call.Issue.AudioLatency);
|
|
602
|
+
* ```
|
|
603
|
+
*
|
|
604
|
+
* @param score - A score representing the serverity of the issue being
|
|
605
|
+
* reported.
|
|
606
|
+
* @param issue - The issue being reported.
|
|
607
|
+
* @returns
|
|
608
|
+
* A `Promise` that
|
|
609
|
+
* - Resolves when the feedback has been posted.
|
|
610
|
+
* - Rejects when the feedback is unable to be sent.
|
|
611
|
+
*/
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
async postFeedback(score, issue) {
|
|
615
|
+
if (!validScores.includes(score)) {
|
|
616
|
+
throw new InvalidArgumentError('"score" parameter invalid. Must be a member of the `Call.Score` enum.');
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
if (!Object.values(Call.Issue).includes(issue)) {
|
|
620
|
+
throw new InvalidArgumentError('"issue" parameter invalid. Must be a member of the `Call.Issue` enum.');
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
const nativeScore = scoreMap[score];
|
|
624
|
+
const nativeIssue = issueMap[issue];
|
|
625
|
+
return NativeModule.call_postFeedback(this._uuid, nativeScore, nativeIssue);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Namespace for enumerations and types used by
|
|
631
|
+
* {@link (Call:class) | Call objects}.
|
|
632
|
+
*
|
|
633
|
+
* @remarks
|
|
634
|
+
* - See also the {@link (Call:class) | Call class}.
|
|
635
|
+
* - See also the {@link (Call:interface) | Call interface}.
|
|
636
|
+
*
|
|
637
|
+
* @public
|
|
638
|
+
*/
|
|
639
|
+
|
|
640
|
+
(function (_Call) {
|
|
641
|
+
let Event;
|
|
642
|
+
|
|
643
|
+
(function (Event) {
|
|
644
|
+
Event["Connected"] = "connected";
|
|
645
|
+
Event["ConnectFailure"] = "connectFailure";
|
|
646
|
+
Event["Reconnecting"] = "reconnecting";
|
|
647
|
+
Event["Reconnected"] = "reconnected";
|
|
648
|
+
Event["Disconnected"] = "disconnected";
|
|
649
|
+
Event["Ringing"] = "ringing";
|
|
650
|
+
Event["QualityWarningsChanged"] = "qualityWarningsChanged";
|
|
651
|
+
Event["MessageReceived"] = "messageReceived";
|
|
652
|
+
})(Event || (Event = {}));
|
|
653
|
+
|
|
654
|
+
_Call.Event = Event;
|
|
655
|
+
let State;
|
|
656
|
+
|
|
657
|
+
(function (State) {
|
|
658
|
+
State[State["Connected"] = Constants.CallStateConnected] = "Connected";
|
|
659
|
+
State[State["Connecting"] = Constants.CallStateConnecting] = "Connecting";
|
|
660
|
+
State[State["Disconnected"] = Constants.CallStateDisconnected] = "Disconnected";
|
|
661
|
+
State[State["Reconnecting"] = Constants.CallStateReconnecting] = "Reconnecting";
|
|
662
|
+
State[State["Ringing"] = Constants.CallStateRinging] = "Ringing";
|
|
663
|
+
})(State || (State = {}));
|
|
664
|
+
|
|
665
|
+
_Call.State = State;
|
|
666
|
+
let QualityWarning;
|
|
667
|
+
|
|
668
|
+
(function (QualityWarning) {
|
|
669
|
+
QualityWarning["ConstantAudioInputLevel"] = "constant-audio-input-level";
|
|
670
|
+
QualityWarning["HighJitter"] = "high-jitter";
|
|
671
|
+
QualityWarning["HighPacketLoss"] = "high-packet-loss";
|
|
672
|
+
QualityWarning["HighRtt"] = "high-rtt";
|
|
673
|
+
QualityWarning["LowMos"] = "low-mos";
|
|
674
|
+
})(QualityWarning || (QualityWarning = {}));
|
|
675
|
+
|
|
676
|
+
_Call.QualityWarning = QualityWarning;
|
|
677
|
+
let Score;
|
|
678
|
+
|
|
679
|
+
(function (Score) {
|
|
680
|
+
Score[Score["NotReported"] = 0] = "NotReported";
|
|
681
|
+
Score[Score["One"] = 1] = "One";
|
|
682
|
+
Score[Score["Two"] = 2] = "Two";
|
|
683
|
+
Score[Score["Three"] = 3] = "Three";
|
|
684
|
+
Score[Score["Four"] = 4] = "Four";
|
|
685
|
+
Score[Score["Five"] = 5] = "Five";
|
|
686
|
+
})(Score || (Score = {}));
|
|
687
|
+
|
|
688
|
+
_Call.Score = Score;
|
|
689
|
+
let Issue;
|
|
690
|
+
|
|
691
|
+
(function (Issue) {
|
|
692
|
+
Issue["NotReported"] = "not-reported";
|
|
693
|
+
Issue["DroppedCall"] = "dropped-call";
|
|
694
|
+
Issue["AudioLatency"] = "audio-latency";
|
|
695
|
+
Issue["OneWayAudio"] = "one-way-audio";
|
|
696
|
+
Issue["ChoppyAudio"] = "choppy-audio";
|
|
697
|
+
Issue["NoisyCall"] = "noisy-call";
|
|
698
|
+
Issue["Echo"] = "echo";
|
|
699
|
+
})(Issue || (Issue = {}));
|
|
700
|
+
|
|
701
|
+
_Call.Issue = Issue;
|
|
702
|
+
let Listener;
|
|
703
|
+
|
|
704
|
+
(function (_Listener) {})(Listener || (Listener = _Call.Listener || (_Call.Listener = {})));
|
|
705
|
+
})(Call || (Call = {}));
|
|
706
|
+
/**
|
|
707
|
+
* Mapping of {@link (Call:namespace).Event | Call events} to
|
|
708
|
+
* {@link (Call:namespace).State | Call states}.
|
|
709
|
+
*
|
|
710
|
+
* @remarks
|
|
711
|
+
* Note that this mapping is not a 1:1 bijection. Not every event coming from
|
|
712
|
+
* the native layer has a relevant state, and some events share a state.
|
|
713
|
+
* Therefore, this `Record` needs to be marked as `Partial` and
|
|
714
|
+
* undefined-checking logic is needed when using this mapping.
|
|
715
|
+
*
|
|
716
|
+
* @internal
|
|
717
|
+
*/
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
const eventTypeStateMap = {
|
|
721
|
+
[Constants.CallEventConnected]: Call.State.Connected,
|
|
722
|
+
[Constants.CallEventConnectFailure]: Call.State.Disconnected,
|
|
723
|
+
[Constants.CallEventDisconnected]: Call.State.Disconnected,
|
|
724
|
+
[Constants.CallEventReconnecting]: Call.State.Reconnecting,
|
|
725
|
+
[Constants.CallEventReconnected]: Call.State.Connected,
|
|
726
|
+
[Constants.CallEventRinging]: Call.State.Ringing
|
|
727
|
+
};
|
|
728
|
+
/**
|
|
729
|
+
* Array of valid call scores.
|
|
730
|
+
*
|
|
731
|
+
* @internal
|
|
732
|
+
*/
|
|
733
|
+
|
|
734
|
+
const validScores = [Call.Score.NotReported, Call.Score.One, Call.Score.Two, Call.Score.Three, Call.Score.Four, Call.Score.Five];
|
|
735
|
+
/**
|
|
736
|
+
* Mapping of the {@link (Call:namespace).Score | Call score} enum to
|
|
737
|
+
* cross-platform common constants.
|
|
738
|
+
*
|
|
739
|
+
* @internal
|
|
740
|
+
*/
|
|
741
|
+
|
|
742
|
+
const scoreMap = {
|
|
743
|
+
[Call.Score.NotReported]: Constants.CallFeedbackScoreNotReported,
|
|
744
|
+
[Call.Score.One]: Constants.CallFeedbackScoreOne,
|
|
745
|
+
[Call.Score.Two]: Constants.CallFeedbackScoreTwo,
|
|
746
|
+
[Call.Score.Three]: Constants.CallFeedbackScoreThree,
|
|
747
|
+
[Call.Score.Four]: Constants.CallFeedbackScoreFour,
|
|
748
|
+
[Call.Score.Five]: Constants.CallFeedbackScoreFive
|
|
749
|
+
};
|
|
750
|
+
/**
|
|
751
|
+
* Mapping of the {@link (Call:namespace).Issue | Call issue} enum to
|
|
752
|
+
* cross-platform common constants.
|
|
753
|
+
*
|
|
754
|
+
* @internal
|
|
755
|
+
*/
|
|
756
|
+
|
|
757
|
+
const issueMap = {
|
|
758
|
+
[Call.Issue.AudioLatency]: Constants.CallFeedbackIssueAudioLatency,
|
|
759
|
+
[Call.Issue.ChoppyAudio]: Constants.CallFeedbackIssueChoppyAudio,
|
|
760
|
+
[Call.Issue.DroppedCall]: Constants.CallFeedbackIssueDroppedCall,
|
|
761
|
+
[Call.Issue.Echo]: Constants.CallFeedbackIssueEcho,
|
|
762
|
+
[Call.Issue.NoisyCall]: Constants.CallFeedbackIssueNoisyCall,
|
|
763
|
+
[Call.Issue.NotReported]: Constants.CallFeedbackIssueNotReported,
|
|
764
|
+
[Call.Issue.OneWayAudio]: Constants.CallFeedbackIssueOneWayAudio
|
|
765
|
+
};
|
|
766
|
+
//# sourceMappingURL=Call.js.map
|