Skip to content

Instantly share code, notes, and snippets.

@belison
Created August 13, 2012 19:48
Show Gist options
  • Save belison/3343585 to your computer and use it in GitHub Desktop.
Save belison/3343585 to your computer and use it in GitHub Desktop.
Figure 3: Sample JS connection
setupRealtime: function (config) {
if (window.Faye && Faye.Client && config.faye_uri) {
_.bindAll(this , 'onFayeConnect' , 'onFayeEvent');
this.fayeClient = new Faye.Client(config.faye_uri , {
retry: 5
});
this.fayeClient.connect(this.onFayeConnect);
}
},
onFayeConnect: function () {
var user = this.get('user');
this.fayeUserSubscription = this.fayeClient.subscribe('/' + user.get('id') + '/**' , this.onFayeEvent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment