mirror of
https://github.com/danbulant/discord.js
synced 2026-06-19 06:31:20 +00:00
Remove WebSocket datastore - move directly to WebSocketManager
This commit is contained in:
parent
bd50e3c0a5
commit
ad8b4c7698
5 changed files with 18 additions and 24 deletions
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;
|
||||
Loading…
Reference in a new issue