summaryrefslogtreecommitdiff
path: root/web-static/socket.html
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-09-24 21:56:10 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-09-24 21:56:10 (GMT)
commitc2ac2add756be8be1f74827bdc943636187e8bbf (patch)
treeea2d12d0e53bf40e3f66a88994f8d435de862f62 /web-static/socket.html
parent0ed3e9fbc1ea1b69b66f0f494bd06dd8c272ebdf (diff)
addes subscribe command to websocket
Diffstat (limited to 'web-static/socket.html')
-rw-r--r--web-static/socket.html34
1 files changed, 34 insertions, 0 deletions
diff --git a/web-static/socket.html b/web-static/socket.html
index 466431d..fc1b270 100644
--- a/web-static/socket.html
+++ b/web-static/socket.html
@@ -61,6 +61,34 @@
function init() {
$('#buttonstate').removeAttr('disabled','disabled');
}
+
+ function Subscription(req) {
+ this.req = req
+ this.sock = new WebSocket("wss://rdimport.helsinki.at/rhctl/socket");
+ this.sock_onmessage = function (event) {
+ $('#rawmsg').text(event.data);
+ }
+ this.sock.onmessage = this.sock_onmessage.bind(this);
+
+ this.sock_onopen = function() {
+ this.sock.send(JSON.stringify(this.req));
+ $('#buttonsub').attr('disabled','disabled')
+ }
+ this.sock.onopen = this.sock_onopen.bind(this);
+ }
+
+ var sub;
+
+ function sub() {
+ req = { COMMAND: "subscribe", ARGS: [ $('#subtype').val() ]};
+ sub = new Subscription(req);
+ }
+
+ function init() {
+ $('#buttonstate').removeAttr('disabled','disabled');
+ $('#buttonsub').removeAttr('disabled','disabled');
+ }
+
</script>
</head>
<body onload="init()">
@@ -72,5 +100,11 @@
<div id="statemsg" class="data"></div>
</div>
+ <div>
+ <input id="subtype" type="text" size="30" value="state">
+ <button id="buttonsub" onclick="sub()">subscribe</button>
+ <div id="rawmsg" class="data"></div>
+ </div>
+
</body>
</html>