-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
65 lines (59 loc) · 1.32 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
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function wsstatus(){
if ("WebSocket" in window)
{
document.getElementById("m").innerHTML=('WebSockets supported!');
}
}
function printstatus(msg)
{
document.getElementById("m").innerHTML += '<br />' + msg;
}
function clearstatus()
{
document.getElementById("m").innerHTML = '';
}
function WebSocketShell()
{
if ("WebSocket" in window)
{
var server = "localhost:9998/server"
var ws = new WebSocket("ws://" + server);
printstatus ('Connecting to ' + server);
ws.onopen = function()
{
printstatus ('Connected!')
ws.send(document.getElementById('in').value);
printstatus('Command sent.. Waiting for server..')
};
ws.onmessage = function (evt)
{
var received_msg = evt.data;
clearstatus();
printstatus(received_msg);
};
ws.onclose = function(a)
{
clearstatus();
printstatus('Connection could not be estabilished. Closing websocket.');
};
}
else
{
printstatus("WebSocket NOT supported by your Browser!");
}
}
</script>
</head>
<body onload="wsstatus()">
<div id="sse"><p>
<b>Enter command: </b><input type="text" id="in" name="in" />
<button onclick="WebSocketShell()">Execute!</button></p>
</div>
<p><b>Status: </b></p>
<pre><div id="m"></div></pre>
</body>
</html>