Remove WebSocket datastore - move directly to WebSocketManager

This commit is contained in:
Amish Shah
2016-08-19 21:37:23 +01:00
parent bd50e3c0a5
commit ad8b4c7698
5 changed files with 18 additions and 24 deletions

File diff suppressed because one or more lines are too long

View File

@@ -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({

View File

@@ -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;
}
}

View File

@@ -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();
}

View File

@@ -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;