fixed missing fallback if serverside websocket fails
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Mon, 19 Aug 2013 22:11:39 +0000 (00:11 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Mon, 19 Aug 2013 22:11:39 +0000 (00:11 +0200)
web/xynt-streaming.js

index f80e8e8..1751ca0 100644 (file)
@@ -18,6 +18,7 @@ function transport_ws(doc, xynt_streaming, page)
             if (this.readyState == 1) {
                 // connected
                 self.ws_cb("open");
+                self.init_steps = 1;
             }
         };
         this.ws.onmessage = function (msg) {
@@ -26,8 +27,11 @@ function transport_ws(doc, xynt_streaming, page)
             self.ctx_new += msg.data;
         };
         this.ws.onclose = function (msg) {
-            self.xynt_streaming.log("onclose");
-            self.ws_cb("close");
+            self.xynt_streaming.log("onclose"+self.init_steps);
+            if (self.init_steps == 0)
+                self.ws_cb("error");
+            else
+                self.ws_cb("close");
         };
         this.ws.onerror = function () {
             // on error
@@ -49,6 +53,8 @@ transport_ws.prototype = {
     stopped: true,
     failed: false,
 
+    init_steps: 0,
+
     ctx_old: "",
     ctx_old_len: 0,
     ctx_new: "",