/
index.html
33 lines (30 loc) · 843 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script>
function start() {
var connection = new WebSocket('ws://localhost:8888/websocket');
connection.onopen = function () {
document.getElementById("status").innerHTML = "Connected";
};
connection.onclose = function() {
document.getElementById("status").innerHTML = "Not Connected";
};
connection.onmessage = function (evt) {
document.getElementById("messages").innerHTML += evt.data + "<br/>";
};
}
</script>
</head>
<body>
<button onclick="start();">Connect to server</button>
[<span id="status">Not Connected</span>]
<br/>
<hr/>
<div id="messages">
<strong>Server Messages</strong><br/>
</div>
</body>
</html>