Skip to content

Instantly share code, notes, and snippets.

@lukelex
Created December 10, 2012 03:39
Show Gist options
  • Select an option

  • Save lukelex/4248252 to your computer and use it in GitHub Desktop.

Select an option

Save lukelex/4248252 to your computer and use it in GitHub Desktop.
Private Pub client subscription callback
// on privatepub this data is sent by server to client
var opts = {
server: "foo",
channel: "/hello/world",
...
}
// and you can add a subscription callback
// it will take a Faye subscription object. (see http://faye.jcoglan.com/browser/subscribing.html)
opts.subscription = function(subscription) {
subscription.callback(function() {
// subscription was successful here.
// send an initial message on that channel.
PrivatePub.faye(function(faye){
faye.send("/hello/world", {text: 'Hey I just connected!'});
});
});
}
PrivatePub.sign(options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment