Skip to content

Instantly share code, notes, and snippets.

@push-gists
Created January 10, 2017 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save push-gists/ede0c8e1db6c8cde80def19acd56d85f to your computer and use it in GitHub Desktop.
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
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