diff options
author | Aaron LI <aaronly.me@outlook.com> | 2016-11-04 13:28:19 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2016-11-04 13:59:03 +0800 |
commit | 54b756d88b72eb07f4ee9fbb6b5f9d35ae1484a3 (patch) | |
tree | b4644a671743e8ba41c1920e5cee513cc946dc1c /fg21sim/webui/static/js/websocket.js | |
parent | dee4165ac47a8184ea8ae0876bd45364ba40affa (diff) | |
download | fg21sim-54b756d88b72eb07f4ee9fbb6b5f9d35ae1484a3.tar.bz2 |
webui: Update server & client sides WebSocket handlers
* Server side:
+ Update the "on_message()" method to support 3 types of message
requests (i.e., "configs", "console", and "results");
+ Add messages stub handlers: "_handle_{configs,console,results}()";
+ Reorder the methods
+ Client side:
+ Change timeout before reconnection to 3000 ms;
+ Parse the received JSON message to JS object;
Diffstat (limited to 'fg21sim/webui/static/js/websocket.js')
-rw-r--r-- | fg21sim/webui/static/js/websocket.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/fg21sim/webui/static/js/websocket.js b/fg21sim/webui/static/js/websocket.js index 95e85f2..ae44410 100644 --- a/fg21sim/webui/static/js/websocket.js +++ b/fg21sim/webui/static/js/websocket.js @@ -16,7 +16,7 @@ var ws = null; /* WebSocket */ var ws_reconnect = { maxTry: 100, tried: 0, - timeout: 1000, /* ms */ + timeout: 3000, /* ms */ }; @@ -130,8 +130,9 @@ var connectWebSocket = function (url) { toggleWSReconnect("show"); }; ws.onmessage = function (e) { - console.log("WebSocket received message:"); - console.log(e.data); + var msg = JSON.parse(e.data); + console.log("WebSocket received message: type:", msg.type, + ", status:", msg.status); }; }; |