Browse Source

Move some files, comment visiblegraphstate

master
Pete Shadbolt 8 years ago
parent
commit
eb4fe7d81e
15 changed files with 10 additions and 10 deletions
  1. +1
    -5
      abp/server.py
  2. +9
    -5
      abp/visiblegraphstate.py
  3. +0
    -0
      client/anders_briegel.js
  4. +0
    -0
      client/api.js
  5. +0
    -0
      client/curve.js
  6. +0
    -0
      client/graph.js
  7. +0
    -0
      client/index.html
  8. +0
    -0
      client/interaction.js
  9. +0
    -0
      client/libs.js
  10. +0
    -0
      client/main.css
  11. +0
    -0
      client/main.js
  12. +0
    -0
      client/materials.js
  13. +0
    -0
      client/poll.js
  14. +0
    -0
      client/tables.js
  15. +0
    -0
      client/three.js

server/server.py → abp/server.py View File

@@ -4,10 +4,6 @@ import abp
import json

clients = []
state = abp.VisibleGraphState()

def compute_diff(decoded_message):


def new_message(client, server, message):
decoded_message = json.loads(message)
@@ -29,7 +25,7 @@ def client_left(client, server):
clients.remove(client)

if __name__ == '__main__':
server = WebsocketServer(5001)
server = WebsocketServer(5000)
server.set_fn_new_client(new_client)
server.set_fn_message_received(new_message)
server.set_fn_client_left(client_left)

+ 9
- 5
abp/visiblegraphstate.py View File

@@ -9,25 +9,29 @@ from websocket import create_connection
from graphstate import GraphState
import json


class VisibleGraphState(GraphState):

""" Overloads the graph state with methods for sending to the browser over a websocket """

def __init__(self, *args, **kwargs):
""" Constructor """
GraphState.__init__(self, *args, **kwargs)
self.ws = create_connection("ws://localhost:5001")
self.ws = create_connection("ws://localhost:5000")
atexit.register(self.shutdown)
#self.ws.send(json.dumps({"method":"clear"}))

def shutdown(self):
""" The client should shut down automatically on close """
self.update()
self.ws.close()

def to_json(self):
ngbh = {a: {b : True for b in self.ngbh[a]}
""" We override to_json() so that we send the whole `ngbh` structure in JS-friendly form """
ngbh = {a: {b: True for b in self.ngbh[a]}
for a in self.ngbh}
return {"vops": self.vops, "ngbh": ngbh, "meta": self.meta}

def update(self):
""" Call this function when you are ready to send data to the browser """
data = json.dumps(self.to_json())
self.ws.send(data)



server/anders_briegel.js → client/anders_briegel.js View File


server/api.js → client/api.js View File


server/curve.js → client/curve.js View File


server/graph.js → client/graph.js View File


server/index.html → client/index.html View File


server/interaction.js → client/interaction.js View File


server/libs.js → client/libs.js View File


server/main.css → client/main.css View File


server/main.js → client/main.js View File


server/materials.js → client/materials.js View File


server/poll.js → client/poll.js View File


server/tables.js → client/tables.js View File


server/three.js → client/three.js View File


Loading…
Cancel
Save