blob: 57e335ea977b0eb87fa2e4fb8c0e8efb8832cc86 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8 />
<title>Minimal Websocket message sender</title>
</head>
<body>
<script>
var pos = 0;
var websocket_ads;
/*
* We open the websocket encrypted if this page came on an
* https:// url itself, otherwise unencrypted
*/
if (document.URL.substring(0, 5) == "https")
websocket_ads = "wss://127.0.0.1:7681";
else
websocket_ads = "ws://127.0.0.1:7681"
var socket = new WebSocket(websocket_ads);
try {
// alert('<p class="event">Socket Status: '+socket.readyState);
socket.onopen = function(){
// alert('<p class="event">Socket Status: '+socket.readyState+' (open)');
}
socket.onmessage = got_packet;
socket.onclose = function(){
alert('<p class="event">Socket Status: (Closed)');
}
} catch(exception){
alert('<p>Error'+exception);
}
function got_packet(msg){
// alert('got packet' + msg.data);
document.body.textContent = msg.data + "\n";
}
</script>
</body>
</html>