From 6a189ed876a607797d381af0a5a9113bb0d7e0e5 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Tue, 20 Aug 2013 00:11:39 +0200 Subject: [PATCH] fixed missing fallback if serverside websocket fails --- web/xynt-streaming.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/xynt-streaming.js b/web/xynt-streaming.js index f80e8e8..1751ca0 100644 --- a/web/xynt-streaming.js +++ b/web/xynt-streaming.js @@ -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: "", -- 2.17.1