Integrate keepalives into websocket resources

This commit is contained in:
lilia 2015-07-28 13:05:55 -07:00
parent 7d2b41db11
commit cd363bd84d
6 changed files with 116 additions and 118 deletions

View file

@ -42,14 +42,15 @@
eventTarget.dispatchEvent(ev);
});
}
}
};
this.wsr = new WebSocketResource(this.socket, this.handleRequest.bind(this));
this.keepalive = new KeepAlive(this.wsr);
this.wsr = new WebSocketResource(this.socket, this.handleRequest.bind(this), {
keepalive: { path: '/v1/keepalive', disconnect: true }
});
},
handleRequest: function(request) {
this.keepalive.reset();
this.wsr.resetKeepAliveTimer();
// TODO: handle different types of requests. for now we only expect
// PUT /messages <encrypted IncomingPushMessageSignal>
textsecure.crypto.decryptWebsocketMessage(request.body).then(function(plaintext) {