mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +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 zlib = require('zlib');
|
||||
const PacketManager = require('./packets/WebSocketPacketManager');
|
||||
const WebSocketManagerDataStore = require('../../structures/datastore/WebSocketManagerDataStore');
|
||||
|
||||
/**
|
||||
* The WebSocket Manager of the Client
|
||||
@@ -22,16 +21,23 @@ class WebSocketManager {
|
||||
* @type {PacketManager}
|
||||
*/
|
||||
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.
|
||||
* @type {Number}
|
||||
*/
|
||||
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() {
|
||||
const payload = {
|
||||
token: this.client.store.token,
|
||||
session_id: this.store.sessionID,
|
||||
seq: this.store.sequence,
|
||||
session_id: this.sessionID,
|
||||
seq: this.sequence,
|
||||
};
|
||||
|
||||
this.send({
|
||||
|
||||
@@ -55,8 +55,8 @@ class WebSocketPacketManager {
|
||||
}
|
||||
|
||||
setSequence(s) {
|
||||
if (s && s > this.ws.store.sequence) {
|
||||
this.ws.store.sequence = s;
|
||||
if (s && s > this.ws.sequence) {
|
||||
this.ws.sequence = s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class ReadyHandler extends AbstractHandler {
|
||||
client.store.newChannel(privateDM);
|
||||
}
|
||||
|
||||
this.packetManager.ws.store.sessionID = data.session_id;
|
||||
this.packetManager.ws.sessionID = data.session_id;
|
||||
|
||||
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