@jnode/discord 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/gateway.js +4 -12
package/package.json
CHANGED
package/src/gateway.js
CHANGED
|
@@ -62,6 +62,7 @@ class DiscordGateway extends EventEmitter {
|
|
|
62
62
|
this.emit('socketClose', event);
|
|
63
63
|
clearTimeout(this._connectTimeout);
|
|
64
64
|
clearInterval(this._heartbeatInterval);
|
|
65
|
+
clearTimeout(this._heartbeatTimeout);
|
|
65
66
|
|
|
66
67
|
// error close
|
|
67
68
|
if ([4004, 4010, 4011, 4012, 4013, 4014].includes(event.code)) {
|
|
@@ -150,7 +151,7 @@ class DiscordGateway extends EventEmitter {
|
|
|
150
151
|
|
|
151
152
|
break;
|
|
152
153
|
case 11: // heartbeat ack
|
|
153
|
-
this.
|
|
154
|
+
clearTimeout(this._heartbeatTimeout);
|
|
154
155
|
break;
|
|
155
156
|
}
|
|
156
157
|
});
|
|
@@ -160,20 +161,11 @@ class DiscordGateway extends EventEmitter {
|
|
|
160
161
|
this.send(1, this._s);
|
|
161
162
|
|
|
162
163
|
// could not receive heartbeat ack
|
|
163
|
-
|
|
164
|
+
clearTimeout(this._heartbeatTimeout);
|
|
165
|
+
this._heartbeatTimeout = setTimeout(() => {
|
|
164
166
|
this.emit('heartbeatTimeout');
|
|
165
167
|
this.socket.close();
|
|
166
168
|
}, this.heartbeatAckTimeout);
|
|
167
|
-
|
|
168
|
-
// received ack
|
|
169
|
-
this.once('heartbeatAck', () => {
|
|
170
|
-
clearTimeout(timeout);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
// close
|
|
174
|
-
this.once('close', () => {
|
|
175
|
-
clearTimeout(timeout);
|
|
176
|
-
});
|
|
177
169
|
}
|
|
178
170
|
|
|
179
171
|
// sends a gateway event
|