SessionConnectEvent class
The Session object dispatches SessionConnectEvent object when a session has successfully connected in response to a call to the connect() method of the Session object.
SessionConnectEvent properties
The SessionConnectEvent object has the following properties:
archives (Array[Archive])
An array of
Archive objects. Each Archive object represents an archive that is currently being recorded
(at the time you connect to the session). You can check the type property of each Archive
object to see if the archive is "perSession". If it is, then each stream published to the
session is being recorded. Added in OpenTok v0.91.23.
connections (Array[Connection]) An array of Connection objects, representing connections to the session. (Note that each connection can publish multiple streams.)
target (Object) The object that dispatched the event.
type (String) The type of event. There is only one types of SessionConnectEvent object: "sessionConnected".
streams (Array[Stream]) An array of Stream objects corresponding to the streams currently available in the session that has connected.
Example
The following code initializes a session and sets up an event listener for when a session is connected. The event listener adds links to the page for each stream in the session:
var sessionID = "1690446fcddb5a4e6dd5ec1fcd1415312a18aae38";
apiKey = 1234;
var session = TB.initSession(sessionID);
session.addEventListener("sessionConnected", sessionConnectedHandler);
session.connect(apiKey, token);
function sessionConnectedHandler(event) {
for (var i = 0; i < event.streams; i++) {
var stream = event.streams[i];
addLink(stream);
}
}
function addLink(stream) {
var aLink = document.createElement('a');
aLink.setAttribute('id', 'stream' + stream.streamId);
aLink.setAttribute('href', 'javaScript:subscribeToStream(' + stream.streamId + ')');
var name = stream.name;
if (name == "") {
name = stream.streamId.toString();
}
aLink.innerHTML = "Subscribe to stream " + name;
var streamsListContainer = document.getElementById('streamsListContainer');
streamsListContainer.appendChild(aLink);
streamsListContainer. appendChild(document.createElement('br'));
}
function subscribeToStream(streamId) {
//
}
IRC Live Chat
Have a quick question? Chat with other developers. Join chat
TokBox staff may not be online right now. To reach them during off-hours, visit the forums.