Rewrite WebSocket internals (#1410)

* Start rewriting Manager and Connection

* more stuff

* stuff

* Fix ready bug

* some stuff i forgot

* fix some stuff

* add stupid heartbeat ack like seriously who cares

* woo!

* fix a bug

* rate limit the dumb websocket

* stuff

* hdocs

* Docs

* Remove ClientManager#setupKeepAlive as it is now redundant

* Change Client._pingTimestamp to a getter that fetches the timestamp from the WebSocketConnection

* are you happy now eslint smh

* make gus happy

* Add CloseEvent external doc

* Make sure to emit 'reconnecting' when actually reconnecting

* ffs

* Fix RESUME logic

* Add heartbeat ack debug messages, including latency data

* Dumb stuff for Gus

* thx eslint

* more dumb stuff

* more dumb crap smh gus i h8 u

* moar messages

* fix for using wrong status, causing certain events not to be fired (#1422)
This commit is contained in:
Amish Shah
2017-04-28 16:13:06 +01:00
committed by GitHub
parent 95bcac9d9b
commit 195fcfa15c
13 changed files with 541 additions and 432 deletions

View File

@@ -1,18 +1,20 @@
const AbstractHandler = require('./AbstractHandler');
const Constants = require('../../../../util/Constants');
class ResumedHandler extends AbstractHandler {
handle(packet) {
const client = this.packetManager.client;
const ws = client.ws;
const ws = client.ws.connection;
ws._trace = packet.d._trace;
const replayed = ws.sequence - ws.resumeStart;
ws.resumeStart = -1;
ws.status = Constants.Status.READY;
this.packetManager.handleQueue();
const replayed = ws.sequence - ws.closeSequence;
client.emit('debug', `RESUMED ${ws._trace.join(' -> ')} | replayed ${replayed} events. `);
client.emit('resume', replayed);
ws.heartbeat();
}
}