From 4c37ed9e27a70a123eea038adbc1a6128340ffb6 Mon Sep 17 00:00:00 2001 From: bel Date: Mon, 6 Apr 2015 22:22:50 +0200 Subject: [PATCH] Add test case for issue #77 --- test/websocket.xhtml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/test/websocket.xhtml b/test/websocket.xhtml index 87b9753c..52c49ffd 100644 --- a/test/websocket.xhtml +++ b/test/websocket.xhtml @@ -20,6 +20,27 @@ var hand_hour; var hand_min; + function queryStringElem(name, idx) { + if (typeof(queryStringElem_Table) != "object") { + queryStringElem_Table = {}; + window.location.search.slice(1).split('&').forEach( + function(keyValuePair) { + keyValuePair = keyValuePair.split('='); + if (typeof(queryStringElem_Table[keyValuePair[0]]) != "object") { + queryStringElem_Table[keyValuePair[0]] = []; + } + var idx = queryStringElem_Table[keyValuePair[0]].length+1; + queryStringElem_Table[keyValuePair[0]][idx] = keyValuePair[1] || ''; + } + ); + } + idx = idx || 1; + if (queryStringElem_Table[name]) { + return queryStringElem_Table[name][idx]; + } + return null; + } + function webSockKeepAlive() { if (keepAlive) { connection.send('client still alive'); @@ -35,8 +56,16 @@ hand_min = document.getElementById('hand_min'); hand_hour = document.getElementById('hand_hour'); + var ka = queryStringElem("keepAlive"); + if (ka) { + use_keepAlive = (ka.toLowerCase()!="false") && (ka.toLowerCase()!=0); + } else { + use_keepAlive = true; + } + connection.onopen = function () { - keepAlive = true; + keepAlive = use_keepAlive; + alert(keepAlive); webSockKeepAlive(); };