Skip to content

Instantly share code, notes, and snippets.

@hbaqai
Created March 23, 2017 02:05
Show Gist options
  • Save hbaqai/d4f07cccd431407fa2ead58b2229cef7 to your computer and use it in GitHub Desktop.
Save hbaqai/d4f07cccd431407fa2ead58b2229cef7 to your computer and use it in GitHub Desktop.
TokBox Access Dialogue Events
<!DOCTYPE HTML>
<html>
<body>
<script src="https://static.opentok.com/v2/js/opentok.js" charset="utf-8"></script>
<script charset="utf-8">
var apiKey = 'API_KEY';
var sessionId = 'SESSION_ID';
var token = 'TOKEN_ID';
var publisher;
var session = OT.initSession(apiKey, sessionId)
.on('streamCreated', function(event) {
session.subscribe(event.stream);
})
.connect(token, function(error) {
publisher = OT.initPublisher();
publisher.on('accessAllowed', function(){
console.log('event: accessAllowed');
});
publisher.on('accessDenied', function(){
console.log('event: accessDenied');
});
publisher.on('accessDialogOpened', function(){
console.log('event: accessDialogOpened');
});
publisher.on('accessDialogClosed', function(){
console.log('event: accessDialogClosed');
});
session.publish(publisher);
});
function destroyMyPublisher(){
console.log('calling session.unpublish');
session.unpublish(publisher);
//publisher.destroy();
}
</script>
<button onclick="destroyMyPublisher()">Disconnect</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment