Kaynağa Gözat

Closed the loop - JS -> Python -> JS

master
Pete Shadbolt 8 yıl önce
ebeveyn
işleme
899b202810
2 değiştirilmiş dosya ile 10 ekleme ve 3 silme
  1. +2
    -2
      abp/static/scripts/editor.js
  2. +8
    -1
      bin/abpserver

+ 2
- 2
abp/static/scripts/editor.js Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

@@ -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


Yükleniyor…
İptal
Kaydet