Better handling of online/offline behavior, socket shutdown (#1593)
* Online/offline: Always stop timer, don't connect if closed * Sockets: Send our own close event faster, shutdown only on close Seems that we were too-aggressively disconnecting from all socket events. Also, we should be able to send our own close event a lot faster with no ill effects. * Catch-up libtextsecure changes
This commit is contained in:
parent
3b810d3196
commit
6a895f0e27
4 changed files with 14 additions and 6 deletions
|
@ -185,6 +185,10 @@
|
||||||
disconnectTimer = null;
|
disconnectTimer = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (disconnectTimer) {
|
||||||
|
clearTimeout(disconnectTimer);
|
||||||
|
disconnectTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
connect();
|
connect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38351,7 +38351,7 @@ var TextSecureServer = (function() {
|
||||||
ev.code = code;
|
ev.code = code;
|
||||||
ev.reason = reason;
|
ev.reason = reason;
|
||||||
this.dispatchEvent(ev);
|
this.dispatchEvent(ev);
|
||||||
}.bind(this), 10000);
|
}.bind(this), 1000);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
window.WebSocketResource.prototype = new textsecure.EventTarget();
|
window.WebSocketResource.prototype = new textsecure.EventTarget();
|
||||||
|
@ -38435,6 +38435,10 @@ MessageReceiver.prototype = new textsecure.EventTarget();
|
||||||
MessageReceiver.prototype.extend({
|
MessageReceiver.prototype.extend({
|
||||||
constructor: MessageReceiver,
|
constructor: MessageReceiver,
|
||||||
connect: function() {
|
connect: function() {
|
||||||
|
if (this.calledClose) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.hasConnected = true;
|
this.hasConnected = true;
|
||||||
|
|
||||||
if (this.socket && this.socket.readyState !== WebSocket.CLOSED) {
|
if (this.socket && this.socket.readyState !== WebSocket.CLOSED) {
|
||||||
|
@ -38485,8 +38489,6 @@ MessageReceiver.prototype.extend({
|
||||||
this.wsr.close(3000, 'called close');
|
this.wsr.close(3000, 'called close');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.shutdown();
|
|
||||||
|
|
||||||
return this.drain();
|
return this.drain();
|
||||||
},
|
},
|
||||||
onopen: function() {
|
onopen: function() {
|
||||||
|
|
|
@ -28,6 +28,10 @@ MessageReceiver.prototype = new textsecure.EventTarget();
|
||||||
MessageReceiver.prototype.extend({
|
MessageReceiver.prototype.extend({
|
||||||
constructor: MessageReceiver,
|
constructor: MessageReceiver,
|
||||||
connect: function() {
|
connect: function() {
|
||||||
|
if (this.calledClose) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.hasConnected = true;
|
this.hasConnected = true;
|
||||||
|
|
||||||
if (this.socket && this.socket.readyState !== WebSocket.CLOSED) {
|
if (this.socket && this.socket.readyState !== WebSocket.CLOSED) {
|
||||||
|
@ -78,8 +82,6 @@ MessageReceiver.prototype.extend({
|
||||||
this.wsr.close(3000, 'called close');
|
this.wsr.close(3000, 'called close');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.shutdown();
|
|
||||||
|
|
||||||
return this.drain();
|
return this.drain();
|
||||||
},
|
},
|
||||||
onopen: function() {
|
onopen: function() {
|
||||||
|
|
|
@ -182,7 +182,7 @@
|
||||||
ev.code = code;
|
ev.code = code;
|
||||||
ev.reason = reason;
|
ev.reason = reason;
|
||||||
this.dispatchEvent(ev);
|
this.dispatchEvent(ev);
|
||||||
}.bind(this), 10000);
|
}.bind(this), 1000);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
window.WebSocketResource.prototype = new textsecure.EventTarget();
|
window.WebSocketResource.prototype = new textsecure.EventTarget();
|
||||||
|
|
Loading…
Reference in a new issue