diff options
author | Loïc Hoguin <[email protected]> | 2011-11-17 16:03:13 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2011-11-17 16:03:13 +0100 |
commit | fed58882493f1befe859115129dff0d80425ef6e (patch) | |
tree | 4f793d68af49c11fda4f04adcfd2d7f1567366c0 /priv | |
parent | 0e7850239b59fa9da84b4be9c7da7ea60179630b (diff) | |
download | bullet-fed58882493f1befe859115129dff0d80425ef6e.tar.gz bullet-fed58882493f1befe859115129dff0d80425ef6e.tar.bz2 bullet-fed58882493f1befe859115129dff0d80425ef6e.zip |
Fix errors at connection triggering an infinite connection-trying loop
Diffstat (limited to 'priv')
-rw-r--r-- | priv/bullet.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/priv/bullet.js b/priv/bullet.js index 38d80ea..9f61f00 100644 --- a/priv/bullet.js +++ b/priv/bullet.js @@ -154,7 +154,7 @@ var c = 0; for (var f in transports){ - if (tn >= c){ + if (tn == c){ var t = transports[f](); if (t){ var ret = new t.transport(url); @@ -167,6 +167,8 @@ c++; } + + return false; } var stream = new function(){ @@ -178,6 +180,12 @@ function init(){ readyState = CONNECTING; + if (!transport){ + // No transport, give up + // @todo Trigger a disconnect error + return false; + } + transport.onopen = function(){ // We got a connection, reset the poll delay delay = delayDefault; @@ -201,11 +209,10 @@ // Close happened on connect, select next transport if (readyState == CONNECTING){ tn++; - } else{ - delay *= 2; - if (delay > 10000){ - delay = 10000; - } + + delay *= 2; + if (delay > 10000){ + delay = 10000; } setTimeout(function(){ |