Simplify keepalive resets
Websocket resources should have their keepalive timers reset whenever a message comes in. This is a nicety that slightly reduces the amount of traffic we send when actively messaging. Previously this was handled by MessageReceiver, but it's a bit cleaner to just have the WebsocketResource add an extra 'message' event handler. // FREEBIE
This commit is contained in:
parent
5a8787f91a
commit
9be5efc571
3 changed files with 6 additions and 6 deletions
|
@ -38461,8 +38461,9 @@ axolotlInternal.RecipientRecord = function() {
|
||||||
path : opts.keepalive.path,
|
path : opts.keepalive.path,
|
||||||
disconnect : opts.keepalive.disconnect
|
disconnect : opts.keepalive.disconnect
|
||||||
});
|
});
|
||||||
this.resetKeepAliveTimer = keepalive.reset.bind(keepalive);
|
var resetKeepAliveTimer = keepalive.reset.bind(keepalive);
|
||||||
socket.addEventListener('connect', this.resetKeepAliveTimer);
|
socket.addEventListener('connect', resetKeepAliveTimer);
|
||||||
|
socket.addEventListener('message', resetKeepAliveTimer);
|
||||||
socket.addEventListener('close', keepalive.stop.bind(keepalive));
|
socket.addEventListener('close', keepalive.stop.bind(keepalive));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39261,7 +39262,6 @@ MessageReceiver.prototype = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleRequest: function(request) {
|
handleRequest: function(request) {
|
||||||
this.wsr.resetKeepAliveTimer();
|
|
||||||
// TODO: handle different types of requests. for now we only expect
|
// TODO: handle different types of requests. for now we only expect
|
||||||
// PUT /messages <encrypted IncomingPushMessageSignal>
|
// PUT /messages <encrypted IncomingPushMessageSignal>
|
||||||
textsecure.crypto.decryptWebsocketMessage(request.body, this.signalingKey).then(function(plaintext) {
|
textsecure.crypto.decryptWebsocketMessage(request.body, this.signalingKey).then(function(plaintext) {
|
||||||
|
|
|
@ -53,7 +53,6 @@ MessageReceiver.prototype = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleRequest: function(request) {
|
handleRequest: function(request) {
|
||||||
this.wsr.resetKeepAliveTimer();
|
|
||||||
// TODO: handle different types of requests. for now we only expect
|
// TODO: handle different types of requests. for now we only expect
|
||||||
// PUT /messages <encrypted IncomingPushMessageSignal>
|
// PUT /messages <encrypted IncomingPushMessageSignal>
|
||||||
textsecure.crypto.decryptWebsocketMessage(request.body, this.signalingKey).then(function(plaintext) {
|
textsecure.crypto.decryptWebsocketMessage(request.body, this.signalingKey).then(function(plaintext) {
|
||||||
|
|
|
@ -134,8 +134,9 @@
|
||||||
path : opts.keepalive.path,
|
path : opts.keepalive.path,
|
||||||
disconnect : opts.keepalive.disconnect
|
disconnect : opts.keepalive.disconnect
|
||||||
});
|
});
|
||||||
this.resetKeepAliveTimer = keepalive.reset.bind(keepalive);
|
var resetKeepAliveTimer = keepalive.reset.bind(keepalive);
|
||||||
socket.addEventListener('connect', this.resetKeepAliveTimer);
|
socket.addEventListener('connect', resetKeepAliveTimer);
|
||||||
|
socket.addEventListener('message', resetKeepAliveTimer);
|
||||||
socket.addEventListener('close', keepalive.stop.bind(keepalive));
|
socket.addEventListener('close', keepalive.stop.bind(keepalive));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue