-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.html
More file actions
52 lines (52 loc) · 1.47 KB
/
client.html
File metadata and controls
52 lines (52 loc) · 1.47 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
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var socket = null;
var isopen = false;
window.onload = function() {
socket = new WebSocket("ws://127.0.0.1:9000");
socket.onopen = function() {
console.log("Connected!");
isopen = true;
}
socket.onmessage = function(e) {
console.log("Text message received: " + e.data);
}
socket.onclose = function(e) {
console.log("Connection closed.");
socket = null;
isopen = false;
}
};
function sendText() {
if (isopen) {
socket.send("Hello, world!");
console.log("Text message sent.");
} else {
console.log("Connection not opened.")
}
};
function sendConfig(fill_timeout) {
if (isopen) {
socket.send("{\"type\":\"CONFIG\",\"fill_timeout\":" + fill_timeout + "}");
console.log("Text message sent.");
} else {
console.log("Connection not opened.")
}
};
</script>
</head>
<body>
<h1>Basic Client</h1>
<button onclick='sendText();'>Send Text Message</button>
</body>
<div>
<h2>Modify Config</h2>
<form name="config_form" action="" method="GET">
<label for="fill_timeout">Fill timeout</label>
<input type="number" min="0" max="10" step="0.1" name="fill_timeout" value="5">seconds<p>
<input type="button" name="button" value="Send Config" onClick="sendConfig(this.form.fill_timeout.value)">
</form>
</div>
</html>