Sha256: 346e75df200075087b5da565357885cd5ddfe827d313c7599f3491355747daa5
Contents?: true
Size: 1.3 KB
Versions: 17
Compression:
Stored size: 1.3 KB
Contents
// Initialize an OpenTok Session object var session = OT.initSession(apiKey, sessionId); // Initialize a Publisher, and place it into the element with id="publisher" var publisher = OT.initPublisher('publisher', { insertMode: 'append', }, function(error) { if (error) { console.error('Failed to initialise publisher', error); } }); // Attach event handlers session.on({ // This function runs when session.connect() asynchronously completes sessionConnected: function(event) { // Publish the publisher we initialzed earlier (this will trigger 'streamCreated' on other // clients) session.publish(publisher, function(error) { if (error) { console.error('Failed to publish', error); } }); }, // This function runs when another client publishes a stream (eg. session.publish()) streamCreated: function(event) { // Subscribe to the stream that caused this event, and place it into the element with id="subscribers" session.subscribe(event.stream, 'subscribers', { insertMode: 'append', }, function(error) { if (error) { console.error('Failed to subscribe', error); } }); } }); // Connect to the Session using a 'token' session.connect(token, function(error) { if (error) { console.error('Failed to connect', error); } });
Version data entries
17 entries across 17 versions & 1 rubygems