diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 34a58ca0..e6dd6475 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -38406,10 +38406,11 @@ axolotlInternal.RecipientRecord = function() { * */ -TextSecureWebSocket = function (url) { +TextSecureWebSocket = function (url, opts) { 'use strict'; + opts = opts || {}; + var reconnectTimeout = opts.reconnectTimeout || 1000; var reconnectSemaphore = 0; - var reconnectTimeout = 1000; var socket; var calledClose = false; var socketWrapper = { @@ -38422,7 +38423,7 @@ TextSecureWebSocket = function (url) { var error; function onclose(e) { - if (!error && !calledClose) { + if (!error && !calledClose && reconnectTimeout) { reconnectSemaphore--; setTimeout(connect, reconnectTimeout); } @@ -39266,7 +39267,7 @@ TextSecureServer = function () { self.getTempWebsocket = function() { var url = URL_BASE.replace(/^http/g, 'ws') + URL_CALLS['temp_push'] + '/?'; - return TextSecureWebSocket(url); + return TextSecureWebSocket(url, {reconnectTimeout: false}); } return self; diff --git a/libtextsecure/api.js b/libtextsecure/api.js index f614c6ea..493608b7 100644 --- a/libtextsecure/api.js +++ b/libtextsecure/api.js @@ -329,7 +329,7 @@ TextSecureServer = function () { self.getTempWebsocket = function() { var url = URL_BASE.replace(/^http/g, 'ws') + URL_CALLS['temp_push'] + '/?'; - return TextSecureWebSocket(url); + return TextSecureWebSocket(url, {reconnectTimeout: false}); } return self; diff --git a/libtextsecure/websocket.js b/libtextsecure/websocket.js index 4073f37f..49917c49 100644 --- a/libtextsecure/websocket.js +++ b/libtextsecure/websocket.js @@ -22,10 +22,11 @@ * */ -TextSecureWebSocket = function (url) { +TextSecureWebSocket = function (url, opts) { 'use strict'; + opts = opts || {}; + var reconnectTimeout = opts.reconnectTimeout || 1000; var reconnectSemaphore = 0; - var reconnectTimeout = 1000; var socket; var calledClose = false; var socketWrapper = { @@ -38,7 +39,7 @@ TextSecureWebSocket = function (url) { var error; function onclose(e) { - if (!error && !calledClose) { + if (!error && !calledClose && reconnectTimeout) { reconnectSemaphore--; setTimeout(connect, reconnectTimeout); }