[Pkg-javascript-commits] [sockjs-client] 280/434: Timeout/delay/rto is dependent on number of rtt.
Tonnerre Lombard
tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:19 UTC 2014
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch master
in repository sockjs-client.
commit 833bcf2393d92e86eacdffecb7f05e4096f27ba1
Author: Marek Majkowski <majek04 at gmail.com>
Date: Wed Jan 11 11:22:28 2012 +0000
Timeout/delay/rto is dependent on number of rtt.
Must move the timeout code to _try_next_protocol, and make the timeout dependent on roundTrips (per protocol value)
---
lib/sockjs.js | 31 ++++++++++++++++---------------
lib/trans-iframe-eventsource.js | 1 +
lib/trans-iframe-htmlfile.js | 1 +
lib/trans-iframe-xhr-polling.js | 1 +
4 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/lib/sockjs.js b/lib/sockjs.js
index 3b9bbc9..07f7ee0 100644
--- a/lib/sockjs.js
+++ b/lib/sockjs.js
@@ -88,27 +88,13 @@ SockJS.prototype._didClose = function(code, reason) {
if (that._transport)
that._transport.doCleanup();
that._transport = null;
- if (that._transport_tref) {
- clearTimeout(that._transport_tref);
- that._transport_tref = null;
- }
+
var close_event = new SimpleEvent("close", {code: code,
reason: reason,
wasClean: utils.userSetCode(code)});
if (!utils.userSetCode(code) && that.readyState === SockJS.CONNECTING) {
if (that._try_next_protocol(close_event)) {
- that._transport_tref = setTimeout(
- function() {
- if (that.readyState === SockJS.CONNECTING) {
- // I can't understand how it is possible to run
- // this timer, when the state is CLOSED, but
- // apparently in IE everythin is possible.
- that._didClose(2007,
- "Transport timeouted");
- }
- }, that._options.rto || 5000);
-
return;
}
close_event = new SimpleEvent("close", {code: 2000,
@@ -156,6 +142,10 @@ SockJS.prototype._try_next_protocol = function(close_event) {
that._debug('Closed transport:', that.protocol, ''+close_event);
that.protocol = null;
}
+ if (that._transport_tref) {
+ clearTimeout(that._transport_tref);
+ that._transport_tref = null;
+ }
while(1) {
var protocol = that.protocol = that._protocols.shift();
@@ -179,6 +169,17 @@ SockJS.prototype._try_next_protocol = function(close_event) {
!SockJS[protocol].enabled(that._options)) {
that._debug('Skipping transport:', protocol);
} else {
+ var roundTrips = SockJS[protocol].roundTrips || 1;
+ var to = ((that._options.rto || 0) * roundTrips) || 5000;
+ that._transport_tref = utils.delay(to, function() {
+ if (that.readyState === SockJS.CONNECTING) {
+ // I can't understand how it is possible to run
+ // this timer, when the state is CLOSED, but
+ // apparently in IE everythin is possible.
+ that._didClose(2007, "Transport timeouted");
+ }
+ });
+
var connid = utils.random_string(8);
var trans_url = that._base_url + '/' + that._server + '/' + connid;
that._debug('Opening transport:', protocol, ' url:'+trans_url,
diff --git a/lib/trans-iframe-eventsource.js b/lib/trans-iframe-eventsource.js
index 77d85d1..a13bc67 100644
--- a/lib/trans-iframe-eventsource.js
+++ b/lib/trans-iframe-eventsource.js
@@ -12,6 +12,7 @@ EventSourceIframeTransport.enabled = function () {
};
EventSourceIframeTransport.need_body = true;
+EventSourceIframeTransport.roundTrips = 3; // html, javascript, eventsource
var EventSourceTransport = FacadeJS['w-iframe-eventsource'] = function (ri, trans_url) {
diff --git a/lib/trans-iframe-htmlfile.js b/lib/trans-iframe-htmlfile.js
index 8cf1eb2..45e376f 100644
--- a/lib/trans-iframe-htmlfile.js
+++ b/lib/trans-iframe-htmlfile.js
@@ -19,6 +19,7 @@ HtmlFileIframeTransport.enabled = function (options) {
};
HtmlFileIframeTransport.need_body = true;
+HtmlFileIframeTransport.roundTrips = 3; // html, javascript, htmlfile
var HtmlFileTransport = FacadeJS['w-iframe-htmlfile'] = function (ri, trans_url) {
diff --git a/lib/trans-iframe-xhr-polling.js b/lib/trans-iframe-xhr-polling.js
index 412ea59..2e148d8 100644
--- a/lib/trans-iframe-xhr-polling.js
+++ b/lib/trans-iframe-xhr-polling.js
@@ -12,6 +12,7 @@ XhrPollingIframeTransport.enabled = function () {
};
XhrPollingIframeTransport.need_body = true;
+XhrPollingIframeTransport.roundTrips = 3; // html, javascript, xhr
var XhrPollingITransport = FacadeJS['w-iframe-xhr-polling'] = function (ri, trans_url) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git
More information about the Pkg-javascript-commits
mailing list