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