mirror of
https://github.com/danbulant/discord.js
synced 2026-06-19 22:51:32 +00:00
Webpack build: 3eca3ba95e
This commit is contained in:
parent
4c9575d1f8
commit
654fada91f
2 changed files with 22 additions and 11 deletions
|
|
@ -11640,6 +11640,7 @@ class Client extends EventEmitter {
|
|||
_pong(startTime) {
|
||||
this.pings.unshift(Date.now() - startTime);
|
||||
if (this.pings.length > 3) this.pings.length = 3;
|
||||
this.clearTimeout(this._ackTimeout);
|
||||
}
|
||||
|
||||
_setPresence(id, presence) {
|
||||
|
|
@ -19429,14 +19430,22 @@ class ClientManager {
|
|||
* @param {number} time The interval in milliseconds at which heartbeat packets should be sent
|
||||
*/
|
||||
setupKeepAlive(time) {
|
||||
this.heartbeatInterval = this.client.setInterval(() => {
|
||||
this.client.emit('debug', 'Sending heartbeat');
|
||||
this.client._pingTimestamp = Date.now();
|
||||
this.client.ws.send({
|
||||
op: Constants.OPCodes.HEARTBEAT,
|
||||
d: this.client.ws.sequence,
|
||||
}, true);
|
||||
}, time);
|
||||
this.heartbeatInterval = this.client.setInterval(this.ping.bind(this), time);
|
||||
}
|
||||
|
||||
ping() {
|
||||
this.client.emit('debug', 'Sending heartbeat');
|
||||
this.client._pingTimestamp = Date.now();
|
||||
this.client.ws.send({
|
||||
op: Constants.OPCodes.HEARTBEAT,
|
||||
d: this.client.ws.sequence,
|
||||
}, true);
|
||||
|
||||
const lastPing = this.client.ping;
|
||||
|
||||
this.client._ackTimeout = this.client.setTimeout(() => {
|
||||
this.client.ws.ws.close(1005);
|
||||
}, lastPing ? lastPing * 20 : 20e3);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
|
@ -22492,6 +22501,8 @@ class ReadyHandler extends AbstractHandler {
|
|||
const client = this.packetManager.client;
|
||||
const data = packet.d;
|
||||
|
||||
client.manager.ping();
|
||||
|
||||
const clientUser = new ClientUser(client, data.user);
|
||||
client.user = clientUser;
|
||||
client.readyAt = new Date();
|
||||
|
|
|
|||
6
discord.indev.min.js
vendored
6
discord.indev.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue