-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex-faye.html
34 lines (29 loc) · 900 Bytes
/
index-faye.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<html>
<title>Dante</title>
<head>
<script>
var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';
var address = protocol + window.location.host + window.location.pathname + '/ws';
var socket = new WebSocket(address);
var body;
function addLine(line) {
body = body || document.getElementsByTagName('body')[0];
var div = document.createElement('div');
div.appendChild(document.createTextNode(line));
body.appendChild(div);
}
socket.onmessage = function (msg) {
addLine(msg.data);
};
socket.onerror = function (e) {
addLine('Unable to establish WebSocket connection to ' + address);
};
socket.onclose = function () {
addLine('WebSocket connection is closed.');
};
</script>
</head>
<body>
<h1>Dante over WebSockets with faye-websockets</h1>
</body>
</html>