Suggestions

close search

OT

Methods Events 

The first step in using the OpenTok API is to call the OT.initSession() method. Other methods of the OT object check for system requirements and set up error logging.

Methods

Name Description
(static) addEventListener(type, listener) This method is deprecated.
(static) checkScreenSharingCapability(callback) Checks for support for publishing screen-sharing streams on the client browser.
(static) checkSystemRequirements() → {Number} Checks if the system supports OpenTok for WebRTC.
(static) getDevices(callback) Enumerates the audio input devices (such as microphones) and video input devices (cameras) available to the browser.
(static) initPublisher(targetElement, properties, completionHandler) → {Publisher}

Initializes and returns a Publisher object.

(static) initSession(apiKey, sessionId) → {Session}

Initializes and returns the local session object for a specified session ID.

(static) log(message) Sends a string to the debugger console.
(static) off(type, handler, context) Removes an event handler.
(static) on(type, handler, context) Adds an event handler function for one or more events.
(static) once(type, handler, context) Adds an event handler function for an event.
(static) registerScreenSharingExtension(kind, id, version) Register a Chrome extension for screen-sharing support.
(static) removeEventListener(type, listener) This method is deprecated.
(static) reportIssue(completionHandler) Report that your app experienced an issue.
(static) setLogLevel(logLevel) Sets the API log level.
(static) upgradeSystemRequirements() Displays information about system requirments for OpenTok for WebRTC.

(static) addEventListener(type, listener)

This method is deprecated. Use on() or once() instead.

Registers a method as an event listener for a specific event.

The OT object dispatches one type of event — an exception event. The following code adds an event listener for the exception event:

OT.addEventListener("exception", exceptionHandler);

function exceptionHandler(event) {
   alert("exception event. \n  code == " + event.code + "\n  message == " + event.message);
}

If a handler is not registered for an event, the event is ignored locally. If the event listener function does not exist, the event is ignored locally.

Throws an exception if the listener name is invalid.

Parameters:
Name Type Description
type String The string identifying the type of event.
listener function The function to be invoked when the OT object dispatches the event.
See:

(static) checkScreenSharingCapability(callback)

Checks for support for publishing screen-sharing streams on the client browser. The object passed to the callback function defines whether screen sharing is supported, as well as whether an extension is required, installed, and registered (if needed).

OT.checkScreenSharingCapability(function(response) {
  if (!response.supported || response.extensionRegistered === false) {
    // This browser does not support screen sharing
  } else if (response.extensionInstalled === false) {
    // Prompt to install the extension
  } else {
    // Screen sharing is available.
  }
});

To publish a screen-sharing video in Chrome or Firefox, the client adds an extension that enables publishing a screen-sharing video stream on your domain. The OpenTok plugin for Internet Explorer has screen-sharing capabilities built-in. The OpenTok screensharing-extensions sample includes code for creating Chrome and Firefox extensions for screen-sharing support.

For support in Firefox, instead of using an extension, you can have Mozilla add your domain to the Firefox screen-sharing whitelist.

For more information, see the OpenTok Screen Sharing developer guide.

Parameters:
Name Type Description
callback function The callback invoked with the support options object passed as the parameter. This object has the following properties that indicate support for publishing screen-sharing streams in the client:

  • extensionInstalled (Boolean) — In Chrome, this is set to true if the extension is installed and registered. In Firefox, this is set to true if the extension is installed and it is set to work in the current page's domain. (This requires the Firefox extension to be built using the version of the OpenTok screen-sharing extension released with OpenTok.js 2.8.0 or later. For previous versions of the extension, the extensionInstalled property is always false in Firefox.) However, if you register the domain in the Firefox screen-sharing whitelist (instead using a Firefox screen-sharing extension), this property is set to false; check the client's Firefox version (navigator.userAgent.match(/Firefox\/(\d+)/i)[1]) to see if it is greater than or equal to the version in which your domain was added to the Firefox whitelist. This property is undefined in Internet Explorer.
  • supported (Boolean) — Set to true if screen sharing is supported in the browser. Check the extensionRequired property to see if the browser requires an extension for screen sharing.
  • supportedSources (Object) — An object with the following properties: application, screen, and window. Each property is a Boolean value indicating support. In Firefox, each of these properties is set to true. Currently in Chrome, only the screen property is set to true. In Internet Explorer (using the OpenTok plugin), only screen and window are set to true.

