frontend.html (748B)
1 <!DOCTYPE>
2 <html>
3 <head>
4 <script>
5 var socket = null;
6 var sent = 0;
7 var recv = 0;
8 var length = 65536;
9
10 function open(evt) {
11 }
12
13 function message(msg) {
14 }
15
16 function onmessage(evt) {
17 var obj = document.getElementById("log");
18 obj.innerHTML = "<p>" + evt.data + "</p>" + obj.innerHTML;
19 }
20
21 function connect() {
22 socket = new WebSocket("wss://127.0.0.1:8888/connect");
23
24 socket.onopen = function(evt) { open(evt) };
25 socket.onclose = function(evt) { alert("closed"); };
26 socket.onmessage = function(evt) { onmessage(evt) };
27 socket.onerror = function(evt) { alert("onerror"); };
28 }
29 </script>
30 </head>
31
32 <body>
33
34 <form action="/" onsubmit="connect(); return false;">
35 <input type="submit" value="connect">
36 </form>
37
38 <div id="log">
39 </div>
40
41 </body>
42 </html>