Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ typings/
.env

# build files
dist/
# dist/

# env
.env
Expand All @@ -72,4 +72,4 @@ sample/node_modules
/test/credentials.json

# We're using npm (at least for now)
yarn.lock
yarn.lock
82 changes: 43 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,25 @@ The `OTNetworkTest()` constructor includes the following parameters:
will be used in the real OpenTok session. This way, the test prompts the end user
to grant permission to the correct device. Note that changing the video device may not
influence the quality test score.
* `initSessionOptions` (Object) -- An object that includes optional options
for initializing the session
([Session Options](https://tokbox.com/developer/sdks/js/reference/OT.html#initSession)).

* `initSessionOptions` (Object) -- An object that includes optional options
for initializing the session
([Session Options](https://tokbox.com/developer/sdks/js/reference/OT.html#initSession)).
This object includes the following properties:
* `ipWhitelist ` (Boolean) -- This is available as an add-on feature
for **enterprise accounts**. Set this to true if IP white listing
is enabled for your project. The default value is false.
for **enterprise accounts**. Set this to true if IP white listing
is enabled for your project. The default value is false.
* `iceConfig ` (Object) -- This feature is part of the configurable TURN add-on feature.

* `proxyServerUrl` (String) -- (Optional) Set this to the proxy server URL
* `proxyServerUrl` (String) -- (Optional) Set this to the proxy server URL
you use in the OpenTok client SDKs (for example, when calling `OT.setProxyUrl()`
in OpenTok.js). For more information, please check the
in OpenTok.js). For more information, please check the
[IP Proxy Documentation](https://tokbox.com/developer/guides/ip-proxy/).

* `skipPublisherCleaningOnSuccess` (Boolean) -- (Optional) On iOS if a publisher is displayed
while the tests are running, the publisher turns black once the tests are done.
this switch allows you to skip cleaning the publisher in the normal publisher flow.

The `options` parameter is optional.

The constructor throws an Error object with a `message` property and a `name` property. The
Expand Down Expand Up @@ -505,7 +509,7 @@ an error object (against the values defined in ErrorNames) to determine the type
| ------------------------------------------------------------------ | ----------- |
| `MISSING_OPENTOK_INSTANCE` | An instance of OT, the OpenTok.js client SDK, was not passed into the constructor. |
| `INCOMPLETE_SESSON_CREDENTIALS` | The sessionInfo object passed into the constructor did not include an `apiKey`, `sessionId`, or `token` object. |
| `MISSING_SESSON_CREDENTIALS` | No sessionInfo object was passed into the constructor. |
| `MISSING_SESSON_CREDENTIALS` | No sessionInfo object was passed into the constructor. |

#### testConnectivity() errors

Expand All @@ -516,22 +520,22 @@ the following:

| Error.name property set to this property<br/>of ErrorNames ... | Description |
| -------------------------------------------------------------- | ----------- |
| `API_CONNECTIVITY_ERROR` | The test failed to connect to OpenTOK API Server. |
| `CONNECT_TO_SESSION_ERROR` | The test failed to connect to the test OpenTok session due to a network error. |
| `CONNECT_TO_SESSION_TOKEN_ERROR` | The test failed to connect to the test OpenTok session due to an invalid token. |
| `CONNECT_TO_SESSION_ID_ERROR` | The test failed to connect to the test OpenTok session due to an invalid session ID. |
| `CONNECT_TO_SESSION_NETWORK_ERROR` | The test failed to connect to the test OpenTok session due to a network error. |
| `FAILED_TO_OBTAIN_MEDIA_DEVICES` | The test failed to obtain media devices (a camera or microphone). |
| `NO_AUDIO_CAPTURE_DEVICES` | The browser cannot access a microphone. |
| `NO_VIDEO_CAPTURE_DEVICES` | The browser cannot access a camera. |
| `PUBLISH_TO_SESSION_ERROR` | Encountered an unknown error while attempting to publish to a session. |
| `FAILED_MESSAGING_SERVER_TEST` | The test failed to connect to media server due to messaging server connection failure. |
| `FAILED_TO_CREATE_LOCAL_PUBLISHER` | The test failed to create a local publisher object. |
| `PUBLISH_TO_SESSION_NOT_CONNECTED` | The test failed to publish to the test session because the client was not connected to the session. |
| `PUBLISH_TO_SESSION_PERMISSION_OR_TIMEOUT_ERROR` | The test failed to publish to the test session due a permissions error or timeout. |
| `PUBLISH_TO_SESSION_NETWORK_ERROR` | The test failed to publish to the test session due a network error. |
| `SUBSCRIBE_TO_SESSION_ERROR` | The test encountered an unknown error while attempting to subscribe to a test stream. |
| `LOGGING_SERVER_CONNECTION_ERROR` | The test failed to connect to the OpenTok logging server. |
| `API_CONNECTIVITY_ERROR` | The test failed to connect to OpenTOK API Server. |
| `CONNECT_TO_SESSION_ERROR` | The test failed to connect to the test OpenTok session due to a network error. |
| `CONNECT_TO_SESSION_TOKEN_ERROR` | The test failed to connect to the test OpenTok session due to an invalid token. |
| `CONNECT_TO_SESSION_ID_ERROR` | The test failed to connect to the test OpenTok session due to an invalid session ID. |
| `CONNECT_TO_SESSION_NETWORK_ERROR` | The test failed to connect to the test OpenTok session due to a network error. |
| `FAILED_TO_OBTAIN_MEDIA_DEVICES` | The test failed to obtain media devices (a camera or microphone). |
| `NO_AUDIO_CAPTURE_DEVICES` | The browser cannot access a microphone. |
| `NO_VIDEO_CAPTURE_DEVICES` | The browser cannot access a camera. |
| `PUBLISH_TO_SESSION_ERROR` | Encountered an unknown error while attempting to publish to a session. |
| `FAILED_MESSAGING_SERVER_TEST` | The test failed to connect to media server due to messaging server connection failure. |
| `FAILED_TO_CREATE_LOCAL_PUBLISHER` | The test failed to create a local publisher object. |
| `PUBLISH_TO_SESSION_NOT_CONNECTED` | The test failed to publish to the test session because the client was not connected to the session. |
| `PUBLISH_TO_SESSION_PERMISSION_OR_TIMEOUT_ERROR` | The test failed to publish to the test session due a permissions error or timeout. |
| `PUBLISH_TO_SESSION_NETWORK_ERROR` | The test failed to publish to the test session due a network error. |
| `SUBSCRIBE_TO_SESSION_ERROR` | The test encountered an unknown error while attempting to subscribe to a test stream. |
| `LOGGING_SERVER_CONNECTION_ERROR` | The test failed to connect to the OpenTok logging server. |

#### testQuality() errors

Expand All @@ -541,20 +545,20 @@ method has a `name` property set to one of the following:
| Error.name property set to this<br/>property of ErrorNames ... | Description |
| -------------------------------------------------------------- | ----------- |
| `INVALID_ON_UPDATE_CALLBACK` | The `updateCallback` parameter is invalid. It must be a function that accepts a single parameter. |
| `UNSUPPORTED_BROWSER` | The test is running on an unsupported browser (see [Supported browsers](#supported-browsers)). |
| `CONNECT_TO_SESSION_ERROR` | The test failed to connect to the test OpenTok session due to a network error. |
| `CONNECT_TO_SESSION_TOKEN_ERROR` | The test failed to connect to the test OpenTok session due to an invalid token. |
| `CONNECT_TO_SESSION_ID_ERROR` | The test failed to connect to the test OpenTok session due to an invalid session ID. |
| `CONNECT_TO_SESSION_NETWORK_ERROR` | The test failed to connect to the test OpenTok session due to a network error. |
| `FAILED_TO_OBTAIN_MEDIA_DEVICES` | The test failed to obtain media devices (a camera or microphone). |
| `NO_AUDIO_CAPTURE_DEVICES` | The browser cannot access a microphone. |
| `NO_VIDEO_CAPTURE_DEVICES` | The browser cannot access a camera. |
| `PUBLISH_TO_SESSION_ERROR` | The test encountered an unknown error while attempting to publish to a session. |
| `INIT_PUBLISHER_ERROR` | The test failed to initialize a publisher. |
| `PUBLISH_TO_SESSION_NOT_CONNECTED` | The test failed to publish to the test session because the client was not connected to the session. |
| `PUBLISH_TO_SESSION_PERMISSION_OR_TIMEOUT_ERROR` | The test failed to publish to the test session due a permissions error or timeout. |
| `SUBSCRIBE_TO_SESSION_ERROR` | The test encountered an unknown error while attempting to subscribe to a test stream. |
| `SUBSCRIBER_GET_STATS_ERROR` | The test failed to get audio and video statistics for the test stream. |
| `UNSUPPORTED_BROWSER` | The test is running on an unsupported browser (see [Supported browsers](#supported-browsers)). |
| `CONNECT_TO_SESSION_ERROR` | The test failed to connect to the test OpenTok session due to a network error. |
| `CONNECT_TO_SESSION_TOKEN_ERROR` | The test failed to connect to the test OpenTok session due to an invalid token. |
| `CONNECT_TO_SESSION_ID_ERROR` | The test failed to connect to the test OpenTok session due to an invalid session ID. |
| `CONNECT_TO_SESSION_NETWORK_ERROR` | The test failed to connect to the test OpenTok session due to a network error. |
| `FAILED_TO_OBTAIN_MEDIA_DEVICES` | The test failed to obtain media devices (a camera or microphone). |
| `NO_AUDIO_CAPTURE_DEVICES` | The browser cannot access a microphone. |
| `NO_VIDEO_CAPTURE_DEVICES` | The browser cannot access a camera. |
| `PUBLISH_TO_SESSION_ERROR` | The test encountered an unknown error while attempting to publish to a session. |
| `INIT_PUBLISHER_ERROR` | The test failed to initialize a publisher. |
| `PUBLISH_TO_SESSION_NOT_CONNECTED` | The test failed to publish to the test session because the client was not connected to the session. |
| `PUBLISH_TO_SESSION_PERMISSION_OR_TIMEOUT_ERROR` | The test failed to publish to the test session due a permissions error or timeout. |
| `SUBSCRIBE_TO_SESSION_ERROR` | The test encountered an unknown error while attempting to subscribe to a test stream. |
| `SUBSCRIBER_GET_STATS_ERROR` | The test failed to get audio and video statistics for the test stream. |

## MOS estimates

Expand Down
22 changes: 22 additions & 0 deletions dist/NetworkTest/errors/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @module Errors
*/
/**
* Base class for errors used throughout Network Connectivity tests.
*/
export declare class NetworkTestError extends Error {
name: string;
constructor(message: string, name?: string);
}
export declare class MissingOpenTokInstanceError extends NetworkTestError {
constructor();
}
export declare class IncompleteSessionCredentialsError extends NetworkTestError {
constructor();
}
export declare class MissingSessionCredentialsError extends NetworkTestError {
constructor();
}
export declare class InvalidOnUpdateCallback extends NetworkTestError {
constructor();
}
68 changes: 68 additions & 0 deletions dist/NetworkTest/errors/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* @module Errors/Connectivity/OpenTok
*/
import { OTError } from '../types/opentok/error';
export declare enum ErrorNames {
NETWORK_TEST_ERROR = "NetworkTestError",
MISSING_OPENTOK_INSTANCE = "MissingOpenTokInstanceError",
INCOMPLETE_SESSON_CREDENTIALS = "IncompleteSessionCredentialsError",
MISSING_SESSON_CREDENTIALS = "MissingSessionCredentialsError",
INVALID_ON_UPDATE_CALLBACK = "InvalidOnUpdateCallback",
CONNECTIVITY_ERROR = "ConnectivityError",
API_CONNECTIVITY_ERROR = "APIConnectivityError",
CONNECT_TO_SESSION_ERROR = "ConnectToSessionError",
CONNECT_TO_SESSION_TOKEN_ERROR = "ConnectToSessionTokenError",
CONNECT_TO_SESSION_ID_ERROR = "ConnectToSessionSessionIdError",
CONNECT_TO_SESSION_NETWORK_ERROR = "ConnectToSessionNetworkError",
MEDIA_DEVICE_ERROR = "MediaDeviceError",
FAILED_TO_OBTAIN_MEDIA_DEVICES = "FailedToObtainMediaDevices",
NO_VIDEO_CAPTURE_DEVICES = "NoVideoCaptureDevicesError",
NO_AUDIO_CAPTURE_DEVICES = "NoAudioCaptureDevicesError",
PUBLISH_TO_SESSION_ERROR = "PublishToSessionError",
INIT_PUBLISHER_ERROR = "InitPublisherError",
FAILED_MESSAGING_SERVER_TEST = "FailedMessagingServerTestError",
FAILED_TO_CREATE_LOCAL_PUBLISHER = "FailedToCreateLocalPublisher",
PUBLISH_TO_SESSION_NOT_CONNECTED = "PublishToSessionNotConnectedError",
PUBLISH_TO_SESSION_PERMISSION_OR_TIMEOUT_ERROR = "PublishToSessionPermissionOrTimeoutError",
PUBLISH_TO_SESSION_NETWORK_ERROR = "PublishToSessionNetworkError",
SUBSCRIBE_TO_SESSION_ERROR = "SubscribeToSessionError",
LOGGING_SERVER_CONNECTION_ERROR = "LoggingServerConnectionError",
QUALITY_TEST_ERROR = "QualityTestError",
UNSUPPORTED_BROWSER = "UnsupportedBrowser",
SUBSCRIBER_GET_STATS_ERROR = "SubscriberGetStatsError",
MISSING_SUBSCRIBER_ERROR = "MissingSubscriberError"
}
export declare enum OTErrorType {
JS_EXCEPTION = "JS_EXCEPTION",
OT_AUTHENTICATION_ERROR = "OT_AUTHENTICATION_ERROR",
OT_INVALID_HTTP_STATUS = "OT_INVALID_HTTP_STATUS",
OT_CONNECT_FAILED = "OT_CONNECT_FAILED",
OT_INVALID_SESSION_ID = "OT_INVALID_SESSION_ID",
CONNECT_FAILED = "CONNECT_FAILED",
CONNECT_REJECTED = "CONNECT_REJECTED",
CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT",
NOT_CONNECTED = "NOT_CONNECTED",
INVALID_PARAMETER = "INVALID_PARAMETER",
P2P_CONNECTION_FAILED = "P2P_CONNECTION_FAILED",
API_RESPONSE_FAILURE = "API_RESPONSE_FAILURE",
TERMS_OF_SERVICE_FAILURE = "TERMS_OF_SERVICE_FAILURE",
CONNECTION_LIMIT_EXCEEDED = "CONNECTION_LIMIT_EXCEEDED",
UNABLE_TO_PUBLISH = "UNABLE_TO_PUBLISH",
UNABLE_TO_SUBSCRIBE = "UNABLE_TO_SUBSCRIBE",
UNSUPPORTED_VIDEO_CODEC = "UNSUPPORTED_VIDEO_CODEC",
UNABLE_TO_FORCE_DISCONNECT = "UNABLE_TO_FORCE_DISCONNECT",
UNABLE_TO_FORCE_UNPUBLISH = "UNABLE_TO_FORCE_UNPUBLISH",
PUBLISHER_ICE_WORKFLOW_FAILED = "PUBLISHER_ICE_WORKFLOW_FAILED",
SUBSCRIBER_ICE_WORKFLOW_FAILED = "SUBSCRIBER_ICE_WORKFLOW_FAILED",
STREAM_LIMIT_EXCEEDED = "STREAM_LIMIT_EXCEEDED",
UNEXPECTED_SERVER_RESPONSE = "UNEXPECTED_SERVER_RESPONSE",
REPORT_ISSUE_ERROR = "REPORT_ISSUE_ERROR",
ANVIL_BADLY_FORMED_RESPONSE = "ANVIL_BADLY_FORMED_RESPONSE",
ANVIL_INVALID_HTTP_STATUS = "ANVIL_INVALID_HTTP_STATUS",
ANVIL_XDOMAIN_OR_PARSING_ERROR = "ANVIL_XDOMAIN_OR_PARSING_ERROR",
ANVIL_UNKNOWN_HTTP_ERROR = "ANVIL_UNKNOWN_HTTP_ERROR",
ANVIL_UNEXPECTED_ERROR_CODE = "ANVIL_UNEXPECTED_ERROR_CODE",
ANVIL_EMPTY_RESPONSE_BODY = "ANVIL_EMPTY_RESPONSE_BODY",
ANVIL_CONNECT_FAILED = "ANVIL_CONNECT_FAILED"
}
export declare const errorHasName: (error: OTError | null | undefined, name: OTErrorType) => boolean;
58 changes: 58 additions & 0 deletions dist/NetworkTest/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @module NetworkTest
*/
import { OT } from './types/opentok';
import { UpdateCallback, UpdateCallbackStats } from './types/callbacks';
import { ConnectivityTestResults } from './testConnectivity';
import { QualityTestResults } from './testQuality';
import OTKAnalytics = require('opentok-solutions-logging');
export interface NetworkTestOptions {
audioOnly?: boolean;
timeout?: number;
audioSource?: string;
videoSource?: string;
initSessionOptions?: OT.InitSessionOptions;
proxyServerUrl?: string;
skipPublisherCleaningOnSuccess?: boolean;
}
export default class NetworkTest {
credentials: OT.SessionCredentials;
OT: OT.Client;
otLogging: OTKAnalytics;
options?: NetworkTestOptions;
/**
* Returns an instance of NetworkConnectivity. See the "API reference" section of the
* README.md file in the root of the opentok-network-test-js project for details.
*/
constructor(OT: OT.Client, credentials: OT.SessionCredentials, options?: NetworkTestOptions);
private validateOT;
private validateCredentials;
private validateProxyUrl;
private setProxyUrl;
private startLoggingEngine;
/**
* This method checks to see if the client can connect to TokBox servers required for
* using OpenTok.
*
* See the "API reference" section of the README.md file in the root of the
* opentok-network-test-js project for details.
*/
testConnectivity(): Promise<ConnectivityTestResults>;
/**
* This function runs a test publisher and based on the measured video bitrate,
* audio bitrate, and the audio packet loss for the published stream, it returns
* results indicating the recommended supported publisher settings.
*
* See the "API reference" section of the README.md file in the root of the
* opentok-network-test-js project for details.
*/
testQuality(updateCallback?: UpdateCallback<UpdateCallbackStats>): Promise<QualityTestResults>;
/**
* Stops the currently running test.
*
* See the "API reference" section of the README.md file in the root of the
* opentok-network-test-js project for details.
*/
stop(): void;
}
export { ErrorNames } from './errors/types';
2 changes: 2 additions & 0 deletions dist/NetworkTest/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/NetworkTest/index.js.map

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions dist/NetworkTest/testConnectivity/errors/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* @module Errors/Connectivity
*/
/**
* Define errors for Connectivity Test
*/
import { NetworkTestError } from '../../errors';
/**
* Base class for errors used throughout Network Connectivity test.
*/
export declare class ConnectivityError extends NetworkTestError {
constructor(message: string, name?: string);
}
/**
* API Connectivity Error
*/
export declare class APIConnectivityError extends ConnectivityError {
constructor();
}
/**
* Session Errors
*/
export declare class ConnectToSessionError extends ConnectivityError {
constructor(message?: string, name?: string);
}
export declare class ConnectToSessionTokenError extends ConnectToSessionError {
constructor();
}
export declare class ConnectToSessionSessionIdError extends ConnectToSessionError {
constructor();
}
export declare class ConnectToSessionNetworkError extends ConnectToSessionError {
constructor();
}
/**
* Missing Device Errors
*/
export declare class MediaDeviceError extends ConnectivityError {
constructor(message?: string, name?: string);
}
export declare class FailedToObtainMediaDevices extends MediaDeviceError {
constructor();
}
export declare class NoVideoCaptureDevicesError extends MediaDeviceError {
constructor();
}
export declare class NoAudioCaptureDevicesError extends MediaDeviceError {
constructor();
}
/**
* Publishing Errors
*/
export declare class PublishToSessionError extends ConnectivityError {
constructor(message?: string, name?: string);
}
export declare class FailedMessagingServerTestError extends PublishToSessionError {
constructor();
}
export declare class FailedToCreateLocalPublisher extends PublishToSessionError {
constructor();
}
export declare class PublishToSessionNotConnectedError extends PublishToSessionError {
constructor();
}
export declare class PublishToSessionPermissionOrTimeoutError extends PublishToSessionError {
constructor();
}
export declare class PublishToSessionNetworkError extends PublishToSessionError {
constructor();
}
/**
* Subscribing Errors
*/
export declare class SubscribeToSessionError extends ConnectivityError {
constructor(message?: string);
}
/**
* Logger Server Error
*/
export declare class LoggingServerConnectionError extends ConnectivityError {
constructor();
}
20 changes: 20 additions & 0 deletions dist/NetworkTest/testConnectivity/errors/mapping.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @module Errors/Connectivity/Mapping
*/
/**
* Map Connectivity Errors to Failure Types
*/
import { ConnectivityError } from './index';
export declare enum FailureType {
Api = "api",
Messaging = "messaging",
OpentokJs = "OpenTok.js",
Media = "media",
Logging = "logging",
ConnectivityError = "OpenTok.js"
}
export declare type FailureCase = {
type: FailureType;
error: ConnectivityError;
};
export declare const mapErrors: (...errors: ConnectivityError[]) => FailureCase[];
Loading