@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 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', async (event) => {
210
- if (event instanceof MemberInvitedEvent) {
211
- console.log(
212
- `User ${event.body.invitee.name} invited by ${event.body.inviter?.name} to Conversation ${event.conversationId}`
213
- );
214
- } else if (event instanceof MemberJoinedEvent) {
215
- console.log(
216
- `User ${event.body.user.name} joined Conversation ${event.conversationId}`
217
- );
218
- } else if (event instanceof MemberLeftEvent) {
219
- console.log(
220
- `User ${event.body.user.name} left Conversation ${event.conversationId}`
221
- );
222
- } else if (event instanceof TextMessageEvent) {
223
- console.log(
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 type VonageEvent = vonage.CombinedEvents;
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
  /**