disconnect()
method of the session object.
Example
The following code initializes a session and sets up an event listener for when a session is disconnected.
var apiKey = ""; // Replace with your API key. See https://dashboard.nexmo.com
var sessionID = ""; // Replace with your own session ID.
// See https://developer.vonage.com/en/video/guides/create-session/
var token = ""; // Replace with a generated token that has been assigned the moderator role.
// See https://developer.vonage.com/en/video/guides/create-token/
var session = OT.initSession(apiKey, sessionID);
session.on("sessionDisconnected", function(event) {
alert("The session disconnected. " + event.reason);
});
session.connect(token);
Properties
Name | Type | Description |
---|---|---|
reason |
String |
A description of why the session disconnected. This property
can have the following values:
|
Methods
Name | Description |
---|---|
isDefaultPrevented
()
→ {Boolean}
|
Whether the default event behavior has been prevented via a
call to
preventDefault()
(
true
) or not (
false
).
|
preventDefault
()
|
Prevents the default behavior associated with the event from taking place. |
isDefaultPrevented () → {Boolean}
preventDefault()
(
true
) or not (
false
). See
preventDefault()
.
Returns:
preventDefault ()
For the
sessionDisconnectEvent
, the default behavior is that all Subscriber objects are
unsubscribed and removed from the HTML DOM. Each Subscriber object
dispatches a
destroyed
event when the element is removed from the HTML DOM. If you call
the
preventDefault()
method in the event listener for the
sessionDisconnect
event, the default behavior is prevented, and you can, optionally,
clean up Subscriber objects using your own code).
To see whether an event has a default behavior, check the
cancelable
property of the event object.
Call the
preventDefault()
method in the event listener function for the event.