aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Karneges <justin@affinix.com>2013-01-29 13:41:33 -0800
committerJustin Karneges <justin@affinix.com>2013-01-29 13:41:33 -0800
commitfbc1a60edbad95b7408597cba1072dceeb717d56 (patch)
treee331821e1b79b90ea3a93d468a525910e0a5fba1
parenta7d2425aae938cac829fb53e4ab85edd35e92d81 (diff)
downloadpollymer-fbc1a60edbad95b7408597cba1072dceeb717d56.tar
pollymer-fbc1a60edbad95b7408597cba1072dceeb717d56.tar.gz
make retry() public, change debugging
-rw-r--r--polldance.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/polldance.js b/polldance.js
index cf56770..2401074 100644
--- a/polldance.js
+++ b/polldance.js
@@ -135,7 +135,7 @@
if (self._delayNext) {
self._delayNext = false;
delaytime = Math.floor(Math.random() * self.maxDelay);
- console.log("polling again in " + delaytime + "ms");
+ console.log("PD: polling again in " + delaytime + "ms");
} else {
delaytime = 0; // always queue the call, to prevent browser "busy"
}
@@ -147,6 +147,9 @@
self._timer = setTimeout(function() { self._connect(); }, delaytime);
};
+ Request.prototype.retry = function () {
+ this._retry();
+ };
Request.prototype._connect = function () {
var self = this;
self._timer = window.setTimeout(function () { self._timeout(); }, TIMEOUT);
@@ -175,7 +178,7 @@
self._xhr.send(self._body);
- console.log("PollDance.Request start: " + self._url + " " + self._body);
+ console.log("PD: xhr " + self._url + " " + self._body);
} else { // Jsonp
@@ -202,7 +205,7 @@
src = self._url + "?" + params;
}
- console.log("PollDance.Request json-p " + this._callbackInfo.id + " " + src);
+ console.log("PD: json-p " + this._callbackInfo.id + " " + src);
this._addJsonpCallback(this._callbackInfo, src);
}
};
@@ -240,7 +243,7 @@
this._xhr.abort();
this._xhr = null;
} else { // Jsonp
- console.log("PollDance.Request json-p " + this._callbackInfo.id + " cancel");
+ console.log("PD: json-p " + this._callbackInfo.id + " cancel");
this._removeJsonpCallback(this._callbackInfo);
this._callbackInfo = null;
}
@@ -270,7 +273,7 @@
}
};
Request.prototype._jsonp_callback = function (result) {
- console.log("PollDance.Request json-p " + this._callbackInfo.id + " finished");
+ console.log("PD: json-p " + this._callbackInfo.id + " finished");
window.clearTimeout(this._timer);
this._timer = null;
@@ -318,8 +321,8 @@
}
var delaytime = this._retryTime * 1000;
- delaytime += Math.floor(Math.random() * self.maxDelay);
- console.log("trying again in " + delaytime + "ms");
+ delaytime += Math.floor(Math.random() * this.maxDelay);
+ console.log("PD: trying again in " + delaytime + "ms");
var self = this;
self._timer = setTimeout(function() { self._connect(); }, delaytime);