From aff844b94ae2cbf9ab9fc7cf662bc468a6c2f0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 30 Nov 2011 01:00:16 +0100 Subject: For xhrPolling, call onopen only after we get our first response --- priv/bullet.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'priv/bullet.js') 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}); -- cgit v1.2.3