Skip to content

Instantly share code, notes, and snippets.

@tommedema
Created May 19, 2011 12:00
Show Gist options
  • Save tommedema/980593 to your computer and use it in GitHub Desktop.
Save tommedema/980593 to your computer and use it in GitHub Desktop.
define(['/nowjs/now.js', '/lib/jquery.js'], function() {
console.log('woo, registration handler here I come!');
//called when server gives a response to our registration request
now.onRegisterCallback = function(success, err) {
console.log('registered as user: ' + userName);
if (success) $('#myInfo').html('UserName: ' + userName);
else $('#myInfo').html('Error, cannot register: ' + err);
};
//called when now.js communication has been setup
now.ready(function() {
console.log('now.js is connected to server: %o', now);
//register to the server with a username
userName = 'user' + new Date().getTime();
now.register(userName);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment