|
|
@@ -1,16 +1,16 @@ |
|
|
|
var websocket = {}; |
|
|
|
|
|
|
|
websocket.connect = function(update) { |
|
|
|
var ws = new WebSocket("ws://localhost:5000"); |
|
|
|
ws.onopen = function(evt) { |
|
|
|
websocket.ws = new WebSocket("ws://localhost:5000"); |
|
|
|
websocket.ws.onopen = function(evt) { |
|
|
|
gui.serverMessage("Connected to server."); |
|
|
|
}; |
|
|
|
|
|
|
|
ws.onerror = function(err) { |
|
|
|
websocket.ws.onerror = function(err) { |
|
|
|
gui.serverMessage("Could not connect to server."); |
|
|
|
}; |
|
|
|
|
|
|
|
ws.onmessage = function(evt) { |
|
|
|
websocket.ws.onmessage = function(evt) { |
|
|
|
json = JSON.parse(evt.data); |
|
|
|
for (var i in json.node) { |
|
|
|
var pos = json.node[i].position; |
|
|
@@ -22,7 +22,7 @@ websocket.connect = function(update) { |
|
|
|
update(json); |
|
|
|
}; |
|
|
|
|
|
|
|
ws.onclose = function(evt) { |
|
|
|
websocket.ws.onclose = function(evt) { |
|
|
|
gui.serverMessage("No connection to server. <a href='#' onclick='javascript:websocket.connect()'>Reconnect</a>.", true); |
|
|
|
}; |
|
|
|
}; |