@d-id/client-sdk 2.0.7 → 2.0.8

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
@@ -126,12 +126,10 @@ The `agentManager` object created during initialization has several built-in met
126
126
  ```
127
127
 
128
128
  ```javascript Audio File - JavaScript
129
- let speak = agentManager.speak(
130
- {
131
- type: "audio",
132
- audio_url: "http://www.yourwebsite.com/audio.mp3"
133
- }
134
- );
129
+ let speak = agentManager.speak({
130
+ type: 'audio',
131
+ audio_url: 'http://www.yourwebsite.com/audio.mp3',
132
+ });
135
133
  ```
136
134
 
137
135
  - **`agentManager.chat(string)`**
@@ -158,28 +156,28 @@ The `agentManager` object created during initialization has several built-in met
158
156
  **Supported only with Expressive (V4) agents.**
159
157
  Method to publish a microphone audio track to the session. Call after `connect()` to enable voice input.
160
158
 
161
- ```javascript
162
- const micStream = await navigator.mediaDevices.getUserMedia({ audio: true });
163
- await agentManager.publishMicrophoneStream(micStream);
164
- ```
159
+ ```javascript
160
+ const micStream = await navigator.mediaDevices.getUserMedia({ audio: true });
161
+ await agentManager.publishMicrophoneStream(micStream);
162
+ ```
165
163
 
166
164
  - **`agentManager.unpublishMicrophoneStream()`**
167
165
  **Supported only with Expressive (V4) agents.**
168
166
  Method to stop and remove the currently published microphone track from the session.
169
167
 
170
- ```javascript
171
- await agentManager.unpublishMicrophoneStream();
172
- ```
168
+ ```javascript
169
+ await agentManager.unpublishMicrophoneStream();
170
+ ```
173
171
 
174
172
  - **`agentManager.sendDataChannelMessage(topic, payload)`**
175
173
  **Supported only with Expressive (V4) agents.**
176
174
  Method to send a JSON payload to the agent over a data-channel topic. `PublicDataChannelTopic` is exported from the package root and lists every topic this method accepts.
177
175
 
178
- ```javascript
179
- import { PublicDataChannelTopic } from '@d-id/client-sdk';
176
+ ```javascript
177
+ import { PublicDataChannelTopic } from '@d-id/client-sdk';
180
178
 
181
- await agentManager.sendDataChannelMessage(PublicDataChannelTopic.Presentation, { type: 'navigate', slide: 3 });
182
- ```
179
+ await agentManager.sendDataChannelMessage(PublicDataChannelTopic.Presentation, { type: 'navigate', slide: 3 });
180
+ ```
183
181
 
184
182
  ### ➤ ✴️ Callback Functions
185
183
 
@@ -217,21 +215,24 @@ Callback functions enable you to manage various events throughout the SDK lifecy
217
215
  }
218
216
  ```
219
217
 
220
- - **`onConnectionStateChange(state):`**
218
+ - **`onConnectionStateChange(state, reason):`**
221
219
  Displaying the different connection states with the Agent's WebRTC stream connection
222
220
  Triggered when `agentManager.connect(), agentManager.reconnect(), agentManager.disconnect()` are called.
223
221
 
224
222
  ```javascript
225
- onConnectionStateChange(state) {
226
- console.log("onConnectionStateChange(): ", state)
223
+ onConnectionStateChange(state, reason) {
224
+ console.log("onConnectionStateChange(): ", state, reason)
227
225
  if (state == "connected") {
228
226
  console.log("I'm ready to go!")
229
227
  }
230
228
  }
231
229
  ```
232
230
 
231
+ The second `reason` argument says why the connection reached that state. On `disconnected` it is a `StreamEndReason` when the server ended the stream on purpose, which lets you tell a deliberate end from a dropped connection. Any other value is an opaque transport diagnostic. `agentManager.reconnect()` still works after a deliberate end; it starts a new stream rather than resuming the old one.
232
+
233
233
  ```javascript Example Values
234
234
  state: ['new', 'fail', 'connecting', 'connected', 'disconnected', 'closed'];
235
+ reason: ['ok', 'unknown_error', 'network_issue', 'message_limit', 'time_limit', 'inactivity', 'ended_by_agent'];
235
236
  ```
236
237
 
237
238
  - **`onNewMessage(messages, type)`:**