Files
discord.js/src/client/websocket/packets/handlers/Resumed.js
SpaceEEC 1fe201ae90 Backporting, doc/bug fixes as well deprecation (#1826)
* Backporting, doc/bug fixes as well deprecation

* Adress issue with not resettable icons/images
2017-08-25 15:14:05 +02:00

29 lines
765 B
JavaScript

const AbstractHandler = require('./AbstractHandler');
const Constants = require('../../../../util/Constants');
class ResumedHandler extends AbstractHandler {
handle(packet) {
const client = this.packetManager.client;
const ws = client.ws.connection;
ws._trace = packet.d._trace;
ws.status = Constants.Status.READY;
this.packetManager.handleQueue();
const replayed = ws.sequence - ws.closeSequence;
ws.debug(`RESUMED ${ws._trace.join(' -> ')} | replayed ${replayed} events.`);
client.emit(Constants.Events.RESUME, replayed);
ws.heartbeat();
}
}
/**
* Emitted whenever a WebSocket resumes.
* @event Client#resume
* @param {number} replayed The number of events that were replayed
*/
module.exports = ResumedHandler;