Reconnect provisioning socket
If the provisioning socket closes, reconnect and generate a new qr code. Fixes #371 // FREEBIE
This commit is contained in:
parent
47befdbf61
commit
9b12d8a978
3 changed files with 36 additions and 28 deletions
|
@ -39073,10 +39073,11 @@ var TextSecureServer = (function() {
|
|||
var registerKeys = this.server.registerKeys.bind(this.server);
|
||||
var getSocket = this.server.getProvisioningSocket.bind(this.server);
|
||||
return textsecure.protocol_wrapper.createIdentityKeyRecvSocket().then(function(cryptoInfo) {
|
||||
return new Promise(function(resolve) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var socket = getSocket();
|
||||
socket.onclose = function(e) {
|
||||
console.log('websocket closed', e.code);
|
||||
reject(new Error('websocket closed'));
|
||||
};
|
||||
var wsr = new WebSocketResource(socket, {
|
||||
keepalive: { path: '/v1/keepalive/provisioning' },
|
||||
|
|
|
@ -61,34 +61,40 @@
|
|||
});
|
||||
|
||||
$(function() {
|
||||
$('#init-setup').show().addClass('in');
|
||||
$('#status').text("Connecting...");
|
||||
|
||||
var accountManager = new bg.getAccountManager();
|
||||
accountManager.registerSecondDevice(setProvisioningUrl, confirmNumber, incrementCounter).then(function() {
|
||||
var launch = function() {
|
||||
bg.openInbox();
|
||||
bg.removeEventListener('textsecure:contactsync', launch);
|
||||
clearTimeout(timeout);
|
||||
window.close();
|
||||
};
|
||||
var timeout = setTimeout(launch, 60000);
|
||||
bg.addEventListener('textsecure:contactsync', launch);
|
||||
$('.progress-dialog .status').text('Syncing groups and contacts');
|
||||
$('.progress-dialog .bar').addClass('progress-bar-striped active');
|
||||
|
||||
}).catch(function(e) {
|
||||
if (e.name === 'HTTPError' && e.code == 411) {
|
||||
$('.progress-dialog').hide();
|
||||
$('.error-dialog').show();
|
||||
$('.error-dialog .ok').click(function(e) {
|
||||
chrome.runtime.reload();
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
var init = function() {
|
||||
$('#init-setup').show().addClass('in');
|
||||
$('#qr').html('');
|
||||
$('#status').text("Connecting...");
|
||||
|
||||
accountManager.registerSecondDevice(setProvisioningUrl, confirmNumber, incrementCounter).then(function() {
|
||||
var launch = function() {
|
||||
bg.openInbox();
|
||||
bg.removeEventListener('textsecure:contactsync', launch);
|
||||
clearTimeout(timeout);
|
||||
window.close();
|
||||
};
|
||||
var timeout = setTimeout(launch, 60000);
|
||||
bg.addEventListener('textsecure:contactsync', launch);
|
||||
$('.progress-dialog .status').text('Syncing groups and contacts');
|
||||
$('.progress-dialog .bar').addClass('progress-bar-striped active');
|
||||
}).catch(function(e) {
|
||||
if (e.message === 'websocket closed') {
|
||||
init();
|
||||
} else if (e.name === 'HTTPError' && e.code == 411) {
|
||||
$('.progress-dialog').hide();
|
||||
$('.error-dialog').show();
|
||||
$('.error-dialog .ok').click(function(e) {
|
||||
chrome.runtime.reload();
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
};
|
||||
init();
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -36,10 +36,11 @@
|
|||
var registerKeys = this.server.registerKeys.bind(this.server);
|
||||
var getSocket = this.server.getProvisioningSocket.bind(this.server);
|
||||
return textsecure.protocol_wrapper.createIdentityKeyRecvSocket().then(function(cryptoInfo) {
|
||||
return new Promise(function(resolve) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var socket = getSocket();
|
||||
socket.onclose = function(e) {
|
||||
console.log('websocket closed', e.code);
|
||||
reject(new Error('websocket closed'));
|
||||
};
|
||||
var wsr = new WebSocketResource(socket, {
|
||||
keepalive: { path: '/v1/keepalive/provisioning' },
|
||||
|
|
Loading…
Reference in a new issue