Skip to content

Commit

Permalink
Make WebSocketTransport#resend async to avoid feedback loop that happ…
Browse files Browse the repository at this point in the history
…ens if messages are sent during disconnection.
  • Loading branch information
jcoglan committed Oct 18, 2010
1 parent e8a82c6 commit 63056df
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions javascript/network/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ Faye.WebSocketTransport = Faye.Class(Faye.Transport, {
};
},

// We must do this asynchronously otherwise the socket can get
// into a feedback loop if messages were sent during disconnection
resend: function() {
var messages = Faye.map(this._messages, function(id, msg) { return msg });
this.request(messages);
var self = this;
setTimeout(function() {
var messages = Faye.map(self._messages, function(id, msg) { return msg });
self.request(messages);
}, 10);
}
});

Expand Down

0 comments on commit 63056df

Please sign in to comment.