Procházet zdrojové kódy

Closed the loop - JS -> Python -> JS

master
Pete Shadbolt před 8 roky
rodič
revize
899b202810
2 změnil soubory, kde provedl 10 přidání a 3 odebrání
  1. +2
    -2
      abp/static/scripts/editor.js
  2. +8
    -1
      bin/abpserver

+ 2
- 2
abp/static/scripts/editor.js Zobrazit soubor

@@ -47,8 +47,8 @@ editor.addQubitAtPoint = function(point) {
return;
}
point.round();
websocket.edit({test:"test"});
var new_node = Math.floor(point.x*1000000 + point.y*1000 + point.z);
websocket.edit({action:"create", name:new_node, position: point});
gui.serverMessage("Created node " + new_node +".");
};



+ 8
- 1
bin/abpserver Zobrazit soubor

@@ -18,12 +18,19 @@ from pkg_resources import resource_filename
clients = []
local_state = abp.GraphState()

def process_edit(edit, server):
action = edit["action"]
if action == "create":
local_state.add_qubit(edit["name"], position=edit["position"])
server.send_message_to_all(json.dumps(local_state.to_json()))


def new_message(client, server, message):
if message.startswith("edit:"):
print message[5:]
edit = json.loads(message[5:])
print "Received update from javascript."
print edit
process_edit(edit, server)
else:
print "Received update from python {}.".format(client["id"])
print message


Načítá se…
Zrušit
Uložit