-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
48 lines (42 loc) · 1.44 KB
/
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
47
48
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Database connected to CanvasJS</title>
<script src="socket.io.js"></script>
<script src="jquery-3.5.1.js"></script>
<script src="canvasjs.min.js"></script>
<!-- <script src="https://cdn.socket.io/3.1.1/socket.io.min.js"></script> -->
</head>
<body>
<div id="chartContainer" style="height: 150px; width: 100%;"></div>
<div id="chartContainer2" style="height: 150px; width: 100%;"></div>
<div id="chartContainer3" style="height: 150px; width: 100%;"></div>
<div id="chartContainer4" style="height: 150px; width: 100%;"></div>
<div id="chartContainer5" style="height: 150px; width: 100%;"></div>
<script>
let socket = new WebSocket("ws://localhost:8011/");
console.log(socket)
socket.onopen = function (e) {
console.log("[open] Connection established");
console.log("Sending to server");
socket.send("Client Connected");
};
socket.onmessage = function (event) {
console.log(`[message] Data received from server: ${event.data}`);
};
socket.onclose = function (event) {
if (event.wasClean) {
console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
} else {
// e.g. server process killed or network down
// event.code is usually 1006 in this case
console.log('[close] Connection died');
}
};
socket.onerror = function (error) {
console.log(`[error] ${error.message}`);
};
</script>
</body>
</html>