The options parameter also includes the following properties, which apply to screen-sharing support in Chrome (in all other browsers these properties are undefined):

  • extensionRequired (String) — Set to "chrome" in Chrome, which requires a screen-sharing extension to be installed. This property is undefined in other browsers.
  • extensionRegistered (Boolean) — In Chrome, this property is set to true if a screen-sharing extension is registered; otherwise it is set to false. In other browsers (which do not require an extension), this property is undefined. Use the OT.registerScreenSharingExtension() method to register a screen-sharing extension in Chrome.

See:

(static) checkSystemRequirements() → {Number}

Checks if the system supports OpenTok for WebRTC. Note that this method is called automatically when you call OT.initPublisher() or OT.initSession(), and if the system doesn't support OpenTok, the OpenTok.js library displays a message to the user. Call the OT.checkSystemRequirements() method before calling OT.initPublisher() or OT.initSession() if you do not want the library to display that message.
See:
Returns:
Whether the system supports OpenTok for WebRTC (1) or not (0).

(static) getDevices(callback)

Enumerates the audio input devices (such as microphones) and video input devices (cameras) available to the browser.

The array of devices is passed in as the devices parameter of the callback function passed into the method.

Parameters:
Name Type Description
callback function The callback function invoked when the list of devices devices is available. This function takes two parameters:
  • error — This is set to an error object when there is an error in calling this method; it is set to null when the call succeeds.
  • devices — An array of objects corresponding to available microphones and cameras. Each object has three properties: kind, deviceId, and label, each of which are strings.

    The kind property is set to "audioInput" for audio input devices or "videoInput" for video input devices.

    The deviceId property is a unique ID for the device. You can pass the deviceId in as the audioSource or videoSource property of the options parameter of the OT.initPublisher() method.

    The label property identifies the device. The label property is set to an empty string if the user has not previously granted access to a camera and microphone. In HTTP, the user must have granted access to a camera and microphone in the current page (for example, in response to a call to OT.initPublisher()). In HTTPS, the user must have previously granted access to the camera and microphone in the current page or in a page previously loaded from the domain.

See:

(static) initPublisher(targetElement, properties, completionHandler) → {Publisher}

Initializes and returns a Publisher object. You can then pass this Publisher object to Session.publish() to publish a stream to a session.

Note: If you intend to reuse a Publisher object created using OT.initPublisher() to publish to different sessions sequentially, call either Session.disconnect() or Session.unpublish(). Do not call both. Then call the preventDefault() method of the streamDestroyed or sessionDisconnected event object to prevent the Publisher object from being removed from the page.

Parameters:
Name Type Description
targetElement Object (Optional) The DOM element or the id attribute of the existing DOM element used to determine the location of the Publisher video in the HTML DOM. See the insertMode property of the properties parameter. If you do not specify a targetElement, the application appends a new DOM element to the HTML body.

The application throws an error if an element with an ID set to the targetElement value does not exist in the HTML DOM.

