Commit e1116c9e285d1d5156ae906ca5573a5ca9c5ac2e
1 parent
e81f3fe030
Exists in
master
and in
1 other branch
add deck listener
Showing 1 changed file with 17 additions and 2 deletions Inline Diff
ws_debug.html
View file @
e1116c9
<!DOCTYPE html> | 1 | 1 | <!DOCTYPE html> | |
<html> | 2 | 2 | <html> | |
<head lang="en"> | 3 | 3 | <head lang="en"> | |
<meta charset="UTF-8"> | 4 | 4 | <meta charset="UTF-8"> | |
<title></title> | 5 | 5 | <title></title> | |
</head> | 6 | 6 | </head> | |
<body> | 7 | 7 | <body> | |
<ul> | 8 | 8 | <ul> | |
9 | 9 | |||
</ul> | 10 | 10 | </ul> | |
</body> | 11 | 11 | </body> | |
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | 12 | 12 | <script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script> | 13 | 13 | <script> | |
var loc = window.location, new_uri; | 14 | 14 | var loc = window.location, new_uri; | |
if (loc.protocol === "https:") { | 15 | 15 | if (loc.protocol === "https:") { | |
new_uri = "wss:"; | 16 | 16 | new_uri = "wss:"; | |
} else { | 17 | 17 | } else { | |
new_uri = "ws:"; | 18 | 18 | new_uri = "ws:"; | |
} | 19 | 19 | } | |
new_uri += "//" + loc.host; | 20 | 20 | new_uri += "//" + loc.host; | |
new_uri += "/ws/feed/496?subscribe-broadcast"; | 21 | 21 | var ws = new WebSocket(new_uri + '/ws/deck/496?subscribe-user'); | |
var ws = new WebSocket(new_uri); | 22 | 22 | ws.onopen = function () { | |
23 | console.log("websocket connected"); | |||
24 | }; | |||
25 | ws.onmessage = function (e) { | |||
26 | $('ul').append('<li>' + e.data + '</li>'); | |||
27 | }; | |||
28 | ws.onerror = function (e) { | |||
29 | console.error(e); | |||
30 | }; | |||
31 | ws.onclose = function (e) { | |||
32 | console.log("connection closed"); | |||
33 | }; | |||
34 | function send_message(msg) {1 | |||
35 | ws.send(msg); | |||
36 | } | |||
37 | var ws = new WebSocket(new_uri + '/ws/feed/496?subscribe-broadcast'); | |||
ws.onopen = function () { | 23 | 38 | ws.onopen = function () { | |
console.log("websocket connected"); | 24 | 39 | console.log("websocket connected"); | |
}; | 25 | 40 | }; | |
ws.onmessage = function (e) { | 26 | 41 | ws.onmessage = function (e) { | |
$('ul').append('<li>' + e.data + '</li>'); | 27 | 42 | $('ul').append('<li>' + e.data + '</li>'); | |
}; | 28 | 43 | }; | |
ws.onerror = function (e) { | 29 | 44 | ws.onerror = function (e) { | |
console.error(e); | 30 | 45 | console.error(e); | |
}; | 31 | 46 | }; | |
ws.onclose = function (e) { | 32 | 47 | ws.onclose = function (e) { | |
console.log("connection closed"); | 33 | 48 | console.log("connection closed"); | |
}; | 34 | 49 | }; | |
function send_message(msg) { | 35 | 50 | function send_message(msg) { | |
ws.send(msg); | 36 | 51 | ws.send(msg); | |
} | 37 | 52 | } | |
</script> | 38 | 53 | </script> | |
</html> | 39 | 54 | </html> | |