Created
July 9, 2012 13:42
-
-
Save vicapow/3076653 to your computer and use it in GitHub Desktop.
who's the master node?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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