properties Object (Optional) This object contains the following properties (each of which are optional):

  • audioFallbackEnabled (String) — Whether the stream will use the audio-fallback feature (true) or not (false). The audio-fallback feature is available in sessions that use the OpenTok Media Router. With the audio-fallback feature enabled (the default), when the server determines that a stream's quality has degraded significantly for a specific subscriber, it disables the video in that subscriber in order to preserve audio quality. For streams that use a camera as a video source, the default setting is true (the audio-fallback feature is enabled). The default setting is false (the audio-fallback feature is disabled) for screen-sharing streams, which have the videoSource property set to "application", "screen", or "window" in the OT.initPublisher() options. For more information, see the Subscriber videoDisabled event and the OpenTok Media Router and media modes.
  • audioSource (String) — The ID of the audio input device (such as a microphone) to be used by the publisher. You can obtain a list of available devices, including audio input devices, by calling the OT.getDevices() method. Each device listed by the method has a unique device ID. If you pass in a device ID that does not match an existing audio input device, the call to OT.initPublisher() fails with an error (error code 1500, "Unable to Publish") passed to the completion handler function.

    If you set this property to null or false, the browser does not request access to the microphone, and no audio is published.

  • fitMode (String) — Determines how the video is displayed if the its dimensions do not match those of the DOM element. You can set this property to one of the following values:

    • "cover" — The video is cropped if its dimensions do not match those of the DOM element. This is the default setting for videos publishing a camera feed.
    • "contain" — The video is letterboxed if its dimensions do not match those of the DOM element. This is the default setting for screen-sharing videos.

  • frameRate (Number) — The desired frame rate, in frames per second, of the video. Valid values are 30, 15, 7, and 1. The published stream will use the closest value supported on the publishing client. The frame rate can differ slightly from the value you set, depending on the browser of the client. And the video will only use the desired frame rate if the client configuration supports it.

    If the publisher specifies a frame rate, the actual frame rate of the video stream is set as the frameRate property of the Stream object, though the actual frame rate will vary based on changing network and system conditions. If the developer does not specify a frame rate, this property is undefined.

    For sessions that use the OpenTok Media Router (sessions with the media mode set to routed, lowering the frame rate proportionally reduces the maximum bandwidth the stream uses. However, in sessions with the media mode set to relayed, lowering the frame rate does not reduce the stream's bandwidth.

    You can also restrict the frame rate of a Subscriber's video stream. To restrict the frame rate a Subscriber, call the restrictFrameRate() method of the subscriber, passing in true. (See Subscriber.restrictFrameRate().)

  • height (Number) — The desired initial height of the displayed Publisher video in the HTML page (default: 198 pixels). You can specify the number of pixels as either a number (such as 300) or a string ending in "px" (such as "300px"). Or you can specify a percentage of the size of the parent element, with a string ending in "%" (such as "100%"). Note: To resize the publisher video, adjust the CSS of the publisher's DOM element (the element property of the Publisher object) or (if the height is specified as a percentage) its parent DOM element (see Resizing or repositioning a video).
  • insertDefaultUI (Boolean) — Whether to use the default OpenTok UI (true, the default) or not (false). The default UI element contains user interface controls, a video loading indicator, and automatic video cropping or letterboxing, in addition to the video. (If you leave insertDefaultUI set to true, you can control individual UI settings using the fitMode, showControls, and style options.)

    If you set this option to false, OpenTok.js does not insert a default UI element in the HTML DOM, and the element property of the Publisher object is undefined. Instead, the Publisher object dispatches a videoElementCreated event when the video element (or in Internet Explorer the object element containing the video) is created. The element property of the event object is a reference to the Publisher's video (or object) element. Add it to the HTML DOM to display the video.

    Set this option to false if you want to move the Publisher's video (or object) element in the HTML DOM.

    If you set this to false, do not set the targetElement parameter. (This results in an error passed into to the OT.initPublisher() callback function.) To add the video to the HTML DOM, add an event listener for the videoElementCreated event, and then add the element property of the event object into the HTML DOM.

  • insertMode (String) — Specifies how the Publisher object will be inserted in the HTML DOM. See the targetElement parameter. This string can have the following values:

    • "replace" — The Publisher object replaces contents of the targetElement. This is the default.
    • "after" — The Publisher object is a new element inserted after the targetElement in the HTML DOM. (Both the Publisher and targetElement have the same parent element.)
    • "before" — The Publisher object is a new element inserted before the targetElement in the HTML DOM. (Both the Publisher and targetElement have the same parent element.)
    • "append" — The Publisher object is a new element added as a child of the targetElement. If there are other child elements, the Publisher is appended as the last child element of the targetElement.

    Do not move the publisher element or its parent elements in the DOM heirarchy. Use CSS to resize or reposition the publisher video's element (the element property of the Publisher object) or its parent element (see Resizing or repositioning a video.

  • maxResolution (Object) — Sets the maximum resolution to stream. This setting only applies to when the videoSource property is set to "application", "screen", or "window" (when the publisher is screen-sharing). The resolution of the stream will match the captured screen region unless the region is greater than the maxResolution setting. Set this to an object that has two properties: width and height (both numbers). The maximum value for each of the width and height properties is 1920, and the minimum value is 10.
  • mirror (Boolean) — Whether the publisher's video image is mirrored in the publisher's page. The default value is true (the video image is mirrored), except for a screen-sharing video (when the videoSource property is set to "application", "screen", or "window" (in which case the default is false). This property does not affect the display on subscribers' views of the video.
  • name (String) — The name for this stream. The name appears at the bottom of Subscriber videos. The default value is "" (an empty string). Setting this to a string longer than 1000 characters results in an runtime exception.
  • publishAudio (Boolean) — Whether to initially publish audio for the stream (default: true). This setting applies when you pass the Publisher object in a call to the Session.publish() method.
  • publishVideo (Boolean) — Whether to initially publish video for the stream (default: true). This setting applies when you pass the Publisher object in a call to the Session.publish() method.
  • resolution (String) — The desired resolution of the video. The format of the string is "widthxheight", where the width and height are represented in pixels. Valid values are "1280x720", "640x480", and "320x240". The published video will only use the desired resolution if the client configuration supports it. Some browsers and clients do not support each of these resolution settings.

    The requested resolution of a video stream is set as the videoDimensions.width and videoDimensions.height properties of the Stream object.

    The default resolution for a stream (if you do not specify a resolution) is 640x480 pixels. If the client system cannot support the resolution you requested, the stream will use the next largest setting supported.

    The actual resolution used by the Publisher is returned by the videoHeight() and videoWidth() methods of the Publisher object. The actual resolution of a Subscriber video stream is returned by the videoHeight() and videoWidth() properties of the Subscriber object. These may differ from the values of the resolution property passed in as the properties property of the OT.initPublisher() method, if the browser does not support the requested resolution.

  • showControls (Boolean) — Whether to display the built-in user interface controls (default: true) for the Publisher. These controls include the name display, the audio level indicator, and the microphone control button. You can turn off all user interface controls by setting this property to false. You can control the display of individual user interface controls by leaving this property set to true (the default) and setting individual properties of the style property.
  • style (Object) — An object containing properties that define the initial appearance of user interface controls of the Publisher. The style object includes the following properties:
    • audioLevelDisplayMode (String) — How to display the audio level indicator. Possible values are: "auto" (the indicator is displayed when the video is disabled), "off" (the indicator is not displayed), and "on" (the indicator is always displayed).
    • archiveStatusDisplayMode (String) — How to display the archive status indicator. Possible values are: "auto" (the indicator is displayed when the session is being recorded), "off" (the indicator is not displayed). If you disable the archive status display indicator, you can display your own user interface notifications based on the archiveStarted and archiveStopped events dispatched by the Session object.
    • backgroundImageURI (String) — A URI for an image to display as the background image when a video is not displayed. (A video may not be displayed if you call publishVideo(false) on the Publisher object). You can pass an http or https URI to a PNG, JPEG, or non-animated GIF file location. You can also use the data URI scheme (instead of http or https) and pass in base-64-encrypted PNG data, such as that obtained from the Publisher.getImgData() method. (For example, you could set the property to a value returned by calling getImgData() on a previous Publisher object.) If the URL or the image data is invalid, the property is ignored (the attempt to set the image fails silently).
    • buttonDisplayMode (String) — How to display the microphone controls Possible values are: "auto" (controls are displayed when the stream is first displayed and when the user mouses over the display), "off" (controls are not displayed), and "on" (controls are always displayed).
    • nameDisplayMode (String) — Whether to display the stream name. Possible values are: "auto" (the name is displayed when the stream is first displayed and when the user mouses over the display), "off" (the name is not displayed), and "on" (the name is always displayed).
  • usePreviousDeviceSelection (Boolean) — Used by the OpenTok Plugin for Internet Explorer only. When this is set to true), the Plugin uses the previously selected camera and microphone (from previous visits to a page in the same domain), if there are any. When set to false (the default) the Plugin prompts the user to select the the camera and microphone to use (regardless of a previous selection). This setting only applies to pages loaded over HTTPS. In HTTP, the Plugin always prompts the user to select the camera and microphone to use.
  • videoSource (String) — The ID of the video input device (such as a camera) to be used by the publisher. You can obtain a list of available devices, including video input devices, by calling the OT.getDevices() method. Each device listed by the method has a unique device ID. If you pass in a device ID that does not match an existing video input device, the call to OT.initPublisher() fails with an error (error code 1500, "Unable to Publish") passed to the completion handler function.

    If you set this property to null or false, the browser does not request access to the camera, and no video is published. In a voice-only call, set this property to null or false for each Publisher.

    To publish a screen-sharing stream, set this property to "application", "screen", or "window". Call OT.checkScreenSharingCapability() to check if screen sharing is supported. When you set the videoSource property to "application", "screen", or "window", the following are default values for other properties: audioFallbackEnabled == false, maxResolution == {width: 1920, height: 1920}, mirror == false, scaleMode == "fit". Also, the default scaleMode setting for subscribers to the stream is "fit".

  • width (Number) — The desired initial width of the displayed Publisher video in the HTML page (default: 264 pixels). You can specify the number of pixels as either a number (such as 400) or a string ending in "px" (such as "400px"). Or you can specify a percentage of the size of the parent element, with a string ending in "%" (such as "100%"). Note: To resize the publisher video, adjust the CSS of the publisher's DOM element (the element property of the Publisher object) or (if the width is specified as a percentage) its parent DOM element (see Resizing or repositioning a video).
completionHandler function (Optional) A function to be called when the method succeeds or fails in initializing a Publisher object. This function takes one parameter — error. On success, the error object is set to null. On failure, the error object has two properties: code (an integer) and message (a string), which identify the cause of the failure. The method succeeds when the user grants access to the camera and microphone. The method fails if the user denies access to the camera and microphone. The completionHandler function is called before the Publisher dispatches an accessAllowed (success) event or an accessDenied (failure) event.

The following code adds a completionHandler when calling the OT.initPublisher() method:

var publisher = OT.initPublisher('publisher', null, function (error) {
  if (error) {
    console.log(error);
  } else {
    console.log("Publisher initialized.");
  }
});
See:
Returns:
The Publisher object.

(static) initSession(apiKey, sessionId) → {Session}

Initializes and returns the local session object for a specified session ID.

You connect to an OpenTok session using the connect() method of the Session object returned by the OT.initSession() method. Note that calling OT.initSession() does not initiate communications with the cloud. It simply initializes the Session object that you can use to connect (and to perform other operations once connected).

Note that you can initialize only one Session object per session ID. Calling OT.initSession() a second time with the same session ID returns the previously created Session object. However, you can initialize multiple Session objects for different sessions (with different session IDs) to connect to multiple sessions.

When the client disconnects from the session (and the session dispatches a sessionDisconnected event), you can reuse the Session object to reconnect to the session. However, the Session object will retain any existing event handlers attached to it. You can remove all event handlers by calling the off() method of the Session object (passing in no parameters).

For an example, see Session.connect().

Parameters:
Name Type Description
apiKey String Your OpenTok API key (see your TokBox account page).
sessionId String The session ID identifying the OpenTok session. For more information, see Session creation.
Returns:
The session object through which all further interactions with the session will occur.

(static) log(message)

Sends a string to the debugger console. However, the function only logs to the console if you have set the log level to OT.LOG or OT.DEBUG, by calling OT.setLogLevel(OT.LOG) or OT.setLogLevel(OT.DEBUG).
Parameters:
Name Type Description
message String The string to log.
See:

(static) off(type, handler, context)

Removes an event handler.

Pass in an event name and a handler method, the handler is removed for that event:

OT.off("exceptionEvent", exceptionEventHandler);

If you pass in an event name and no handler method, all handlers are removed for that events:

OT.off("exceptionEvent");

The method also supports an alternate syntax, in which the first parameter is an object that is a hash map of event names and handler functions and the second parameter (optional) is the context for matching handlers:

OT.off(
  {
    exceptionEvent: exceptionEventHandler
  },
  this
);
Parameters:
Name Type Description
type String (Optional) The string identifying the type of event. You can use a space to specify multiple events, as in "eventName1 eventName2 eventName3". If you pass in no type value (or other arguments), all event handlers are removed for the object.
handler function (Optional) The event handler function to remove. If you pass in no handler, all event handlers are removed for the specified event type.
context Object (Optional) If you specify a context, the event handler is removed for all specified events and handlers that use the specified context.
See:

(static) on(type, handler, context)

Adds an event handler function for one or more events.

The OT object dispatches one type of event — an exception event. The following code adds an event listener for the exception event:

OT.on("exception", function (event) {
  // This is the event handler.
});

You can also pass in a third context parameter (which is optional) to define the value of this in the handler method:

OT.on("exception",
  function (event) {
    // This is the event handler.
  }),
  session
);

If you do not add a handler for an event, the event is ignored locally.

Parameters:
Name Type Description
type String The string identifying the type of event.
handler function The handler function to process the event. This function takes the event object as a parameter.
context Object (Optional) Defines the value of this in the event handler function.
See:

(static) once(type, handler, context)

Adds an event handler function for an event. Once the handler is called, the specified handler method is removed as a handler for this event. (When you use the OT.on() method to add an event handler, the handler is not removed when it is called.) The OT.once() method is the equivilent of calling the OT.on() method and calling OT.off() the first time the handler is invoked.

The following code adds a one-time event handler for the exception event:

OT.once("exception", function (event) {
  console.log(event);
}

You can also pass in a third context parameter (which is optional) to define the value of this in the handler method:

OT.once("exception",
  function (event) {
    // This is the event handler.
  },
  session
);

The method also supports an alternate syntax, in which the first parameter is an object that is a hash map of event names and handler functions and the second parameter (optional) is the context for this in each handler:

OT.once(
  {exeption: function (event) {
    // This is the event handler.
    }
  },
  session
);
Parameters:
Name Type Description
type String The string identifying the type of event. You can specify multiple event names in this string, separating them with a space. The event handler will process the first occurence of the events. After the first event, the handler is removed (for all specified events).
handler function The handler function to process the event. This function takes the event object as a parameter.
context Object (Optional) Defines the value of this in the event handler function.
See:

(static) registerScreenSharingExtension(kind, id, version)

Register a Chrome extension for screen-sharing support.

Use the OT.checkScreenSharingCapability() method to check if an extension is required, registered, and installed.

The OpenTok screensharing-extensions repo includes code for creating an extension for screen-sharing support.

Parameters:
Name Type Description
kind String Set this parameter to "chrome". Currently, you can only register a screen-sharing extension for Chrome.
id String The ID for your Chrome screen-sharing extension. You can find this ID at chrome://extensions.
version Number The version of the Chrome screen-sharing extension from the screensharing-extensions repo. Set this if you are using version 2 or later. For example, if you are using version 2, set this to 2. With version 2, the client can use the extension immediately after installing it, without reloading the page.
See:

(static) removeEventListener(type, listener)

This method is deprecated. Use off() instead.

Removes an event listener for a specific event.

Throws an exception if the listener name is invalid.

Parameters:
Name Type Description
type String The string identifying the type of event.
listener function The event listener function to remove.
See:

(static) reportIssue(completionHandler)

Report that your app experienced an issue. You can use the issue ID with Inspector or when discussing an issue with the TokBox support team.
Parameters:
Name Type Description
completionHandler function A function that is called when the call to this method succeeds or fails. This function has two parameters. The first parameter is an Error object that is set when the call to the reportIssue() method fails (for example, if the client is not connected to the network) or null when the call to the reportIssue() method succeeds. The second parameter is set to the report ID (a unique string) when the call succeeds.

(static) setLogLevel(logLevel)

Sets the API log level.

Calling OT.setLogLevel() sets the log level for runtime log messages that are the OpenTok library generates. The default value for the log level is OT.ERROR.

The OpenTok JavaScript library displays log messages in the debugger console (such as Firebug), if one exists.

The following example logs the session ID to the console, by calling OT.log(). The code also logs an error message when it attempts to publish a stream before you have connected to the session (by calling Session.connect()).

OT.setLogLevel(OT.LOG);
session = OT.initSession(sessionId);
OT.log(sessionId);
publisher = OT.initPublisher("publishContainer");
session.publish(publisher);
Parameters:
Name Type Description
logLevel Number The degree of logging desired by the developer:

  • OT.NONE — API logging is disabled.
  • OT.ERROR — Logging of errors only.
  • OT.WARN — Logging of warnings and errors.
  • OT.INFO — Logging of other useful information, in addition to warnings and errors.
  • OT.LOG — Logging of OT.log() messages, in addition to OpenTok info, warning, and error messages.
  • OT.DEBUG — Fine-grained logging of all API actions, as well as OT.log() messages.

See:

(static) upgradeSystemRequirements()

Displays information about system requirments for OpenTok for WebRTC. This information is displayed in an iframe element that fills the browser window.

Note: this information is displayed automatically when you call the OT.initSession() or the OT.initPublisher() method if the client does not support OpenTok for WebRTC.

See:

Events

exception

Dispatched by the OT class when the app encounters an exception. Note that you set up an event handler for the exception event by calling the OT.on() method.
See: