Fix event dispatching and attempt to reconnect on poll error

This commit is contained in:
Trever Fischer
2012-11-18 09:20:53 -05:00
parent 25ae5444f7
commit ec6cc0db7d

View File

@@ -20,7 +20,6 @@ EventPoller.prototype.start = function() {
};
EventPoller.prototype.dispatchEvent = function(evt) {
console.log(evt['type']);
if (evt['type'] in this.handlers) {
this.handlers[evt['type']].forEach(function (callback, idx, handlers) {
callback(evt, evt['payload']);
@@ -50,6 +49,7 @@ EventPoller.prototype._failedPoll = function(data) {
});
}
this.id = 0;
window.setTimeout(this.poll.bind(this), 5000);
}
EventPoller.prototype._successfulPoll = function(data) {
@@ -78,7 +78,8 @@ EventPoller.prototype._successfulPoll = function(data) {
var that = this;
$(data['events']).each(function(idx, evt) {
that.dispatchEvent(evt);
console.log(evt['event']['type']);
that.dispatchEvent(evt['event']);
});
if (data['is-live']) {