-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
52 lines (51 loc) · 1.57 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
49
50
51
52
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Controller</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
.wrap {
position: fixed;
top: 50%;
left: 50%;
width: 500px;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div class="wrap">
<div class="row">
<button class="btn btn-primary col-md-3 mb-3" onclick="left()">Left</button>
</div>
<div class="row">
<button class="btn btn-primary col-md-3 mb-3" onclick="right()">Right</button>
</div>
</div>
<script>
const socket = io("http://localhost:8000");
socket.on("connect", () => {
console.log("connected");
})
function left() {
socket.emit("signal", {
direction: 0
})
}
function right() {
socket.emit("signal", {
direction: 1
})
}
function random() {
socket.emit("set-random", {
direction: 1
})
}
</script>
</body>
</html>