Reconnect once a minute if internet is down

This commit is contained in:
lilia 2015-07-16 13:16:25 -07:00
parent f6b5eec84e
commit 8a10c96ab4

View file

@ -45,9 +45,6 @@
}
};
function init() {
if (!textsecure.registration.isDone()) { return; }
window.addEventListener('textsecure:message', onMessageReceived);
window.addEventListener('textsecure:receipt', onDeliveryReceipt);
window.addEventListener('textsecure:contact', onContactReceived);
@ -55,12 +52,15 @@
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 init() {
if (!textsecure.registration.isDone()) { return; }
// initialize the socket and start listening for messages
messageReceiver = new textsecure.MessageReceiver(window);
}
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());