2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

console.js: fix filtering with websocket

git-svn-id: https://svn.fhem.de/fhem/trunk@13566 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2017-03-01 16:01:41 +00:00
parent e009eec832
commit 1d8585c1fa
2 changed files with 6 additions and 3 deletions

View File

@ -74,11 +74,13 @@ consFill()
"&timestamp="+new Date().getTime(); "&timestamp="+new Date().getTime();
query = addcsrf(query); query = addcsrf(query);
var loc = (""+location).replace(/\?.*/,"");
if($("body").attr("longpoll") == "websocket") { if($("body").attr("longpoll") == "websocket") {
if(consConn) { if(consConn) {
consConn.close(); consConn.close();
} }
consConn = new WebSocket((location+query).replace(/^http/i, "ws")); consConn = new WebSocket(loc.replace(/[&?].*/,'')
.replace(/^http/i, "ws")+query);
consConn.onclose = consConn.onclose =
consConn.onerror = consConn.onerror =
consConn.onmessage = consUpdate; consConn.onmessage = consUpdate;
@ -89,7 +91,7 @@ consFill()
consConn.abort(); consConn.abort();
} }
consConn = new XMLHttpRequest(); consConn = new XMLHttpRequest();
consConn.open("GET", location.pathname+query, true); consConn.open("GET", loc+query, true);
consConn.onreadystatechange = consUpdate; consConn.onreadystatechange = consUpdate;
consConn.send(null); consConn.send(null);

View File

@ -920,7 +920,8 @@ FW_longpoll()
var loc = (""+location).replace(/\?.*/,""); var loc = (""+location).replace(/\?.*/,"");
if(typeof WebSocket == "function" && FW_longpollType == "websocket") { if(typeof WebSocket == "function" && FW_longpollType == "websocket") {
FW_pollConn = new WebSocket(loc.replace(/[&?].*/,'').replace(/^http/i, "ws")+query); FW_pollConn = new WebSocket(loc.replace(/[&?].*/,'')
.replace(/^http/i, "ws")+query);
FW_pollConn.onclose = FW_pollConn.onclose =
FW_pollConn.onerror = FW_pollConn.onerror =
FW_pollConn.onmessage = FW_doUpdate; FW_pollConn.onmessage = FW_doUpdate;