Add server fallback port 8443
// FREEBIE
This commit is contained in:
parent
4be86a28ef
commit
0487fa3cd1
7 changed files with 121 additions and 66 deletions
|
@ -124,8 +124,8 @@ module.exports = function(grunt) {
|
||||||
process: function(content, srcpath) {
|
process: function(content, srcpath) {
|
||||||
if (srcpath.match('background.js')) {
|
if (srcpath.match('background.js')) {
|
||||||
return content.replace(
|
return content.replace(
|
||||||
/textsecure-service-staging.whispersystems.org:4433/g,
|
/textsecure-service-staging.whispersystems.org/g,
|
||||||
'textsecure-service-ca.whispersystems.org:4433').replace(
|
'textsecure-service-ca.whispersystems.org').replace(
|
||||||
/whispersystems-textsecure-attachments-staging.s3.amazonaws.com/g,
|
/whispersystems-textsecure-attachments-staging.s3.amazonaws.com/g,
|
||||||
'whispersystems-textsecure-attachments.s3.amazonaws.com');
|
'whispersystems-textsecure-attachments.s3.amazonaws.com');
|
||||||
} else if (srcpath.match('expire.js')) {
|
} else if (srcpath.match('expire.js')) {
|
||||||
|
|
|
@ -51,7 +51,8 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var SERVER_URL = 'https://textsecure-service-staging.whispersystems.org:4433';
|
var SERVER_URL = 'https://textsecure-service-staging.whispersystems.org';
|
||||||
|
var SERVER_PORTS = [4433, 8443];
|
||||||
var ATTACHMENT_SERVER_URL = 'https://whispersystems-textsecure-attachments-staging.s3.amazonaws.com';
|
var ATTACHMENT_SERVER_URL = 'https://whispersystems-textsecure-attachments-staging.s3.amazonaws.com';
|
||||||
var messageReceiver;
|
var messageReceiver;
|
||||||
window.getSocketStatus = function() {
|
window.getSocketStatus = function() {
|
||||||
|
@ -64,7 +65,7 @@
|
||||||
window.getAccountManager = function() {
|
window.getAccountManager = function() {
|
||||||
var USERNAME = storage.get('number_id');
|
var USERNAME = storage.get('number_id');
|
||||||
var PASSWORD = storage.get('password');
|
var PASSWORD = storage.get('password');
|
||||||
return new textsecure.AccountManager(SERVER_URL, USERNAME, PASSWORD);
|
return new textsecure.AccountManager(SERVER_URL, SERVER_PORTS, USERNAME, PASSWORD);
|
||||||
};
|
};
|
||||||
|
|
||||||
storage.fetch();
|
storage.fetch();
|
||||||
|
@ -103,7 +104,7 @@
|
||||||
|
|
||||||
// initialize the socket and start listening for messages
|
// initialize the socket and start listening for messages
|
||||||
messageReceiver = new textsecure.MessageReceiver(
|
messageReceiver = new textsecure.MessageReceiver(
|
||||||
SERVER_URL, USERNAME, PASSWORD, mySignalingKey, ATTACHMENT_SERVER_URL
|
SERVER_URL, SERVER_PORTS, USERNAME, PASSWORD, mySignalingKey, ATTACHMENT_SERVER_URL
|
||||||
);
|
);
|
||||||
messageReceiver.addEventListener('message', onMessageReceived);
|
messageReceiver.addEventListener('message', onMessageReceived);
|
||||||
messageReceiver.addEventListener('receipt', onDeliveryReceipt);
|
messageReceiver.addEventListener('receipt', onDeliveryReceipt);
|
||||||
|
@ -114,7 +115,7 @@
|
||||||
messageReceiver.addEventListener('error', onError);
|
messageReceiver.addEventListener('error', onError);
|
||||||
|
|
||||||
window.textsecure.messaging = new textsecure.MessageSender(
|
window.textsecure.messaging = new textsecure.MessageSender(
|
||||||
SERVER_URL, USERNAME, PASSWORD, ATTACHMENT_SERVER_URL
|
SERVER_URL, SERVER_PORTS, USERNAME, PASSWORD, ATTACHMENT_SERVER_URL
|
||||||
);
|
);
|
||||||
if (firstRun === true && textsecure.storage.user.getDeviceId() != '1') {
|
if (firstRun === true && textsecure.storage.user.getDeviceId() != '1') {
|
||||||
var syncRequest = new textsecure.SyncRequest(textsecure.messaging, messageReceiver);
|
var syncRequest = new textsecure.SyncRequest(textsecure.messaging, messageReceiver);
|
||||||
|
|
|
@ -37474,6 +37474,18 @@ window.textsecure.utils = function() {
|
||||||
* vim: ts=4:sw=4:expandtab
|
* vim: ts=4:sw=4:expandtab
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function PortManager(ports) {
|
||||||
|
this.ports = ports;
|
||||||
|
this.idx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortManager.prototype = {
|
||||||
|
constructor: PortManager,
|
||||||
|
getPort: function() {
|
||||||
|
return this.ports[this.idx++];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var TextSecureServer = (function() {
|
var TextSecureServer = (function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -37499,6 +37511,9 @@ var TextSecureServer = (function() {
|
||||||
// Promise-based async xhr routine
|
// Promise-based async xhr routine
|
||||||
function promise_ajax(url, options) {
|
function promise_ajax(url, options) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
if (!url) {
|
||||||
|
url = options.host + ':' + options.port + '/' + options.path;
|
||||||
|
}
|
||||||
console.log(options.type, url);
|
console.log(options.type, url);
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open(options.type, url, true /*async*/);
|
xhr.open(options.type, url, true /*async*/);
|
||||||
|
@ -37546,24 +37561,29 @@ var TextSecureServer = (function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax(url, options) {
|
function retry_ajax(url, options, limit, count) {
|
||||||
options.stack = new Error().stack; // just in case, save stack here.
|
count = count || 0;
|
||||||
var count = 3;
|
limit = limit || 3;
|
||||||
|
if (options.ports) {
|
||||||
function retry(e) {
|
options.port = options.ports[count % options.ports.length];
|
||||||
if (e.name === 'HTTPError' && e.code === -1 && count > 0) {
|
}
|
||||||
count = count - 1;
|
count++;
|
||||||
|
return promise_ajax(url, options).catch(function(e) {
|
||||||
|
if (e.name === 'HTTPError' && e.code === -1 && count < limit) {
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
resolve(promise_ajax(url, options).catch(retry));
|
resolve(retry_ajax(url, options, limit, count));
|
||||||
}, 1000 );
|
}, 1000);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return promise_ajax(url, options).catch(retry);
|
function ajax(url, options) {
|
||||||
|
options.stack = new Error().stack; // just in case, save stack here.
|
||||||
|
return retry_ajax(url, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
function HTTPError(code, response, stack) {
|
function HTTPError(code, response, stack) {
|
||||||
|
@ -37581,17 +37601,18 @@ var TextSecureServer = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var URL_CALLS = {
|
var URL_CALLS = {
|
||||||
accounts : "/v1/accounts",
|
accounts : "v1/accounts",
|
||||||
devices : "/v1/devices",
|
devices : "v1/devices",
|
||||||
keys : "/v2/keys",
|
keys : "v2/keys",
|
||||||
messages : "/v1/messages",
|
messages : "v1/messages",
|
||||||
attachment : "/v1/attachments"
|
attachment : "v1/attachments"
|
||||||
};
|
};
|
||||||
|
|
||||||
function TextSecureServer(url, username, password, attachment_server_url) {
|
function TextSecureServer(url, ports, username, password, attachment_server_url) {
|
||||||
if (typeof url !== 'string') {
|
if (typeof url !== 'string') {
|
||||||
throw new Error('Invalid server url');
|
throw new Error('Invalid server url');
|
||||||
}
|
}
|
||||||
|
this.portManager = new PortManager(ports);
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
|
@ -37610,11 +37631,17 @@ var TextSecureServer = (function() {
|
||||||
|
|
||||||
TextSecureServer.prototype = {
|
TextSecureServer.prototype = {
|
||||||
constructor: TextSecureServer,
|
constructor: TextSecureServer,
|
||||||
|
getUrl: function() {
|
||||||
|
return this.url + ':' + this.portManager.getPort();
|
||||||
|
},
|
||||||
ajax: function(param) {
|
ajax: function(param) {
|
||||||
if (!param.urlParameters) {
|
if (!param.urlParameters) {
|
||||||
param.urlParameters = '';
|
param.urlParameters = '';
|
||||||
}
|
}
|
||||||
return ajax(this.url + URL_CALLS[param.call] + param.urlParameters, {
|
return ajax(null, {
|
||||||
|
host : this.url,
|
||||||
|
ports : this.portManager.ports,
|
||||||
|
path : URL_CALLS[param.call] + param.urlParameters,
|
||||||
type : param.httpType,
|
type : param.httpType,
|
||||||
data : param.jsonData && textsecure.utils.jsonThing(param.jsonData),
|
data : param.jsonData && textsecure.utils.jsonThing(param.jsonData),
|
||||||
contentType : 'application/json; charset=utf-8',
|
contentType : 'application/json; charset=utf-8',
|
||||||
|
@ -37823,7 +37850,7 @@ var TextSecureServer = (function() {
|
||||||
},
|
},
|
||||||
getMessageSocket: function() {
|
getMessageSocket: function() {
|
||||||
return new WebSocket(
|
return new WebSocket(
|
||||||
this.url.replace('https://', 'wss://')
|
this.getUrl().replace('https://', 'wss://')
|
||||||
.replace('http://', 'ws://')
|
.replace('http://', 'ws://')
|
||||||
+ '/v1/websocket/?login=' + encodeURIComponent(this.username)
|
+ '/v1/websocket/?login=' + encodeURIComponent(this.username)
|
||||||
+ '&password=' + encodeURIComponent(this.password)
|
+ '&password=' + encodeURIComponent(this.password)
|
||||||
|
@ -37833,7 +37860,7 @@ var TextSecureServer = (function() {
|
||||||
getProvisioningSocket: function () {
|
getProvisioningSocket: function () {
|
||||||
console.log('opening provisioning socket', this.url);
|
console.log('opening provisioning socket', this.url);
|
||||||
return new WebSocket(
|
return new WebSocket(
|
||||||
this.url.replace('https://', 'wss://')
|
this.getUrl().replace('https://', 'wss://')
|
||||||
.replace('http://', 'ws://')
|
.replace('http://', 'ws://')
|
||||||
+ '/v1/websocket/provisioning/?agent=OWD'
|
+ '/v1/websocket/provisioning/?agent=OWD'
|
||||||
);
|
);
|
||||||
|
@ -37852,8 +37879,8 @@ var TextSecureServer = (function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
window.textsecure = window.textsecure || {};
|
window.textsecure = window.textsecure || {};
|
||||||
|
|
||||||
function AccountManager(url, username, password) {
|
function AccountManager(url, ports, username, password) {
|
||||||
this.server = new TextSecureServer(url, username, password);
|
this.server = new TextSecureServer(url, ports, username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountManager.prototype = {
|
AccountManager.prototype = {
|
||||||
|
@ -38032,12 +38059,12 @@ var TextSecureServer = (function() {
|
||||||
* vim: ts=4:sw=4:expandtab
|
* vim: ts=4:sw=4:expandtab
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function MessageReceiver(url, username, password, signalingKey, attachment_server_url) {
|
function MessageReceiver(url, ports, username, password, signalingKey, attachment_server_url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.signalingKey = signalingKey;
|
this.signalingKey = signalingKey;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.server = new TextSecureServer(url, username, password, attachment_server_url);
|
this.server = new TextSecureServer(url, ports, username, password, attachment_server_url);
|
||||||
|
|
||||||
var address = libsignal.SignalProtocolAddress.fromString(username);
|
var address = libsignal.SignalProtocolAddress.fromString(username);
|
||||||
this.number = address.getName();
|
this.number = address.getName();
|
||||||
|
@ -38502,8 +38529,8 @@ MessageReceiver.prototype.extend({
|
||||||
|
|
||||||
window.textsecure = window.textsecure || {};
|
window.textsecure = window.textsecure || {};
|
||||||
|
|
||||||
textsecure.MessageReceiver = function(url, username, password, signalingKey, attachment_server_url) {
|
textsecure.MessageReceiver = function(url, ports, username, password, signalingKey, attachment_server_url) {
|
||||||
var messageReceiver = new MessageReceiver(url, username, password, signalingKey, attachment_server_url);
|
var messageReceiver = new MessageReceiver(url, ports, username, password, signalingKey, attachment_server_url);
|
||||||
this.addEventListener = messageReceiver.addEventListener.bind(messageReceiver);
|
this.addEventListener = messageReceiver.addEventListener.bind(messageReceiver);
|
||||||
this.removeEventListener = messageReceiver.removeEventListener.bind(messageReceiver);
|
this.removeEventListener = messageReceiver.removeEventListener.bind(messageReceiver);
|
||||||
this.getStatus = messageReceiver.getStatus.bind(messageReceiver);
|
this.getStatus = messageReceiver.getStatus.bind(messageReceiver);
|
||||||
|
@ -38835,8 +38862,8 @@ Message.prototype = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function MessageSender(url, username, password, attachment_server_url) {
|
function MessageSender(url, ports, username, password, attachment_server_url) {
|
||||||
this.server = new TextSecureServer(url, username, password, attachment_server_url);
|
this.server = new TextSecureServer(url, ports, username, password, attachment_server_url);
|
||||||
this.pendingMessages = {};
|
this.pendingMessages = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39187,8 +39214,8 @@ MessageSender.prototype = {
|
||||||
|
|
||||||
window.textsecure = window.textsecure || {};
|
window.textsecure = window.textsecure || {};
|
||||||
|
|
||||||
textsecure.MessageSender = function(url, username, password, attachment_server_url) {
|
textsecure.MessageSender = function(url, ports, username, password, attachment_server_url) {
|
||||||
var sender = new MessageSender(url, username, password, attachment_server_url);
|
var sender = new MessageSender(url, ports, username, password, attachment_server_url);
|
||||||
textsecure.replay.registerFunction(sender.tryMessageAgain.bind(sender), textsecure.replay.Type.ENCRYPT_MESSAGE);
|
textsecure.replay.registerFunction(sender.tryMessageAgain.bind(sender), textsecure.replay.Type.ENCRYPT_MESSAGE);
|
||||||
textsecure.replay.registerFunction(sender.retransmitMessage.bind(sender), textsecure.replay.Type.TRANSMIT_MESSAGE);
|
textsecure.replay.registerFunction(sender.retransmitMessage.bind(sender), textsecure.replay.Type.TRANSMIT_MESSAGE);
|
||||||
textsecure.replay.registerFunction(sender.sendMessage.bind(sender), textsecure.replay.Type.REBUILD_MESSAGE);
|
textsecure.replay.registerFunction(sender.sendMessage.bind(sender), textsecure.replay.Type.REBUILD_MESSAGE);
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
window.textsecure = window.textsecure || {};
|
window.textsecure = window.textsecure || {};
|
||||||
|
|
||||||
function AccountManager(url, username, password) {
|
function AccountManager(url, ports, username, password) {
|
||||||
this.server = new TextSecureServer(url, username, password);
|
this.server = new TextSecureServer(url, ports, username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountManager.prototype = {
|
AccountManager.prototype = {
|
||||||
|
|
|
@ -2,6 +2,18 @@
|
||||||
* vim: ts=4:sw=4:expandtab
|
* vim: ts=4:sw=4:expandtab
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function PortManager(ports) {
|
||||||
|
this.ports = ports;
|
||||||
|
this.idx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortManager.prototype = {
|
||||||
|
constructor: PortManager,
|
||||||
|
getPort: function() {
|
||||||
|
return this.ports[this.idx++];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var TextSecureServer = (function() {
|
var TextSecureServer = (function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -27,6 +39,9 @@ var TextSecureServer = (function() {
|
||||||
// Promise-based async xhr routine
|
// Promise-based async xhr routine
|
||||||
function promise_ajax(url, options) {
|
function promise_ajax(url, options) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
if (!url) {
|
||||||
|
url = options.host + ':' + options.port + '/' + options.path;
|
||||||
|
}
|
||||||
console.log(options.type, url);
|
console.log(options.type, url);
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open(options.type, url, true /*async*/);
|
xhr.open(options.type, url, true /*async*/);
|
||||||
|
@ -74,24 +89,29 @@ var TextSecureServer = (function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax(url, options) {
|
function retry_ajax(url, options, limit, count) {
|
||||||
options.stack = new Error().stack; // just in case, save stack here.
|
count = count || 0;
|
||||||
var count = 3;
|
limit = limit || 3;
|
||||||
|
if (options.ports) {
|
||||||
function retry(e) {
|
options.port = options.ports[count % options.ports.length];
|
||||||
if (e.name === 'HTTPError' && e.code === -1 && count > 0) {
|
}
|
||||||
count = count - 1;
|
count++;
|
||||||
|
return promise_ajax(url, options).catch(function(e) {
|
||||||
|
if (e.name === 'HTTPError' && e.code === -1 && count < limit) {
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
resolve(promise_ajax(url, options).catch(retry));
|
resolve(retry_ajax(url, options, limit, count));
|
||||||
}, 1000 );
|
}, 1000);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return promise_ajax(url, options).catch(retry);
|
function ajax(url, options) {
|
||||||
|
options.stack = new Error().stack; // just in case, save stack here.
|
||||||
|
return retry_ajax(url, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
function HTTPError(code, response, stack) {
|
function HTTPError(code, response, stack) {
|
||||||
|
@ -109,17 +129,18 @@ var TextSecureServer = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var URL_CALLS = {
|
var URL_CALLS = {
|
||||||
accounts : "/v1/accounts",
|
accounts : "v1/accounts",
|
||||||
devices : "/v1/devices",
|
devices : "v1/devices",
|
||||||
keys : "/v2/keys",
|
keys : "v2/keys",
|
||||||
messages : "/v1/messages",
|
messages : "v1/messages",
|
||||||
attachment : "/v1/attachments"
|
attachment : "v1/attachments"
|
||||||
};
|
};
|
||||||
|
|
||||||
function TextSecureServer(url, username, password, attachment_server_url) {
|
function TextSecureServer(url, ports, username, password, attachment_server_url) {
|
||||||
if (typeof url !== 'string') {
|
if (typeof url !== 'string') {
|
||||||
throw new Error('Invalid server url');
|
throw new Error('Invalid server url');
|
||||||
}
|
}
|
||||||
|
this.portManager = new PortManager(ports);
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
|
@ -138,11 +159,17 @@ var TextSecureServer = (function() {
|
||||||
|
|
||||||
TextSecureServer.prototype = {
|
TextSecureServer.prototype = {
|
||||||
constructor: TextSecureServer,
|
constructor: TextSecureServer,
|
||||||
|
getUrl: function() {
|
||||||
|
return this.url + ':' + this.portManager.getPort();
|
||||||
|
},
|
||||||
ajax: function(param) {
|
ajax: function(param) {
|
||||||
if (!param.urlParameters) {
|
if (!param.urlParameters) {
|
||||||
param.urlParameters = '';
|
param.urlParameters = '';
|
||||||
}
|
}
|
||||||
return ajax(this.url + URL_CALLS[param.call] + param.urlParameters, {
|
return ajax(null, {
|
||||||
|
host : this.url,
|
||||||
|
ports : this.portManager.ports,
|
||||||
|
path : URL_CALLS[param.call] + param.urlParameters,
|
||||||
type : param.httpType,
|
type : param.httpType,
|
||||||
data : param.jsonData && textsecure.utils.jsonThing(param.jsonData),
|
data : param.jsonData && textsecure.utils.jsonThing(param.jsonData),
|
||||||
contentType : 'application/json; charset=utf-8',
|
contentType : 'application/json; charset=utf-8',
|
||||||
|
@ -351,7 +378,7 @@ var TextSecureServer = (function() {
|
||||||
},
|
},
|
||||||
getMessageSocket: function() {
|
getMessageSocket: function() {
|
||||||
return new WebSocket(
|
return new WebSocket(
|
||||||
this.url.replace('https://', 'wss://')
|
this.getUrl().replace('https://', 'wss://')
|
||||||
.replace('http://', 'ws://')
|
.replace('http://', 'ws://')
|
||||||
+ '/v1/websocket/?login=' + encodeURIComponent(this.username)
|
+ '/v1/websocket/?login=' + encodeURIComponent(this.username)
|
||||||
+ '&password=' + encodeURIComponent(this.password)
|
+ '&password=' + encodeURIComponent(this.password)
|
||||||
|
@ -361,7 +388,7 @@ var TextSecureServer = (function() {
|
||||||
getProvisioningSocket: function () {
|
getProvisioningSocket: function () {
|
||||||
console.log('opening provisioning socket', this.url);
|
console.log('opening provisioning socket', this.url);
|
||||||
return new WebSocket(
|
return new WebSocket(
|
||||||
this.url.replace('https://', 'wss://')
|
this.getUrl().replace('https://', 'wss://')
|
||||||
.replace('http://', 'ws://')
|
.replace('http://', 'ws://')
|
||||||
+ '/v1/websocket/provisioning/?agent=OWD'
|
+ '/v1/websocket/provisioning/?agent=OWD'
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
* vim: ts=4:sw=4:expandtab
|
* vim: ts=4:sw=4:expandtab
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function MessageReceiver(url, username, password, signalingKey, attachment_server_url) {
|
function MessageReceiver(url, ports, username, password, signalingKey, attachment_server_url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.signalingKey = signalingKey;
|
this.signalingKey = signalingKey;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.server = new TextSecureServer(url, username, password, attachment_server_url);
|
this.server = new TextSecureServer(url, ports, username, password, attachment_server_url);
|
||||||
|
|
||||||
var address = libsignal.SignalProtocolAddress.fromString(username);
|
var address = libsignal.SignalProtocolAddress.fromString(username);
|
||||||
this.number = address.getName();
|
this.number = address.getName();
|
||||||
|
@ -472,8 +472,8 @@ MessageReceiver.prototype.extend({
|
||||||
|
|
||||||
window.textsecure = window.textsecure || {};
|
window.textsecure = window.textsecure || {};
|
||||||
|
|
||||||
textsecure.MessageReceiver = function(url, username, password, signalingKey, attachment_server_url) {
|
textsecure.MessageReceiver = function(url, ports, username, password, signalingKey, attachment_server_url) {
|
||||||
var messageReceiver = new MessageReceiver(url, username, password, signalingKey, attachment_server_url);
|
var messageReceiver = new MessageReceiver(url, ports, username, password, signalingKey, attachment_server_url);
|
||||||
this.addEventListener = messageReceiver.addEventListener.bind(messageReceiver);
|
this.addEventListener = messageReceiver.addEventListener.bind(messageReceiver);
|
||||||
this.removeEventListener = messageReceiver.removeEventListener.bind(messageReceiver);
|
this.removeEventListener = messageReceiver.removeEventListener.bind(messageReceiver);
|
||||||
this.getStatus = messageReceiver.getStatus.bind(messageReceiver);
|
this.getStatus = messageReceiver.getStatus.bind(messageReceiver);
|
||||||
|
|
|
@ -92,8 +92,8 @@ Message.prototype = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function MessageSender(url, username, password, attachment_server_url) {
|
function MessageSender(url, ports, username, password, attachment_server_url) {
|
||||||
this.server = new TextSecureServer(url, username, password, attachment_server_url);
|
this.server = new TextSecureServer(url, ports, username, password, attachment_server_url);
|
||||||
this.pendingMessages = {};
|
this.pendingMessages = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,8 +444,8 @@ MessageSender.prototype = {
|
||||||
|
|
||||||
window.textsecure = window.textsecure || {};
|
window.textsecure = window.textsecure || {};
|
||||||
|
|
||||||
textsecure.MessageSender = function(url, username, password, attachment_server_url) {
|
textsecure.MessageSender = function(url, ports, username, password, attachment_server_url) {
|
||||||
var sender = new MessageSender(url, username, password, attachment_server_url);
|
var sender = new MessageSender(url, ports, username, password, attachment_server_url);
|
||||||
textsecure.replay.registerFunction(sender.tryMessageAgain.bind(sender), textsecure.replay.Type.ENCRYPT_MESSAGE);
|
textsecure.replay.registerFunction(sender.tryMessageAgain.bind(sender), textsecure.replay.Type.ENCRYPT_MESSAGE);
|
||||||
textsecure.replay.registerFunction(sender.retransmitMessage.bind(sender), textsecure.replay.Type.TRANSMIT_MESSAGE);
|
textsecure.replay.registerFunction(sender.retransmitMessage.bind(sender), textsecure.replay.Type.TRANSMIT_MESSAGE);
|
||||||
textsecure.replay.registerFunction(sender.sendMessage.bind(sender), textsecure.replay.Type.REBUILD_MESSAGE);
|
textsecure.replay.registerFunction(sender.sendMessage.bind(sender), textsecure.replay.Type.REBUILD_MESSAGE);
|
||||||
|
|
Loading…
Reference in a new issue