-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
90 lines (84 loc) · 2.87 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
window.addEventListener("load", function (evt) {
var output = document.getElementById("output");
var input = document.getElementById("input");
var ws;
var print = function (message) {
var d = document.createElement("div");
d.textContent = message;
output.appendChild(d);
output.scroll(0, output.scrollHeight);
};
document.getElementById("open").onclick = function (evt) {
const endpoint = document.getElementById("endpoint").value;
if (ws) {
return false;
}
ws = new WebSocket(endpoint);
ws.onopen = function (evt) {
print("OPEN");
}
ws.onclose = function (evt) {
print("CLOSE");
ws = null;
}
ws.onmessage = function (evt) {
print("RESPONSE: " + evt.data);
}
ws.onerror = function (evt) {
print("ERROR: " + evt.data);
}
return false;
};
document.getElementById("send").onclick = function (evt) {
if (!ws) {
return false;
}
print("SEND: " + input.value);
ws.send(input.value);
return false;
};
document.getElementById("close").onclick = function (evt) {
if (!ws) {
return false;
}
ws.close();
return false;
};
});
</script>
</head>
<body>
<h1>Automox Websocket Test Utility</h1>
<p>The purpose of this site is for testing websocket connections for troubleshooting Automox's Remote Control feature.</p>
<p>Connection to: <label for="endpoint">
<input type="text" id="endpoint" name="endpoint"
value="wss://changeme.rc.automox.net/"
style="width: 200px"><br>
</label>
</p>
<table>
<tr>
<td valign="top" width="50%">
<p>Click "Open" to create a connection to the server,
"Send" to send a message to the server and "Close" to close the connection.
You can change the message and send multiple times.
<p>
<form>
<button id="open">Open</button>
<button id="close">Close</button>
<p><input id="input" type="text" value="Hello world!">
<button id="send">Send</button>
</form>
</td>
<td valign="top" width="50%">
<div id="output" style="max-height: 70vh;overflow-y: scroll;"></div>
</td>
</tr>
</table>
</body>
</html>