When rebuilding the channel, subscribe via last seen ID, so we don't miss messages from the time we were disconnected.

This commit is contained in:
Ian Gulliver
2014-05-18 11:20:44 +03:00
parent 63ac321537
commit 0380679ddb
3 changed files with 24 additions and 7 deletions

View File

@@ -423,13 +423,17 @@ Cosmopolite.prototype.createChannel_ = function() {
'onSuccess': this.onCreateChannel_,
},
];
// TODO(flamingcow): Need to restart from the latest message.
for (var subject in this.subscriptions_) {
var subscription = this.subscriptions_[subject];
var last_id = 0;
if (subscription.messages.length > 0) {
last_id = subscription.messages[subscription.messages.length - 1]['id'];
}
rpcs.push({
'command': 'subscribe',
'arguments': {
'subject': subject,
'messages': 0,
'last_id': last_id,
}
});
}