From 4adfa806fd5dbf7b3d2324e260d3bdd174cb46c7 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Wed, 1 Mar 2017 17:08:25 +0000 Subject: [PATCH] console.js: websocket close fix git-svn-id: https://svn.fhem.de/fhem/trunk@13567 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/www/pgm2/console.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/fhem/www/pgm2/console.js b/fhem/www/pgm2/console.js index bdbf48ad1..327d9aa34 100644 --- a/fhem/www/pgm2/console.js +++ b/fhem/www/pgm2/console.js @@ -7,6 +7,18 @@ var mustScroll = 1; log("Console is opening"); +function +cons_closeConn() +{ + if(!consConn) + return; + if(typeof consConn.close == "function") + consConn.close(); + else if(typeof consConn.abort == "function") + consConn.abort(); + consConn = undefined; +} + function consUpdate(evt) { @@ -16,8 +28,7 @@ consUpdate(evt) if(typeof WebSocket == "function" && evt && evt.target instanceof WebSocket) { if(evt.type == 'close') { FW_errmsg(errstr, 4900); - consConn.close(); - consConn = undefined; + cons_closeConn(); setTimeout(consFill, 5000); return; } @@ -58,16 +69,8 @@ consFill() { FW_errmsg(""); - if(FW_pollConn) { - if($("body").attr("longpoll") == "websocket") { - FW_pollConn.onclose = undefined; - FW_pollConn.close(); - } else { - FW_pollConn.onreadystatechange = undefined; - FW_pollConn.abort(); - } - FW_pollConn = undefined; - } + if(FW_pollConn) + FW_closeConn(); var query = "?XHR=1"+ "&inform=type=raw;withLog="+withLog+";filter="+consFilter+