Accept close code/message via websocket/resources
This commit is contained in:
parent
8170a7baae
commit
d9fe783488
5 changed files with 26 additions and 14 deletions
|
@ -38401,8 +38401,8 @@ axolotlInternal.RecipientRecord = function() {
|
||||||
/*
|
/*
|
||||||
* var socket = TextSecureWebSocket(url);
|
* var socket = TextSecureWebSocket(url);
|
||||||
*
|
*
|
||||||
* Returns an adamantium-reinforced super socket, capable of sending
|
* Returns an adamantium-reinforced super socket, capable of
|
||||||
* app-level keep alives and automatically reconnecting.
|
* automatically reconnecting.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -38421,7 +38421,10 @@ TextSecureWebSocket = function (url, opts) {
|
||||||
onclose : function() {},
|
onclose : function() {},
|
||||||
onerror : function() {},
|
onerror : function() {},
|
||||||
getStatus : function() { return socket.readyState; },
|
getStatus : function() { return socket.readyState; },
|
||||||
close : function() { calledClose = true; socket.close(); }
|
close : function(code, reason) {
|
||||||
|
calledClose = true;
|
||||||
|
socket.close(code, reason);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
var error;
|
var error;
|
||||||
|
|
||||||
|
@ -38565,8 +38568,9 @@ TextSecureWebSocket = function (url, opts) {
|
||||||
return new OutgoingWebSocketRequest(options, socket);
|
return new OutgoingWebSocketRequest(options, socket);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.close = function() {
|
this.close = function(code, reason) {
|
||||||
socket.close(3000);
|
if (!code) { code = 3000; }
|
||||||
|
socket.close(code, reason);
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onmessage = function(socketMessage) {
|
socket.onmessage = function(socketMessage) {
|
||||||
|
@ -38640,7 +38644,9 @@ KeepAlive.prototype = {
|
||||||
clearTimeout(this.keepAliveTimer);
|
clearTimeout(this.keepAliveTimer);
|
||||||
clearTimeout(this.disconnectTimer);
|
clearTimeout(this.disconnectTimer);
|
||||||
this.keepAliveTimer = setTimeout(function() {
|
this.keepAliveTimer = setTimeout(function() {
|
||||||
this.disconnectTimer = setTimeout(this.wsr.close, 5000);
|
this.disconnectTimer = setTimeout(function() {
|
||||||
|
this.wsr.close(3001, 'No response to keepalive request');
|
||||||
|
}.bind(this), 5000);
|
||||||
this.wsr.sendRequest({
|
this.wsr.sendRequest({
|
||||||
verb: 'GET',
|
verb: 'GET',
|
||||||
path: '/v1/keepalive',
|
path: '/v1/keepalive',
|
||||||
|
@ -39378,7 +39384,7 @@ TextSecureServer = function () {
|
||||||
} else if (request.path == "/v1/message" && request.verb == "PUT") {
|
} else if (request.path == "/v1/message" && request.verb == "PUT") {
|
||||||
var envelope = textsecure.protobuf.ProvisionEnvelope.decode(request.body, 'binary');
|
var envelope = textsecure.protobuf.ProvisionEnvelope.decode(request.body, 'binary');
|
||||||
request.respond(200, 'OK');
|
request.respond(200, 'OK');
|
||||||
socket.close();
|
wsr.close();
|
||||||
resolve(cryptoInfo.decryptAndHandleDeviceInit(envelope).then(function(provisionMessage) {
|
resolve(cryptoInfo.decryptAndHandleDeviceInit(envelope).then(function(provisionMessage) {
|
||||||
return confirmNumber(provisionMessage.number).then(function(deviceName) {
|
return confirmNumber(provisionMessage.number).then(function(deviceName) {
|
||||||
if (typeof deviceName !== 'string' || deviceName.length == 0) {
|
if (typeof deviceName !== 'string' || deviceName.length == 0) {
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
} else if (request.path == "/v1/message" && request.verb == "PUT") {
|
} else if (request.path == "/v1/message" && request.verb == "PUT") {
|
||||||
var envelope = textsecure.protobuf.ProvisionEnvelope.decode(request.body, 'binary');
|
var envelope = textsecure.protobuf.ProvisionEnvelope.decode(request.body, 'binary');
|
||||||
request.respond(200, 'OK');
|
request.respond(200, 'OK');
|
||||||
socket.close();
|
wsr.close();
|
||||||
resolve(cryptoInfo.decryptAndHandleDeviceInit(envelope).then(function(provisionMessage) {
|
resolve(cryptoInfo.decryptAndHandleDeviceInit(envelope).then(function(provisionMessage) {
|
||||||
return confirmNumber(provisionMessage.number).then(function(deviceName) {
|
return confirmNumber(provisionMessage.number).then(function(deviceName) {
|
||||||
if (typeof deviceName !== 'string' || deviceName.length == 0) {
|
if (typeof deviceName !== 'string' || deviceName.length == 0) {
|
||||||
|
|
|
@ -29,7 +29,9 @@ KeepAlive.prototype = {
|
||||||
clearTimeout(this.keepAliveTimer);
|
clearTimeout(this.keepAliveTimer);
|
||||||
clearTimeout(this.disconnectTimer);
|
clearTimeout(this.disconnectTimer);
|
||||||
this.keepAliveTimer = setTimeout(function() {
|
this.keepAliveTimer = setTimeout(function() {
|
||||||
this.disconnectTimer = setTimeout(this.wsr.close, 5000);
|
this.disconnectTimer = setTimeout(function() {
|
||||||
|
this.wsr.close(3001, 'No response to keepalive request');
|
||||||
|
}.bind(this), 5000);
|
||||||
this.wsr.sendRequest({
|
this.wsr.sendRequest({
|
||||||
verb: 'GET',
|
verb: 'GET',
|
||||||
path: '/v1/keepalive',
|
path: '/v1/keepalive',
|
||||||
|
|
|
@ -97,8 +97,9 @@
|
||||||
return new OutgoingWebSocketRequest(options, socket);
|
return new OutgoingWebSocketRequest(options, socket);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.close = function() {
|
this.close = function(code, reason) {
|
||||||
socket.close(3000);
|
if (!code) { code = 3000; }
|
||||||
|
socket.close(code, reason);
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onmessage = function(socketMessage) {
|
socket.onmessage = function(socketMessage) {
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
/*
|
/*
|
||||||
* var socket = TextSecureWebSocket(url);
|
* var socket = TextSecureWebSocket(url);
|
||||||
*
|
*
|
||||||
* Returns an adamantium-reinforced super socket, capable of sending
|
* Returns an adamantium-reinforced super socket, capable of
|
||||||
* app-level keep alives and automatically reconnecting.
|
* automatically reconnecting.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -37,7 +37,10 @@ TextSecureWebSocket = function (url, opts) {
|
||||||
onclose : function() {},
|
onclose : function() {},
|
||||||
onerror : function() {},
|
onerror : function() {},
|
||||||
getStatus : function() { return socket.readyState; },
|
getStatus : function() { return socket.readyState; },
|
||||||
close : function() { calledClose = true; socket.close(); }
|
close : function(code, reason) {
|
||||||
|
calledClose = true;
|
||||||
|
socket.close(code, reason);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
var error;
|
var error;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue