app/assets/javascripts/faye-authentication.js in faye-authentication-1.7.0 vs app/assets/javascripts/faye-authentication.js in faye-authentication-1.8.0

- old
+ new

@@ -2,10 +2,11 @@ this._client = client; this._endpoint = endpoint || '/faye/auth'; this._signatures = {}; this._outbox = {}; this._options = options || {}; + this._options.retry_delay = this._options.retry_delay || 1000; this._waiting_signatures = []; this._timer = null; } FayeAuthentication.prototype.endpoint = function() { @@ -29,10 +30,15 @@ $.post(self.endpoint(), {messages: messages}, function(response) { $.each(messages, function(key, params) { var signature = $.grep(response.signatures || [], function(e) { return (e.channel == params.channel && e.clientId == params.clientId); })[0]; + if (typeof signature === 'undefined') { + self.error('No signature found in ajax reply for channel ' + params.channel + ' and clientId ' + params.clientId); + } else if (signature && !signature.signature) { + self.error('Error when fetching signature for channel ' + params.channel + ' and clientId ' + params.clientId + ', error was : "' + signature.error + '"'); + } Faye.Promise.resolve(self._signatures[params.clientId][params.channel], signature ? signature.signature : null); }); }, 'json').fail(function(xhr, textStatus, e) { self.error('Failure when trying to fetch JWT signature for data "' + JSON.stringify(messages) + '", error was : ' + textStatus); $.each(messages, function(key, params) { @@ -103,10 +109,13 @@ var channel = outbox_message.message.subscription || outbox_message.message.channel; this._signatures[outbox_message.clientId][channel] = null; outbox_message.message.retried = true; delete outbox_message.message.id; delete this._outbox[message.id]; - this._client._sendMessage(outbox_message.message, {}, callback); + var self = this; + setTimeout(function() { + self._client._sendMessage(outbox_message.message, {}, callback); + }, this._options.retry_delay); } else { callback(message); } };