mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
Remove WebSocket datastore - move directly to WebSocketManager
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -2,7 +2,6 @@ const WebSocket = require('ws');
|
|||||||
const Constants = require('../../util/Constants');
|
const Constants = require('../../util/Constants');
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
const PacketManager = require('./packets/WebSocketPacketManager');
|
const PacketManager = require('./packets/WebSocketPacketManager');
|
||||||
const WebSocketManagerDataStore = require('../../structures/datastore/WebSocketManagerDataStore');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The WebSocket Manager of the Client
|
* The WebSocket Manager of the Client
|
||||||
@@ -22,16 +21,23 @@ class WebSocketManager {
|
|||||||
* @type {PacketManager}
|
* @type {PacketManager}
|
||||||
*/
|
*/
|
||||||
this.packetManager = new PacketManager(this);
|
this.packetManager = new PacketManager(this);
|
||||||
/**
|
|
||||||
* The WebSocketManager datastore
|
|
||||||
* @type {WebSocketManagerDataStore}
|
|
||||||
*/
|
|
||||||
this.store = new WebSocketManagerDataStore();
|
|
||||||
/**
|
/**
|
||||||
* The status of the WebSocketManager, a type of Constants.Status. It defaults to IDLE.
|
* The status of the WebSocketManager, a type of Constants.Status. It defaults to IDLE.
|
||||||
* @type {Number}
|
* @type {Number}
|
||||||
*/
|
*/
|
||||||
this.status = Constants.Status.IDLE;
|
this.status = Constants.Status.IDLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The session ID of the connection, null if not yet available.
|
||||||
|
* @type {?String}
|
||||||
|
*/
|
||||||
|
this.sessionID = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The packet count of the client, null if not yet available.
|
||||||
|
* @type {?Number}
|
||||||
|
*/
|
||||||
|
this.sequence = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,8 +92,8 @@ class WebSocketManager {
|
|||||||
_sendResume() {
|
_sendResume() {
|
||||||
const payload = {
|
const payload = {
|
||||||
token: this.client.store.token,
|
token: this.client.store.token,
|
||||||
session_id: this.store.sessionID,
|
session_id: this.sessionID,
|
||||||
seq: this.store.sequence,
|
seq: this.sequence,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.send({
|
this.send({
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ class WebSocketPacketManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSequence(s) {
|
setSequence(s) {
|
||||||
if (s && s > this.ws.store.sequence) {
|
if (s && s > this.ws.sequence) {
|
||||||
this.ws.store.sequence = s;
|
this.ws.sequence = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class ReadyHandler extends AbstractHandler {
|
|||||||
client.store.newChannel(privateDM);
|
client.store.newChannel(privateDM);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.packetManager.ws.store.sessionID = data.session_id;
|
this.packetManager.ws.sessionID = data.session_id;
|
||||||
|
|
||||||
this.packetManager.ws.checkIfReady();
|
this.packetManager.ws.checkIfReady();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
const AbstractDataStore = require('./AbstractDataStore');
|
|
||||||
|
|
||||||
class WebSocketManagerDataStore extends AbstractDataStore {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.sessionID = null;
|
|
||||||
this.sequence = -1;
|
|
||||||
this.gateway = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = WebSocketManagerDataStore;
|
|
||||||
Reference in New Issue
Block a user