add separate WebSocket for block highlight
This commit is contained in:
		
							
								
								
									
										11
									
								
								sumorobot.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								sumorobot.js
									
									
									
									
									
								
							@@ -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();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user