add separate WebSocket for block highlight

This commit is contained in:
Silver Kuusik 2017-10-22 12:03:33 +02:00
parent 892459f6e5
commit 36b0000da6

View File

@ -16,6 +16,8 @@ var hotkeys = true;
/* the sumorobot code */ /* the sumorobot code */
var sumocode = ""; var sumocode = "";
var block_highlight = null;
var Sumorobot = function(wsUri) { var Sumorobot = function(wsUri) {
/* assign the WebSocket URI */ /* assign the WebSocket URI */
this.wsUri = wsUri; this.wsUri = wsUri;
@ -419,6 +421,15 @@ window.onload = function() {
setLocalStorageItem("sumorobot.robotID" + index, robotID); setLocalStorageItem("sumorobot.robotID" + index, robotID);
/* connect to the selected robot channel */ /* connect to the selected robot channel */
sumorobot = new Sumorobot("ws://" + robotServer + ":80/p2p/browser/" + robotID + "/"); sumorobot = new Sumorobot("ws://" + robotServer + ":80/p2p/browser/" + robotID + "/");
block_highlight = new WebSocket("ws://" + robotServer + ":80/p2p/browser/" + robotID + "-highlight/");
/* when there is a message from the WebSocket */
block_highlight.onmessage = function(evt) {
/* when scope is received */
if (evt.data.length == 20) {
workspace.highlightBlock(evt.data);
highlighted = evt.data;
}
};
/* hide the configuration panel */ /* hide the configuration panel */
$("#panel").hide(); $("#panel").hide();
}); });