Anders and Briegel in Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
744B

  1. var websocket = {};
  2. websocket.connect = function(update) {
  3. var ws = new WebSocket("ws://localhost:5000");
  4. ws.onopen = function(evt) {
  5. gui.serverMessage("Connected to server.");
  6. };
  7. ws.onerror = function(err) {
  8. gui.serverMessage("Could not connect to server.");
  9. };
  10. ws.onmessage = function(evt) {
  11. json = JSON.parse(evt.data);
  12. for (var i in json.meta) {
  13. var pos = json.meta[i].position;
  14. json.meta[i].position = new THREE.Vector3(pos.x, pos.y, pos.z);
  15. }
  16. update(json);
  17. };
  18. ws.onclose = function(evt) {
  19. gui.serverMessage("Connection to server lost. <a href='#' onclick='javascript:websocket.connect()'>Reconnect</a>.", true);
  20. };
  21. };