Commit a690c2e0 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

using native reconection feature from EventSource javascript class

parent 7982a799
......@@ -292,6 +292,13 @@
var onerrorCallback = function(event) {
Log4js.info("[" + this.type + "] error (disconnected by server):", event);
if ((this.pushstream.readyState === PushStream.OPEN) &&
(this.type === EventSourceWrapper.TYPE) &&
(event.type === 'error') &&
(this.connection.readyState === EventSource.CONNECTING)) {
// EventSource already has a reconection function using the last-event-id header
return;
}
this._closeCurrentConnection();
this.pushstream._onerror({type: ((event && (event.type === "load")) || (this.pushstream.readyState === PushStream.CONNECTING)) ? "load" : "timeout"});
}
......@@ -754,8 +761,10 @@
this.wrapper.connect();
} catch (e) {
//each wrapper has a cleanup routine at disconnect method
if (this.wrapper) {
this.wrapper.disconnect();
}
}
},
_disconnect: function() {
......@@ -768,7 +777,9 @@
_onopen: function() {
this.reconnecttimer = clearTimer(this.reconnecttimer);
this._setState(PushStream.OPEN);
if (this._lastUsedMode > 0) {
this._lastUsedMode--; //use same mode on next connection
}
},
_onclose: function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment