@vonage/client-sdk 1.1.0 → 1.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -21
- package/dist/client/VonageClient.d.ts +11 -2
- package/dist/client/index.cjs +3213 -3141
- package/dist/client/index.mjs +3213 -3136
- package/dist/kotlin/ConversationEvents.d.ts +80 -0
- package/dist/lib/MediaClient.d.ts +0 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/vonageClientSDK.js +7076 -3580
- package/dist/vonageClientSDK.min.js +2 -2
- package/dist/vonageClientSDK.min.mjs +2 -2
- package/dist/vonageClientSDK.mjs +7076 -3575
- package/package.json +9 -5
- package/rollup.config.js +2 -1
- package/dist/utils/ConversationEventModels.d.ts +0 -11
package/README.md
CHANGED
|
@@ -165,6 +165,32 @@ client.on('callHangup', async (callId: string, callQuality: RTCQuality) => {
|
|
|
165
165
|
console.log(`Call ${callId} has hanged up, callQuality:${callQuality}`);
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
|
+
|
|
169
|
+
client.on('callHangup', (callId, callQuality, reason) => {
|
|
170
|
+
if (callId == call) {
|
|
171
|
+
console.log('The call has finished');
|
|
172
|
+
}
|
|
173
|
+
console.log(`this was your call mos score: `, callQuality.mos_score);
|
|
174
|
+
const reason_name = reason.name;
|
|
175
|
+
if (reason_name === 'LOCAL_HANGUP') {
|
|
176
|
+
console.log('you hangup the call');
|
|
177
|
+
return;
|
|
178
|
+
} else if (reason_name === 'REMOTE_HANGUP') {
|
|
179
|
+
console.log('call was hanged up remotly');
|
|
180
|
+
return;
|
|
181
|
+
} else if (reason_name === 'REMOTE_REJECT') {
|
|
182
|
+
console.log('call was rejected');
|
|
183
|
+
return;
|
|
184
|
+
} else if (reason_name === 'MEDIA_TIMEOUT') {
|
|
185
|
+
console.log('media timeout');
|
|
186
|
+
return;
|
|
187
|
+
} else if (reason_name === 'REMOTE_NO_ANSWER_TIMEOUT') {
|
|
188
|
+
console.log('remote no answer timeout');
|
|
189
|
+
return;
|
|
190
|
+
} else {
|
|
191
|
+
return exhaustiveCheck(reason_name);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
168
194
|
```
|
|
169
195
|
|
|
170
196
|
### Get Conversations
|
|
@@ -206,27 +232,21 @@ try {
|
|
|
206
232
|
### Listen for Conversation Events
|
|
207
233
|
|
|
208
234
|
```ts
|
|
209
|
-
client.on('conversationEvent',
|
|
210
|
-
if (event
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
`User ${event.body.sender.name} sent Text Message '${event.body.text}' in Conversation ${event.conversationId}`
|
|
225
|
-
);
|
|
226
|
-
} else if (event instanceof CustomMessageEvent) {
|
|
227
|
-
console.log(
|
|
228
|
-
`User ${event.body.sender} sent Custom Message '${event.body.customData}' in Conversation ${event.conversationId}`
|
|
229
|
-
);
|
|
235
|
+
client.on('conversationEvent', (event) => {
|
|
236
|
+
if (event.kind == 'member:invited') {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (event.kind == 'member:joined') {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (event.kind == 'member:left') {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (event.kind == 'message:text') {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (event.kind == 'message:custom') {
|
|
249
|
+
return;
|
|
230
250
|
}
|
|
231
251
|
});
|
|
232
252
|
```
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import vonage from '../utils/vonage';
|
|
2
|
+
import { Conversation, ConversationsPage, Member, MembersPage, PresentingOrder, ConversationEvent } from '../utils';
|
|
2
3
|
/**
|
|
3
4
|
* The Vonage Client SDK for JS/TS provides a simple interface
|
|
4
5
|
* For the Vonage Voice and Messaging APIs.
|
|
@@ -11,7 +12,12 @@ import vonage from '../utils/vonage';
|
|
|
11
12
|
* @packageDocumentation
|
|
12
13
|
*/
|
|
13
14
|
export * from '../utils';
|
|
14
|
-
export
|
|
15
|
+
export interface EventsPage extends vonage.EventsPageJS {
|
|
16
|
+
events: ConversationEvent[];
|
|
17
|
+
}
|
|
18
|
+
interface VonageEvent extends vonage.CombinedEvents {
|
|
19
|
+
conversationEvent: (event: ConversationEvent) => void;
|
|
20
|
+
}
|
|
15
21
|
export type RTCQuality = vonage.RTCQualityJS;
|
|
16
22
|
export type CancelReason = vonage.CancelReasonJS;
|
|
17
23
|
export declare const CancelReason: typeof vonage.CancelReasonJS;
|
|
@@ -28,7 +34,6 @@ export type CallSayParams = Partial<vonage.CallSayParams> & {
|
|
|
28
34
|
type JSONValue = string | number | boolean | {
|
|
29
35
|
[x: string]: JSONValue;
|
|
30
36
|
} | JSONValue[];
|
|
31
|
-
import { Conversation, ConversationsPage, EventsPage, Member, MembersPage, PresentingOrder } from '../utils';
|
|
32
37
|
export declare const setVonageClientLoggingLevel: typeof vonage.setDefaultLoggingLevel;
|
|
33
38
|
/**
|
|
34
39
|
* VonageClient is the main entry point for the Vonage Client SDK.
|
|
@@ -186,6 +191,10 @@ export declare class VonageClient extends vonage.CombinedClientJS {
|
|
|
186
191
|
* @param pageSize - the number of events to return per page (default: 100)
|
|
187
192
|
* @param cursor - the cursor to use for pagination (default: null)
|
|
188
193
|
* @returns a `EventsPage` containing the events
|
|
194
|
+
*
|
|
195
|
+
* @privateRemarks
|
|
196
|
+
* * This is a workaround for the to ensure exhaustiveness of the `ConversationEvent` type
|
|
197
|
+
* * the kotlin core does not support union types
|
|
189
198
|
*/
|
|
190
199
|
getConversationEvents(id: string, order?: PresentingOrder, pageSize?: number, cursor?: string | null): Promise<EventsPage>;
|
|
191
200
|
/**
|