author | ymh <ymh.work@gmail.com> |
Wed, 15 Oct 2014 13:09:47 +0200 | |
changeset 24 | eb1f7b06001f |
parent 22 | 986ee928a866 |
child 43 | e27c3c1c57f1 |
permissions | -rw-r--r-- |
0 | 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> |
|
2
fc1ab0074e29
export config in config file + add static file
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
49 |
<link rel="stylesheet" type="text/css" href="/static/css/base.css"> |
0 | 50 |
</head> |
51 |
<body> |
|
52 |
<h1>OSC websocket Test</h1> |
|
53 |
<noscript>You must enable JavaScript</noscript> |
|
2
fc1ab0074e29
export config in config file + add static file
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
54 |
<pre id="log"></pre> |
0 | 55 |
</body> |
56 |
</html> |