|
@@ -18,12 +18,19 @@ from pkg_resources import resource_filename |
|
|
clients = [] |
|
|
clients = [] |
|
|
local_state = abp.GraphState() |
|
|
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): |
|
|
def new_message(client, server, message): |
|
|
if message.startswith("edit:"): |
|
|
if message.startswith("edit:"): |
|
|
print message[5:] |
|
|
print message[5:] |
|
|
edit = json.loads(message[5:]) |
|
|
edit = json.loads(message[5:]) |
|
|
print "Received update from javascript." |
|
|
print "Received update from javascript." |
|
|
print edit |
|
|
|
|
|
|
|
|
process_edit(edit, server) |
|
|
else: |
|
|
else: |
|
|
print "Received update from python {}.".format(client["id"]) |
|
|
print "Received update from python {}.".format(client["id"]) |
|
|
print message |
|
|
print message |
|
|