Created
June 1, 2017 13:53
-
-
Save jonathanbp/d34aef92e15739177ad2a023d71421f7 to your computer and use it in GitHub Desktop.
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
// Ad-hoc minions | |
var controlConn = new WebSocket('wss://emet.cc.au.dk/golem/v1/connect/'+webstrate.webstrateId); | |
controlConn.addEventListener("open", function(msg) { | |
console.log("connection to chief-minion established"); | |
}); | |
controlConn.addEventListener("message", function(msg) { | |
console.log("got message on controlConn", msg); | |
var minionMsg = JSON.parse(msg.data); | |
if (minionMsg.Event === "minion-connected" && minionMsg.Type === "minion-debug") { | |
// establish a connection to the minion | |
var minionConn = new WebSocket("wss://emet.cc.au.dk/golem/v1/connect-to/"+webstrate.webstrateId+"/"+minionMsg.ID); | |
minionConn.addEventListener("message", function(msg) { | |
document.querySelector("#minion-debug").innerHTML = msg.data + " says minion"; | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment