Skip to content

Instantly share code, notes, and snippets.

@brucespang
Last active December 20, 2015 07:59
Show Gist options
  • Save brucespang/6097690 to your computer and use it in GitHub Desktop.
Save brucespang/6097690 to your computer and use it in GitHub Desktop.
raft example
var id = "" + randBetween(0,100);
console.log("starting as " + id)
cfg = {
host: 'localhost',
port: 9000
}
var peer = new Peer(id, cfg);
peer.on("error", function(err) {
peer = new Peer(room_id + "-" + ..., cfg);
})
var client = new Raft(peer, function(data) {
console.error("apply:", data)
})
client.join(room_id)
client.send(msg)
window.onunload = function() {
client.leave()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment