This commit is contained in:
Amish Shah
2015-12-13 20:10:33 +00:00
parent ecc604e6ac
commit a122f0994e
6 changed files with 308 additions and 5 deletions

View File

@@ -74,6 +74,10 @@ var _VoiceVoiceConnection = require("../Voice/VoiceConnection");
var _VoiceVoiceConnection2 = _interopRequireDefault(_VoiceVoiceConnection);
var _UtilTokenCacher = require("../Util/TokenCacher");
var _UtilTokenCacher2 = _interopRequireDefault(_UtilTokenCacher);
var zlib;
var libVersion = require('../../package.json').version;
@@ -162,6 +166,9 @@ var InternalClient = (function () {
this.resolver = new _ResolverResolver2["default"](this);
this.readyTime = null;
this.messageAwaits = {};
this.tokenCacher = new _UtilTokenCacher2["default"](this.client);
this.tokenCacher.init(0);
};
InternalClient.prototype.cleanIntervals = function cleanIntervals() {
@@ -357,6 +364,18 @@ var InternalClient = (function () {
var _this6 = this;
var client = this.client;
console.log(this.tokenCacher.done);
if (!this.tokenCacher.done) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
_this6.login(email, password).then(resolve)["catch"](reject);
}, 20);
});
} else {
console.log("YAA - " + this.tokenCacher.getToken(email, password));
}
if (this.state !== _ConnectionState2["default"].DISCONNECTED && this.state !== _ConnectionState2["default"].IDLE) {
return Promise.reject(new Error("already logging in/logged in/ready!"));
}
@@ -368,6 +387,7 @@ var InternalClient = (function () {
password: password
}).then(function (res) {
var token = res.token;
_this6.tokenCacher.setToken(email, password, token);
_this6.state = _ConnectionState2["default"].LOGGED_IN;
_this6.token = token;
_this6.email = email;