mirror of
https://github.com/danbulant/discord.js
synced 2026-06-22 00:02:13 +00:00
Fix protocol versions
This commit is contained in:
parent
c02d7808c1
commit
a2f8680514
3 changed files with 10 additions and 5 deletions
|
|
@ -30,7 +30,10 @@ class RESTMethods {
|
|||
getGateway() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.rest.makeRequest('get', Constants.Endpoints.gateway, true)
|
||||
.then(res => resolve(res.url))
|
||||
.then(res => {
|
||||
this.rest.client.store.gateway = `${res.url}/?encoding=json&v=${this.rest.client.options.protocol_version}`;
|
||||
resolve(this.rest.client.store.gateway);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ class WebSocketManager {
|
|||
|
||||
connect(gateway) {
|
||||
this.status = Constants.Status.CONNECTING;
|
||||
this.store.gateway = `${gateway}/?v=${this.client.options.protocol_version}`;
|
||||
this.ws = new WebSocket(gateway);
|
||||
this.ws.onopen = () => this.eventOpen();
|
||||
this.ws.onclose = () => this.eventClose();
|
||||
|
|
@ -81,10 +80,14 @@ class WebSocketManager {
|
|||
return this.eventError(Constants.Errors.BAD_WS_MESSAGE);
|
||||
}
|
||||
|
||||
if (packet.op === 10) {
|
||||
this.client.manager.setupKeepAlive(packet.d.heartbeat_interval);
|
||||
}
|
||||
|
||||
return this.packetManager.handle(packet);
|
||||
}
|
||||
|
||||
EventError() {
|
||||
eventError() {
|
||||
this.tryReconnect();
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +111,7 @@ class WebSocketManager {
|
|||
this.ws.close();
|
||||
this.packetManager.handleQueue();
|
||||
this.client.emit(Constants.Events.RECONNECTING);
|
||||
this.connect(this.store.gateway);
|
||||
this.connect(this.client.store.gateway);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ class ReadyHandler extends AbstractHandler {
|
|||
handle(packet) {
|
||||
const data = packet.d;
|
||||
const client = this.packetManager.client;
|
||||
client.manager.setupKeepAlive(data.heartbeat_interval);
|
||||
|
||||
client.store.user = client.store.add('users', new ClientUser(client, data.user));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue