From 54b756d88b72eb07f4ee9fbb6b5f9d35ae1484a3 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 4 Nov 2016 13:28:19 +0800 Subject: 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; --- fg21sim/webui/static/js/websocket.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'fg21sim/webui/static') 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); }; }; -- cgit v1.2.2