-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.html
46 lines (40 loc) · 958 Bytes
/
index.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
35
36
37
38
39
40
41
42
43
44
45
46
<html>
<head>
<style>
body {
font-family: "Helvetica Neue", helvetica, arial;
padding: 15px;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
ul li {
line-height: 1.4;
}
</style>
<script>
/*
* Assume url is http://localhost:5000/?1985
* Below code establishes a websocket connection to ws://localhost:5000/1985
*/
var host = location.origin.replace(/^http/, 'ws');
host = host + '/' + location.search.substring(1);
var ws;
(function() {
ws = new WebSocket(host);
})();
ws.onmessage = function (event) {
var li = document.getElementById('event');
li.innerHTML = 'Updated: ' + Date() + ':</br>' + event.data;
};
</script>
</head>
<body>
<h1>Node Websocket Server</h1>
<ul id='events'>
<li id='event'></li>
</ul>
</body>
</html>