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(); });