summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-11-30 01:00:16 +0100
committerLoïc Hoguin <[email protected]>2011-11-30 01:02:59 +0100
commitaff844b94ae2cbf9ab9fc7cf662bc468a6c2f0ce (patch)
treedb07fc01186c979656db704ee29e0ad357d5399a
parent18585973b2b84dd58658d09c3f7423612c9f912e (diff)
downloadbullet-aff844b94ae2cbf9ab9fc7cf662bc468a6c2f0ce.tar.gz
bullet-aff844b94ae2cbf9ab9fc7cf662bc468a6c2f0ce.tar.bz2
bullet-aff844b94ae2cbf9ab9fc7cf662bc468a6c2f0ce.zip
For xhrPolling, call onopen only after we get our first response
-rw-r--r--priv/bullet.js12
1 files changed, 5 insertions, 7 deletions
diff --git a/priv/bullet.js b/priv/bullet.js
index 69ac2cf..8730315 100644
--- a/priv/bullet.js
+++ b/priv/bullet.js
@@ -71,7 +71,7 @@
var fake = {
readyState: CONNECTING,
send: function(data){
- if (this.readyState != OPEN){
+ if (this.readyState != CONNECTING && this.readyState != OPEN){
return false;
}
@@ -107,12 +107,6 @@
};
function poll(){
- // We should probably test a connection before doing this
- if (fake.readyState == CONNECTING){
- fake.readyState = OPEN;
- fake.onopen(fake);
- }
-
xhr = $.ajax({
type: 'GET',
cache: false,
@@ -121,6 +115,10 @@
data: {},
headers: {'X-Socket-Transport': 'xhrPolling'},
success: function(data){
+ if (fake.readyState == CONNECTING){
+ fake.readyState = OPEN;
+ fake.onopen(fake);
+ }
// Connection might have closed without a response body
if (data.length != 0){
fake.onmessage({'data': data});