Created
January 10, 2017 14:50
-
-
Save push-gists/ede0c8e1db6c8cde80def19acd56d85f to your computer and use it in GitHub Desktop.
A simple JS Reappt client that attempts subscription to topics with different permissions
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
var diffusion = require('diffusion'); | |
// Connect to Reappt with requester credentials | |
diffusion.connect({ | |
host : 'approvingBoldDaVinci.us.reappt.io', | |
port : 443, | |
secure : true, | |
principal : 'requester', | |
credentials : 'retseuqer' | |
}).then(function(session) { | |
// Subscribe to the "open/cats" topic | |
var openSub = session.subscribe('open/cats').on({ | |
subscribe : function(details, topic) { | |
console.log('Subscribed to topic: ' + topic); | |
}, | |
update : function(value, topic) { | |
console.log(topic + ' updated with value: ' + value); | |
}, | |
error : function(error) { | |
console.log(error); | |
} | |
}); | |
// Subscribe to the "closed/cats" topic | |
var closedSub = session.subscribe('closed/cats').on({ | |
subscribe : function(details, topic) { | |
console.log('Subscribed to topic: ' + topic); | |
}, | |
update : function(value, topic) { | |
console.log(topic + ' updated with value: ' + value); | |
}, | |
error : function(error) { | |
console.log(error); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment