vendor/assets/javascripts/faye-browser.js in faye-rails-2.0.1 vs vendor/assets/javascripts/faye-browser.js in faye-rails-2.0.3
- old
+ new
@@ -1,11 +1,11 @@
(function() {
(function() {
'use strict';
var Faye = {
- VERSION: '1.1.1',
+ VERSION: '1.1.2',
BAYEUX_VERSION: '1.0',
ID_LENGTH: 160,
JSONP_CALLBACK: 'jsonpcallback',
CONNECTION_TYPES: ['long-polling', 'cross-origin-long-polling', 'callback-polling', 'websocket', 'eventsource', 'in-process'],
@@ -1692,12 +1692,12 @@
this._dispatcher.clientId, Faye.URI.stringify(this.endpoint), message);
if (!this.batching) return Faye.Promise.fulfilled(this.request([message]));
this._outbox.push(message);
- this._flushLargeBatch();
this._promise = this._promise || new Faye.Promise();
+ this._flushLargeBatch();
if (message.channel === Faye.Channel.HANDSHAKE) {
this.addTimeout('publish', 0.01, this._flush, this);
return this._promise;
}
@@ -2367,11 +2367,11 @@
for (var i = 0, n = messages.length; i < n; i++) this._pending.add(messages[i]);
var promise = new Faye.Promise();
this.callback(function(socket) {
- if (!socket) return;
+ if (!socket || socket.readyState !== 1) return;
socket.send(Faye.toJSON(messages));
Faye.Promise.fulfill(promise, socket);
}, this);
this.connect();
@@ -2644,10 +2644,11 @@
},
request: function(messages) {
var xhrClass = Faye.ENV.XDomainRequest ? XDomainRequest : XMLHttpRequest,
xhr = new xhrClass(),
+ id = ++Faye.Transport.CORS._id,
headers = this._dispatcher.headers,
self = this,
key;
xhr.open('POST', Faye.URI.stringify(this.endpoint), true);
@@ -2660,10 +2661,11 @@
}
}
var cleanUp = function() {
if (!xhr) return false;
+ Faye.Transport.CORS._pending.remove(id);
xhr.onload = xhr.onerror = xhr.ontimeout = xhr.onprogress = null;
xhr = null;
};
xhr.onload = function() {
@@ -2684,13 +2686,20 @@
cleanUp();
self._handleError(messages);
};
xhr.onprogress = function() {};
+
+ if (xhrClass === Faye.ENV.XDomainRequest)
+ Faye.Transport.CORS._pending.add({id: id, xhr: xhr});
+
xhr.send(this.encode(messages));
return xhr;
}
}), {
+ _id: 0,
+ _pending: new Faye.Set(),
+
isUsable: function(dispatcher, endpoint, callback, context) {
if (Faye.URI.isSameOrigin(endpoint))
return callback.call(context, false);
if (Faye.ENV.XDomainRequest)
\ No newline at end of file