-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update JS samples to use latest API and add error handling (#144)
* Update JS samples to use latest API and add error handling * Update JS style: single quotes * Update URL for JS SDK * Return the initPublisher callback in helloworld sample
- Loading branch information
Showing
4 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
var session = OT.initSession(sessionId), | ||
publisher = OT.initPublisher("publisher"); | ||
var session = OT.initSession(apiKey, sessionId), | ||
publisher = OT.initPublisher('publisher'); | ||
|
||
session.connect(apiKey, token, function(err, info) { | ||
if(err) { | ||
alert(err.message || err); | ||
session.connect(token, function(error, info) { | ||
if (error) { | ||
console.error('Failed to connect', error); | ||
} else { | ||
session.publish(publisher, function(error) { | ||
if (error) { | ||
console.error('Failed to publish', error); | ||
} | ||
}); | ||
} | ||
session.publish(publisher); | ||
}); | ||
|
||
session.on('streamCreated', function(event) { | ||
session.subscribe(event.stream, "subscribers", { insertMode : "append" }); | ||
session.subscribe(event.stream, 'subscribers', { | ||
insertMode : 'append' | ||
}, function(error) { | ||
if (error) { | ||
console.error('Failed to subscribe', error); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters