Last active
December 20, 2015 07:59
-
-
Save brucespang/6097690 to your computer and use it in GitHub Desktop.
raft example
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 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