-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsockettest.html
50 lines (50 loc) · 1.28 KB
/
websockettest.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Websockettest</title>
<script>
var i = 0;
var sock = new WebSocket("ws://localhost:4242");
sock.onmessage = function (event) {
console.log(event.data);
if (i == 0) {
sock.send(JSON.stringify({event:"select_round", round:"testround"}));
}
else if (i == 1) {
sock.send(JSON.stringify({event:"connect_buzzergroup", type: "keyboard", device: "/dev/input/by-id/usb-046d_Gaming_Keyboard_G110-event-kbd"}));
}
else if (i == 2) {
sock.send(JSON.stringify({event:"add_player", color:"#FF12aa"}));
}
else if (i == 3) {
sock.send(JSON.stringify({event:"update_player_name", name:"Manuel"}));
}
else if (i == 5) {
sock.send(JSON.stringify({event:"confirm_player"}));
}
else if (i == 6) {
sock.send(JSON.stringify({event:"add_player", color:"#bb12aa"}));
}
else if (i == 7) {
sock.send(JSON.stringify({event:"update_player_name", name:"Fitsch"}));
}
else if (i == 9) {
sock.send(JSON.stringify({event:"confirm_player"}));
}
else if (i == 10) {
sock.send(JSON.stringify({event:"start"}));
}
else if (i == 11) {
sock.send(JSON.stringify({event:"select_answer", category:0, answer:0}));
}
i++;
};
sock.onopen = function (event) {
sock.send(JSON.stringify({event:"ready"}));
}
</script>
</head>
<body>
</body>
</html>