Skip to content

Instantly share code, notes, and snippets.

@vicapow
Created July 9, 2012 13:42
Show Gist options
  • Save vicapow/3076653 to your computer and use it in GitHub Desktop.
Save vicapow/3076653 to your computer and use it in GitHub Desktop.
who's the master node?
var Hook = require('hook.io').Hook
, is_master = false
var hook = new Hook({
name : 'hook'
, type : 'victor'
, autoheal : true
});
hook.on('*::rank::accepting',function(data){
setRank(data);
});
hook.on('hook::ready',function(){
setRank(this.proposedRank);
});
hook.start();
function setRank(rank){
if(rank==0 && !is_master){
is_master = true;
console.log("I'm master now!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment