From 36b0000da62a04e9a3558c09855f4c4b33840c42 Mon Sep 17 00:00:00 2001 From: Silver Kuusik Date: Sun, 22 Oct 2017 12:03:33 +0200 Subject: [PATCH] add separate WebSocket for block highlight --- sumorobot.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sumorobot.js b/sumorobot.js index 0adf185..7b87e5e 100755 --- a/sumorobot.js +++ b/sumorobot.js @@ -16,6 +16,8 @@ var hotkeys = true; /* the sumorobot code */ var sumocode = ""; +var block_highlight = null; + var Sumorobot = function(wsUri) { /* assign the WebSocket URI */ this.wsUri = wsUri; @@ -419,6 +421,15 @@ window.onload = function() { setLocalStorageItem("sumorobot.robotID" + index, robotID); /* connect to the selected robot channel */ 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 */ $("#panel").hide(); });