Skip to content

Commit 428da6e

Browse files
VBLOCKS-3365 Update preflight docs (#286)
* Update preflight docs * Update docs
1 parent 98e170c commit 428da6e

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

PREFLIGHT.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Preflight Test
22
==============
33

4-
The SDK supports a preflight test API which can help determine Voice calling readiness. The API creates a test call and will provide information to help troubleshoot call related issues. This new API is a static member of the [Device](https://www.twilio.com/docs/voice/client/javascript/device#twilio-device) class and can be used by calling `Device.testPreflight(token, options)`. For example:
4+
The SDK supports a preflight test API which can help determine Voice calling readiness. The API creates a test call and will provide information to help troubleshoot call related issues. This new API is a static member of the [Device](https://www.twilio.com/docs/voice/sdks/javascript/twiliodevice) class and can be used by calling `Device.runPreflight(token, options)`. For example:
55

66
```ts
7-
import { Device, PreflightTest } from 'twilio-client';
7+
import { Device, PreflightTest } from '@twilio/voice-sdk';
88

9-
const preflightTest = Device.testPreflight(token, options);
9+
const preflightTest = Device.runPreflight(token, options);
1010

1111
preflightTest.on(PreflightTest.Events.Completed, (report) => {
1212
console.log(report);
@@ -20,7 +20,7 @@ preflightTest.on(PreflightTest.Events.Failed, (error) => {
2020
## Parameters
2121

2222
### Token
23-
`Device.testPreflight(token, options)` requires a [Twilio Access Token](https://www.twilio.com/docs/iam/access-tokens) to initiate the test call. This access token will be passed directly to the [Device's constructor](https://www.twilio.com/docs/voice/client/javascript/device#setup) and will be used to connect to a TwiML app that you associated with your [Twilio Access Token](https://www.twilio.com/docs/iam/access-tokens). In order to get better results, the TwiML app should be able to record audio from a microphone and play it back to the browser. Please see [Preflight Test TwiML App](#twiml-app---record-and-play) for details.
23+
`Device.runPreflight(token, options)` requires a [Twilio Access Token](https://www.twilio.com/docs/iam/access-tokens) to initiate the test call. This access token will be passed directly to the [Device's constructor](https://www.twilio.com/docs/voice/sdks/javascript/twiliodevice#instantiate-a-device) and will be used to connect to a TwiML app that you associated with your [Twilio Access Token](https://www.twilio.com/docs/iam/access-tokens). In order to get better results, the TwiML app should be able to record audio from a microphone and play it back to the browser. Please see [Preflight Test TwiML App](#twiml-app---record-and-play) for details.
2424

2525
### Options
2626
The `PreflightTest.Options` parameter is a JavaScript object containing configuration settings. Available settings are listed below:
@@ -29,7 +29,7 @@ The `PreflightTest.Options` parameter is a JavaScript object containing configur
2929
|:---------|:--------|:------------|
3030
| `codecPreferences` | `['pcmu', 'opus']` | An ordered list of preferred codecs. |
3131
| `debug` | `false` | Can be `true` or `false`. Set this property to true to enable debug logging in your browser console. |
32-
| `edge` | `roaming` | Specifies which Twilio `edge` to use when initiating the test call. Please see documentation on [edges](https://www.twilio.com/docs/voice/client/edges). |
32+
| `edge` | `roaming` | Specifies which Twilio `edge` to use when initiating the test call. Please see documentation on [edges](https://www.twilio.com/docs/voice/sdks/javascript/edges). |
3333
| `fakeMicInput` | `false` | If set to `true`, the test call will ignore microphone input and will use a default audio file. If set to `false`, the test call will capture the audio from the microphone. |
3434
| `iceServers` | `null` | An array of custom ICE servers to use to connect media. If you provide both STUN and TURN server configurations, the test will detect whether a TURN server is required to establish a connection. See [Using Twilio NTS for Generating STUN/TURN Credentials](#using-twilio-nts-for-generating-stunturn-credentials) |
3535
| `signalingTimeoutMs` | `10000` | Ammount of time to wait for setting up signaling connection. |
@@ -39,7 +39,7 @@ The following example demonstrates how to use [Twilio's Network Traversal Servic
3939

4040
```ts
4141
import Client from 'twilio';
42-
import { Device } from 'twilio-client';
42+
import { Device } from '@twilio/voice-sdk';
4343

4444
// Generate the STUN and TURN server credentials with a ttl of 120 seconds
4545
const client = Client(twilioAccountSid, authToken);
@@ -58,7 +58,7 @@ iceServers = iceServers.map(config => {
5858
});
5959

6060
// Use the TURN credentials using the iceServers parameter
61-
const preflightTest = Device.testPreflight(token, { iceServers });
61+
const preflightTest = Device.runPreflight(token, { iceServers });
6262

6363
// Read from the report object to determine whether TURN is required to connect to media
6464
preflightTest.on('completed', (report) => {
@@ -69,7 +69,7 @@ preflightTest.on('completed', (report) => {
6969
Events
7070
------
7171

72-
The `PreflightTest` object that is returned by `Device.testPreflight(token, options)` is an [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter), and as such its events can be subscribed to via `preflightTest.on(eventName, handler)`. The following is a list of all supported events that might get emitted throughout the duration of the test.
72+
The `PreflightTest` object that is returned by `Device.runPreflight(token, options)` is an [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter), and as such its events can be subscribed to via `preflightTest.on(eventName, handler)`. The following is a list of all supported events that might get emitted throughout the duration of the test.
7373

7474
#### .on('completed', handler(report))
7575
Raised when `PreflightTest.status` has transitioned to `PreflightTest.Status.Completed`. During this time, the `report` is available and ready to be inspected. This will not trigger if a fatal error is encountered during the test. Example report:
@@ -215,12 +215,12 @@ Raised when `PreflightTest.status` has transitioned to `PreflightTest.Status.Com
215215
/**
216216
* Array of samples collected during the test.
217217
* See sample object format here
218-
* https://www.twilio.com/docs/voice/client/javascript/connection#sample
218+
* https://www.twilio.com/docs/voice/sdks/javascript/twiliocall#sample-event
219219
*/
220220
"samples": [...],
221221

222222
/**
223-
* The edge passed to `Device.testPreflight`.
223+
* The edge passed to `Device.runPreflight`.
224224
*/
225225
"selectedEdge": "roaming",
226226

@@ -240,10 +240,10 @@ Raised when `PreflightTest.status` has transitioned to `PreflightTest.Status.Com
240240
Raised when `PreflightTest.status` has transitioned to `PreflightTest.Status.Connected`. This means, the connection to Twilio has been established.
241241

242242
#### .on('failed', handler(error))
243-
Raised when `PreflightTest.status` has transitioned to `PreflightTest.Status.Failed`. This happens when establishing a connection to Twilio has failed or when a test call has encountered a fatal error. This is also raised if `PreflightTest.stop` is called while the test is in progress. The error emitted from this event is coming from [Device.on('error)](https://www.twilio.com/docs/voice/client/javascript/device#error) and uses the same error format.
243+
Raised when `PreflightTest.status` has transitioned to `PreflightTest.Status.Failed`. This happens when establishing a connection to Twilio has failed or when a test call has encountered a fatal error. This is also raised if `PreflightTest.stop` is called while the test is in progress. The error emitted from this event is coming from [Device.on('error)](https://www.twilio.com/docs/voice/sdks/javascript/twiliodevice#error-event) and uses the same error format.
244244

245245
#### .on('sample', handler(sample))
246-
This event is published every second and is raised when the [Connection](https://www.twilio.com/docs/voice/client/javascript/connection) gets a webrtc sample object. The `sample` object is coming from [Connection.on('sample')](https://www.twilio.com/docs/voice/client/javascript/connection#sample) and uses the same `sample` format.
246+
This event is published every second and is raised when the [Call](https://www.twilio.com/docs/voice/sdks/javascript/twiliocall) gets a webrtc sample object. The `sample` object is coming from [Call.on('sample')](https://www.twilio.com/docs/voice/sdks/javascript/twiliocall#sample-event) and uses the same `sample` format.
247247

248248
#### .on('warning', handler(warning))
249249
Raised whenever the test encounters a warning. Example warning data:
@@ -252,7 +252,7 @@ Raised whenever the test encounters a warning. Example warning data:
252252
{
253253
/**
254254
* Name of the warning.
255-
* See https://www.twilio.com/docs/voice/insights/call-quality-events-twilio-client-sdk
255+
* See https://www.twilio.com/docs/voice/voice-insights/api/call/details-sdk-call-quality-events
256256
*/
257257
name: 'insights-connection-error',
258258

@@ -262,8 +262,8 @@ Raised whenever the test encounters a warning. Example warning data:
262262
description: 'Received an error when attempting to connect to Insights gateway',
263263

264264
/**
265-
* Optional RTCWarning data coming from Connection.on('warning')
266-
* See https://www.twilio.com/docs/voice/client/javascript/connection#onwarning-handlerwarningname
265+
* Optional RTCWarning data coming from Call.on('warning')
266+
* See https://www.twilio.com/docs/voice/sdks/javascript/twiliocall#warning-event
267267
*/
268268
rtcWarning: {...}
269269
}
@@ -275,9 +275,9 @@ You can access the following properties on the `PreflightTest` object:
275275

276276
* `callSid` - The callsid generated for the test call. This is set when the client has finished connecting to Twilio.
277277
* `endTime` - A timestamp in milliseconds of when the test ended. This is set when the test has completed and raised the `completed` event.
278-
* `latestSample` - The latest WebRTC sample collected. This is set whenever the connection emits a `sample`. Please see [Connection.on('sample')](https://www.twilio.com/docs/voice/client/javascript/connection#sample) API for more details.
278+
* `latestSample` - The latest WebRTC sample collected. This is set whenever the connection emits a `sample`. Please see [Call.on('sample')](https://www.twilio.com/docs/voice/sdks/javascript/twiliocall#sample-event) API for more details.
279279
* `report` - The report for this test. This is set when the test has completed and raised the `completed` event.
280-
* `startTime` - A timestamp in milliseconds of when the test started. This is set right after calling `Device.testPreflight(token, options)`.
280+
* `startTime` - A timestamp in milliseconds of when the test started. This is set right after calling `Device.runPreflight(token, options)`.
281281
* `status` - The status of the test. Below are the possible values for this property.
282282

283283
| Value | Description |
@@ -297,7 +297,7 @@ Calling this method from the `PreflightTest` object will stop the existing test
297297
TwiML App - Record and Play
298298
===========================
299299

300-
If `PreflightTest.Options.fakeMicInput` is set to `false`, `Device.testPreflight(token, options)` API requires a [token](https://www.twilio.com/docs/iam/access-tokens) with a TwiML app that can record an audio from a microphone and the ability to play the recorded audio back to the browser. In order to achieve this, we need two TwiML endpoints: one to capture and record the audio, and another one to play the recorded audio.
300+
If `PreflightTest.Options.fakeMicInput` is set to `false`, `Device.runPreflight(token, options)` API requires a [token](https://www.twilio.com/docs/iam/access-tokens) with a TwiML app that can record an audio from a microphone and the ability to play the recorded audio back to the browser. In order to achieve this, we need two TwiML endpoints: one to capture and record the audio, and another one to play the recorded audio.
301301

302302
TwiML Bins
303303
----------
@@ -341,13 +341,13 @@ Creating the TwiML App
341341

342342
Now that we have created our TwiML Bins, let's create our TwiML app by going to the [TwiML Apps](https://www.twilio.com/console/voice/twiml/apps) page. Click the plus button on that screen and enter a friendly name that you prefer. Under Voice request url, enter the **TwiML Bin's Record** url that you created in the previous section, and then click the **Create** button.
343343

344-
On that same page, open the TwiML app that you just created by clicking on it and make note of the `SID`. You can now use this TwiML app to generate your [token](https://www.twilio.com/docs/iam/access-tokens) when calling `Device.testPreflight(token, options)` API.
344+
On that same page, open the TwiML app that you just created by clicking on it and make note of the `SID`. You can now use this TwiML app to generate your [token](https://www.twilio.com/docs/iam/access-tokens) when calling `Device.runPreflight(token, options)` API.
345345

346346

347347
TwiML App - Echo
348348
================
349349

350-
If `PreflightTest.Options.fakeMicInput` is set to `true`, `Device.testPreflight(token, options)` API requires a [token](https://www.twilio.com/docs/iam/access-tokens) with a single TwiML app that can capture and play an audio. Following the [previous steps](#twiml-bins), create a TwiML Bin using the following template, and name it `Echo`.
350+
If `PreflightTest.Options.fakeMicInput` is set to `true`, `Device.runPreflight(token, options)` API requires a [token](https://www.twilio.com/docs/iam/access-tokens) with a single TwiML app that can capture and play an audio. Following the [previous steps](#twiml-bins), create a TwiML Bin using the following template, and name it `Echo`.
351351

352352
```xml
353353
<?xml version="1.0" encoding="UTF-8"?>

lib/twilio/preflight/preflight.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ export namespace PreflightTest {
806806
*
807807
* ```ts
808808
* import Client from 'twilio';
809-
* import { Device } from 'twilio-client';
809+
* import { Device } from '@twilio/voice-sdk';
810810
*
811811
* // Generate the STUN and TURN server credentials with a ttl of 120 seconds
812812
* const client = Client(twilioAccountSid, authToken);

0 commit comments

Comments
 (0)