author | ymh <ymh.work@gmail.com> |
Thu, 22 Jan 2015 07:04:42 +0100 | |
changeset 108 | 082b64a5c699 |
parent 43 | e27c3c1c57f1 |
permissions | -rw-r--r-- |
43
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
<!DOCTYPE html> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
<html> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
<head> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
<link rel="icon" href="data:;base64,="> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
<script type="text/javascript"> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
var sock = null; |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
var ellog = null; |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
|
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
window.onload = function() { |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
|
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
ellog = document.getElementById('log'); |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
|
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
var wsuri; |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
if (window.location.protocol === "file:") { |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
wsuri = "ws://127.0.0.1:8090/broadcast"; |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
} else { |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
wsuri = "ws://" + window.location.hostname + ":8090/broadcast"; |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
} |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
if ("WebSocket" in window) { |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
sock = new WebSocket(wsuri); |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
} else if ("MozWebSocket" in window) { |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
sock = new MozWebSocket(wsuri); |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
} else { |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
log("Browser does not support WebSocket!"); |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
window.location = "http://autobahn.ws/unsupportedbrowser"; |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
} |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
|
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
if (sock) { |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
sock.onopen = function() { |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
log("Connected to " + wsuri); |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
} |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
|
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
sock.onclose = function(e) { |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
log("Connection closed (wasClean = " + e.wasClean + ", code = " + e.code + ", reason = '" + e.reason + "')"); |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
sock = null; |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
} |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
|
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
sock.onmessage = function(e) { |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
39 |
log("Got message: " + e.data); |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |
} |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
} |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
}; |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
|
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
44 |
function log(m) { |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
ellog.innerHTML += m + '\n'; |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
ellog.scrollTop = ellog.scrollHeight; |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
}; |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
</script> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
49 |
<link rel="stylesheet" type="text/css" href="/static/css/base.css"> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
</head> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
51 |
<body> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
<h1>OSC websocket Test</h1> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
<noscript>You must enable JavaScript</noscript> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
<pre id="log"></pre> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
</body> |
e27c3c1c57f1
end of admin. change the index page and add a redirect to it on the landing page
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
</html> |