diff --git a/abp/clifford.py b/abp/clifford.py index 4c23c6b..c671b91 100644 --- a/abp/clifford.py +++ b/abp/clifford.py @@ -146,8 +146,6 @@ try: with open(temp("by_name.json")) as f: by_name = json.load(f) - - print "Loaded tables from cache" except IOError: # Spend time building the tables unitaries = get_unitaries() diff --git a/server/static/main.js b/server/static/main.js index 6f39aac..e25fc11 100644 --- a/server/static/main.js +++ b/server/static/main.js @@ -31,6 +31,7 @@ function startMainLoop() { scene = makeScene(); controls.addEventListener("change", render); poll(); + render(); } // Someone resized the window @@ -63,12 +64,12 @@ function init() { controls = new THREE.OrbitControls(camera); // Center the camera + // TODO: frustrum controls.center.set(0, 0, 0); controls.rotateSpeed = 0.2; - camera.position.set(0, 0, 20); + camera.position.set(0, 0, 40); // Start polling - setInterval(poll, 1000); // Run startMainLoop(); diff --git a/server/static/poll.js b/server/static/poll.js index 7852590..f3ad81e 100644 --- a/server/static/poll.js +++ b/server/static/poll.js @@ -1,19 +1,25 @@ function poll() { - var xhr = new XMLHttpRequest(); - - xhr.onload = function() { - var state = JSON.parse(xhr.responseText); - updateScene(state); + var ws = new WebSocket("ws://localhost:5000/echo"); + ws.onopen = function() + { + // Web Socket is connected, send data using send() + ws.send("Hello from the browser! I connected okay"); + console.log("Sent a message to the server"); }; - - xhr.onerror = function(e){ - //soft_console.innerHTML = "\n" + "Lost connection to server"; + + ws.onmessage = function (evt) + { + var received_msg = evt.data; + console.log("I got a message from the server:"); + console.log(evt.data); + }; + + ws.onclose = function() + { + ws.send("Bye by from the browser"); + console.log("Connection is closed..."); }; - - xhr.open("GET", "/state", true); - xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); - xhr.send(); } function updateScene(state) {