equal
deleted
inserted
replaced
|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <head> |
|
4 <link rel="icon" href="data:;base64,="> |
|
5 <script type="text/javascript"> |
|
6 var sock = null; |
|
7 var ellog = null; |
|
8 |
|
9 window.onload = function() { |
|
10 |
|
11 ellog = document.getElementById('log'); |
|
12 |
|
13 var wsuri; |
|
14 if (window.location.protocol === "file:") { |
|
15 wsuri = "ws://127.0.0.1:8090/broadcast"; |
|
16 } else { |
|
17 wsuri = "ws://" + window.location.hostname + ":8090/broadcast"; |
|
18 } |
|
19 if ("WebSocket" in window) { |
|
20 sock = new WebSocket(wsuri); |
|
21 } else if ("MozWebSocket" in window) { |
|
22 sock = new MozWebSocket(wsuri); |
|
23 } else { |
|
24 log("Browser does not support WebSocket!"); |
|
25 window.location = "http://autobahn.ws/unsupportedbrowser"; |
|
26 } |
|
27 |
|
28 if (sock) { |
|
29 sock.onopen = function() { |
|
30 log("Connected to " + wsuri); |
|
31 } |
|
32 |
|
33 sock.onclose = function(e) { |
|
34 log("Connection closed (wasClean = " + e.wasClean + ", code = " + e.code + ", reason = '" + e.reason + "')"); |
|
35 sock = null; |
|
36 } |
|
37 |
|
38 sock.onmessage = function(e) { |
|
39 log("Got message: " + e.data); |
|
40 } |
|
41 } |
|
42 }; |
|
43 |
|
44 function log(m) { |
|
45 ellog.innerHTML += m + '\n'; |
|
46 ellog.scrollTop = ellog.scrollHeight; |
|
47 }; |
|
48 </script> |
|
49 <link rel="stylesheet" type="text/css" href="/static/css/base.css"> |
|
50 </head> |
|
51 <body> |
|
52 <h1>OSC websocket Test</h1> |
|
53 <noscript>You must enable JavaScript</noscript> |
|
54 <pre id="log"></pre> |
|
55 </body> |
|
56 </html> |