Browse Source

Can message abpserver from JavaScript

master
Pete Shadbolt 8 years ago
parent
commit
e273b3107f
3 changed files with 7 additions and 13 deletions
  1. +1
    -12
      abp/static/scripts/editor.js
  2. +4
    -0
      abp/static/scripts/websocket.js
  3. +2
    -1
      bin/abpserver

+ 1
- 12
abp/static/scripts/editor.js View File

@@ -48,18 +48,7 @@ editor.addQubitAtPoint = function(point) {
}
point.round();

// Check for clashes
for (var node in abj.node) {
var delta = new THREE.Vector3();
delta.subVectors(abj.node[node].position, point);
if (delta.length()<0.1){ return; }
}

// TODO: This SUCKS
var new_node = point.x + "." + point.y + "." + point.z;
abj.add_node(new_node, { position: point, vop:0 });
editor.focus(new_node);
graph.update();
websocket.edit({test:"test"});
gui.serverMessage("Created node " + new_node +".");
};



+ 4
- 0
abp/static/scripts/websocket.js View File

@@ -26,3 +26,7 @@ websocket.connect = function(update) {
gui.serverMessage("No connection to server. <a href='#' onclick='javascript:websocket.connect()'>Reconnect</a>.", true);
};
};

websocket.edit = function (data) {
websocket.ws.send("edit:"+JSON.stringify(data));
};

+ 2
- 1
bin/abpserver View File

@@ -18,7 +18,8 @@ from pkg_resources import resource_filename
clients = []

def new_message(client, server, message):
if message.startswith("edit"):
if message.startswith("edit:"):
print message[5:]
edit = json.loads(message[5:])
print "Received update from javascript."
print edit


Loading…
Cancel
Save