summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-30 15:11:32 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-30 15:11:32 (GMT)
commita81d48a3beef8b63fd19cc272a6388ad9e21bb4c (patch)
tree712787dcd19c2d2d1b5d4f26feca78f88c37ac87 /test
parentb4165f9269cb71ccb20e9b525c06951e0033ea2b (diff)
reconnecting session works now
Diffstat (limited to 'test')
-rw-r--r--test/socket.html36
1 files changed, 25 insertions, 11 deletions
diff --git a/test/socket.html b/test/socket.html
index ae13e19..0363b20 100644
--- a/test/socket.html
+++ b/test/socket.html
@@ -23,15 +23,21 @@
$('#rawmsg').text("");
this.sock = new WebSocket("ws://localhost:4080/public/socket");
this.sock.onmessage = function (event) {
+ $('#rawmsg').append(event.data);
msg = $.parseJSON(event.data)
- if (msg.TYPE == "ACK") {
- $('#sessionid').val(msg.ID);
+ switch (msg.TYPE) {
+ case "ACK":
+ $('#sessionid').val(msg.ID);
+ $('#buttonrun').attr('disabled','disabled')
+ $('#buttonreconnect').attr('disabled','disabled')
+ $('#buttoncancel').removeAttr('disabled')
+ break;
+ case "DONE":
+ init();
+ break;
}
- $('#rawmsg').append(event.data);
}
this.sock_onopen = function() {
- this.req.COMMAND = "new";
- this.req.TIMEOUT = 200;
this.sock.send(JSON.stringify(this.req));
}
this.sock.onopen = this.sock_onopen.bind(this);
@@ -43,24 +49,31 @@
var s;
function run() {
- req = { LOGIN_NAME: "heslinki",
+ req = { COMMAND: "new",
+ TIMEOUT: 200,
+ LOGIN_NAME: "heslinki",
PASSWORD: "12423",
SHOW_ID: 10002,
CLEAR_SHOW_CARTS: true,
SOURCE_URI: "fake://10000" };
s = new Session(req);
- $('#buttonrun').attr('disabled','disabled')
- $('#buttoncancel').removeAttr('disabled')
+ }
+
+ function reconnect() {
+ req = { COMMAND: "reconnect",
+ LOGIN_NAME: "heslinki",
+ ID: $('#sessionid').val() };
+ s = new Session(req);
}
function cancel() {
s.cancel();
- $('#buttonrun').removeAttr('disabled')
- $('#buttoncancel').attr('disabled','disabled')
}
function init() {
+ $('#sessionid').val("");
$('#buttonrun').removeAttr('disabled')
+ $('#buttonreconnect').removeAttr('disabled')
$('#buttoncancel').attr('disabled','disabled')
}
</script>
@@ -71,7 +84,8 @@
<button id="buttonrun" onclick="run()">start</button>
<button id="buttoncancel" onclick="cancel()">cancel</button>
- <span></span><input id="sessionid" type="text" size="45" label="ID">
+ <input id="sessionid" type="text" size="45" label="ID">
+ <button id="buttonreconnect" onclick="reconnect()">reconnect</button>
<div id="rawmsg" class="data"></div>
</body>
</html>