Prevent pending events being skipped when remote echo comes
This fixes #241
This commit is contained in:
parent
5d8d139f44
commit
1e209b8613
1 changed files with 15 additions and 2 deletions
|
@ -46,13 +46,26 @@ export class SendQueue {
|
||||||
this._roomEncryption = roomEncryption;
|
this._roomEncryption = roomEncryption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_nextPendingEvent(current) {
|
||||||
|
if (!current) {
|
||||||
|
return this._pendingEvents.get(0);
|
||||||
|
} else {
|
||||||
|
const idx = this._pendingEvents.indexOf(current);
|
||||||
|
if (idx !== -1) {
|
||||||
|
return this._pendingEvents.get(idx + 1);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_sendLoop(log) {
|
_sendLoop(log) {
|
||||||
this._isSending = true;
|
this._isSending = true;
|
||||||
this._sendLoopLogItem = log.runDetached("send queue flush", async log => {
|
this._sendLoopLogItem = log.runDetached("send queue flush", async log => {
|
||||||
|
let pendingEvent;
|
||||||
try {
|
try {
|
||||||
for (let i = 0; i < this._pendingEvents.length; i += 1) {
|
// eslint-disable-next-line no-cond-assign
|
||||||
|
while (pendingEvent = this._nextPendingEvent(pendingEvent)) {
|
||||||
await log.wrap("send event", async log => {
|
await log.wrap("send event", async log => {
|
||||||
const pendingEvent = this._pendingEvents.get(i);
|
|
||||||
log.set("queueIndex", pendingEvent.queueIndex);
|
log.set("queueIndex", pendingEvent.queueIndex);
|
||||||
try {
|
try {
|
||||||
await this._sendEvent(pendingEvent, log);
|
await this._sendEvent(pendingEvent, log);
|
||||||
|
|
Reference in a new issue