This allocation is only deleted / replaced when the connection accesses a
URL region with a different protocol (or the default protocols[0] if no
CALLBACK area matches it).
+
+@section dim Dimming webpage when connection lost
+
+The lws test plugins' html provides useful feedback on the webpage about if it
+is still connected to the server, by greying out the page if not. You can
+also add this to your own html easily
+
+ - include lws-common.js from your HEAD section
+
+ <script src="/lws-common.js"></script>
+
+ - dim the page during initialization, in a script section on your page
+
+ lws_gray_out(true,{'zindex':'499'});
+
+ - in your ws onOpen(), remove the dimming
+
+ lws_gray_out(false);
+
+ - in your ws onClose(), reapply the dimming
+
+ lws_gray_out(true,{'zindex':'499'});
<html>
<head>
+ <script src="/lws-common.js"></script>
<script src="lwsgs.js"></script>
<style>
.body { font-size: 12 }
<img src="lwsgs-logo.png">
</td>
<td style="vertical-align:top;float:right">
- <div id=lwsgs style="text-align:right;background-color: rgba(255, 255, 255, 0.8);"></div>
+ <div id=lwsgs style="zIndex: 1000;text-align:right;background-color: rgba(255, 255, 255, 0.8);"></div>
</td>
</tr>
<html lang="en">
<head>
<meta charset=utf-8 http-equiv="Content-Language" content="en"/>
+ <script src="/lws-common.js"></script>
<title>LWS Server Status</title>
<style type="text/css">
span.title { font-size:18pt; font: Arial; font-weight:normal;
<script>
+lws_gray_out(true,{'zindex':'499'});
+
/*
* We display untrusted stuff in html context... reject anything
* that has HTML stuff in it
try {
socket_status.onopen = function() {
document.getElementById("title").innerHTML = "Server Status (Active)";
+ lws_gray_out(false);
}
socket_status.onmessage =function got_packet(msg) {
socket_status.onclose = function(){
document.getElementById("title").innerHTML = "Server Status (Disconnected)";
+ lws_gray_out(true,{'zindex':'499'});
}
} catch(exception) {
alert('<p>Error' + exception);
if (!strcmp(&file[n - 4], ".css"))
return "text/css";
+ if (!strcmp(&file[n - 3], ".js"))
+ return "text/javascript";
+
return NULL;
}
<html lang="en">
<head>
<meta charset=utf-8 http-equiv="Content-Language" content="en"/>
+ <script src="/lws-common.js"></script>
<title>Minimal Websocket test app</title>
<style type="text/css">
span.title { font-size:18pt; font: Arial; font-weight:normal; text-align:center; color:#000000; }
return s;
}
+lws_gray_out(true,{'zindex':'499'});
+
/* BrowserDetect came from http://www.quirksmode.org/js/detect.html */
var BrowserDetect = {
document.getElementById("wslm_status").innerHTML =
" <b>websocket connection opened</b><br>" +
san(socket_lm.extensions);
+ lws_gray_out(false);
}
socket_lm.onmessage =function got_packet(msg) {
socket_lm.onclose = function(){
document.getElementById("wslm_statustd").style.backgroundColor = "#ff4040";
document.getElementById("wslm_status").textContent = " websocket connection CLOSED ";
+ lws_gray_out(true,{'zindex':'499'});
}
} catch(exception) {
alert('<p>Error' + exception);