Resilience to quick reconnects: always reprocess from cache first
This commit is contained in:
parent
f21dad1519
commit
0122cfd22a
2 changed files with 12 additions and 9 deletions
|
@ -1809,22 +1809,21 @@ type WhatIsThis = typeof window.WhatIsThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
connectCount += 1;
|
connectCount += 1;
|
||||||
const options = {
|
|
||||||
retryCached: connectCount === 1,
|
|
||||||
serverTrustRoot: window.getServerTrustRoot(),
|
|
||||||
};
|
|
||||||
|
|
||||||
window.Whisper.deliveryReceiptQueue.pause(); // avoid flood of delivery receipts until we catch up
|
window.Whisper.deliveryReceiptQueue.pause(); // avoid flood of delivery receipts until we catch up
|
||||||
window.Whisper.Notifications.disable(); // avoid notification flood until empty
|
window.Whisper.Notifications.disable(); // avoid notification flood until empty
|
||||||
|
|
||||||
// initialize the socket and start listening for messages
|
// initialize the socket and start listening for messages
|
||||||
window.log.info('Initializing socket and listening for messages');
|
window.log.info('Initializing socket and listening for messages');
|
||||||
|
const messageReceiverOptions = {
|
||||||
|
serverTrustRoot: window.getServerTrustRoot(),
|
||||||
|
};
|
||||||
messageReceiver = new window.textsecure.MessageReceiver(
|
messageReceiver = new window.textsecure.MessageReceiver(
|
||||||
OLD_USERNAME,
|
OLD_USERNAME,
|
||||||
USERNAME,
|
USERNAME,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
mySignalingKey,
|
mySignalingKey,
|
||||||
options as WhatIsThis
|
messageReceiverOptions as WhatIsThis
|
||||||
);
|
);
|
||||||
window.textsecure.messageReceiver = messageReceiver;
|
window.textsecure.messageReceiver = messageReceiver;
|
||||||
|
|
||||||
|
@ -2151,6 +2150,12 @@ type WhatIsThis = typeof window.WhatIsThis;
|
||||||
|
|
||||||
window.Whisper.events.on('manualConnect', manualConnect);
|
window.Whisper.events.on('manualConnect', manualConnect);
|
||||||
function manualConnect() {
|
function manualConnect() {
|
||||||
|
if (isSocketOnline()) {
|
||||||
|
window.log.info('manualConnect: already online; not connecting again');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.log.info('manualConnect: calling connect()');
|
||||||
connect();
|
connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,6 @@ class MessageReceiverInner extends EventTarget {
|
||||||
signalingKey: ArrayBuffer,
|
signalingKey: ArrayBuffer,
|
||||||
options: {
|
options: {
|
||||||
serverTrustRoot: string;
|
serverTrustRoot: string;
|
||||||
retryCached?: string;
|
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
@ -196,9 +195,8 @@ class MessageReceiverInner extends EventTarget {
|
||||||
processBatch: this.cacheRemoveBatch.bind(this),
|
processBatch: this.cacheRemoveBatch.bind(this),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (options.retryCached) {
|
// We always process our cache before any websocket message
|
||||||
this.pendingQueue.add(async () => this.queueAllCached());
|
this.pendingQueue.add(async () => this.queueAllCached());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static stringToArrayBuffer = (string: string): ArrayBuffer =>
|
static stringToArrayBuffer = (string: string): ArrayBuffer =>
|
||||||
|
|
Loading…
Reference in a new issue