Reconnect once a minute if internet is down
This commit is contained in:
parent
f6b5eec84e
commit
8a10c96ab4
1 changed files with 16 additions and 11 deletions
|
@ -45,22 +45,22 @@
|
|||
}
|
||||
};
|
||||
|
||||
window.addEventListener('textsecure:message', onMessageReceived);
|
||||
window.addEventListener('textsecure:receipt', onDeliveryReceipt);
|
||||
window.addEventListener('textsecure:contact', onContactReceived);
|
||||
window.addEventListener('textsecure:group', onGroupReceived);
|
||||
window.addEventListener('textsecure:sent', onSentMessage);
|
||||
window.addEventListener('textsecure:error', onError);
|
||||
|
||||
if (open) {
|
||||
openInbox();
|
||||
}
|
||||
|
||||
function init() {
|
||||
if (!textsecure.registration.isDone()) { return; }
|
||||
|
||||
window.addEventListener('textsecure:message', onMessageReceived);
|
||||
window.addEventListener('textsecure:receipt', onDeliveryReceipt);
|
||||
window.addEventListener('textsecure:contact', onContactReceived);
|
||||
window.addEventListener('textsecure:group', onGroupReceived);
|
||||
window.addEventListener('textsecure:sent', onSentMessage);
|
||||
window.addEventListener('textsecure:error', onError);
|
||||
|
||||
// initialize the socket and start listening for messages
|
||||
messageReceiver = new textsecure.MessageReceiver(window);
|
||||
|
||||
if (open) {
|
||||
openInbox();
|
||||
}
|
||||
}
|
||||
|
||||
function onContactReceived(ev) {
|
||||
|
@ -132,6 +132,11 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (e.name === 'HTTPError' && e.code == -1) {
|
||||
setTimeout(init, 60000);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev.proto) {
|
||||
var envelope = ev.proto;
|
||||
var message = initIncomingMessage(envelope.source, envelope.timestamp.toNumber());
|
||||
|
|
Loading…
Reference in a new issue