-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay-messages.html
More file actions
54 lines (45 loc) · 1.3 KB
/
display-messages.html
File metadata and controls
54 lines (45 loc) · 1.3 KB
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
53
54
<html>
<script src="https://unpkg.com/eventemitter3@latest/umd/eventemitter3.min.js"></script>
<body>
<h1>Hello, World!</h1>
</body>
<script>
function disp(s) {
const el = document.createElement("div");
el.innerText = s
document.querySelector("body").appendChild(el);
}
function send(msg) {
disp("< " + msg);
external.invoke(msg);
}
function _globalWvLinewise(msg) {
disp("> " + JSON.stringify(msg));
if ((msg.name == "in") && (msg.type == "line")) {
send(JSON.stringify({"msg":"out", descriptor: 1, data: msg.data}));
}
if (msg.type == "paused") {
setTimeout(() => {
send(JSON.stringify({"msg":"streamContinue","name":msg.name}));
}, 1000);
}
if ((msg.type == "finished") && (msg.name == "in")) {
disp('SENDING \'{"msg":"exit", "status": 0}\' - in 10 seconds');
setTimeout(() => {
send('{"msg":"exit", "status": 0}');
}, 10000);
}
}
setInterval(() => {
document.querySelector("h1").innerText = new Date();
}, 1000);
setTimeout(() => {
send('{"msg":"params"}');
send('{"msg":"streamList"}');
setTimeout(() => {
send('{"msg":"streamStart","name":"in","count":5}');
send('{"msg":"streamStart","name":"cargo","count":5}');
}, 1000);
}, 100);
</script>
</html>