Use pre-parsed websocket messages (fixes #407) (#412)

This commit is contained in:
Programmix
2016-06-05 13:53:57 -07:00
committed by abal
parent 1672465768
commit e59dd9b12a
2 changed files with 8 additions and 12 deletions

View File

@@ -370,9 +370,7 @@ var InternalClient = (function () {
var timeout = null;
var check = function check(m) {
var data = JSON.parse(m);
var check = function check(data) {
if (data.t === "VOICE_SERVER_UPDATE") {
if (data.d.guild_id !== server.id) return; // ensure it is the right server
token = data.d.token;
@@ -389,16 +387,16 @@ var InternalClient = (function () {
if (timeout) {
clearTimeout(timeout);
}
_this5.websocket.removeListener("message", check);
_this5.client.removeListener("raw", check);
}
};
timeout = setTimeout(function () {
_this5.websocket.removeListener("message", check);
_this5.client.removeListener("raw", check);
reject(new Error("No voice server details within 10 seconds"));
}, 10000);
_this5.websocket.on("message", check);
_this5.client.on("raw", check);
joinSendWS();
});
};

View File

@@ -290,9 +290,7 @@ export default class InternalClient {
var timeout = null;
var check = m => {
var data = JSON.parse(m);
var check = data => {
if (data.t === "VOICE_SERVER_UPDATE") {
if (data.d.guild_id !== server.id) return // ensure it is the right server
token = data.d.token;
@@ -309,16 +307,16 @@ export default class InternalClient {
if (timeout) {
clearTimeout(timeout);
}
this.websocket.removeListener("message", check);
this.client.removeListener("raw", check);
}
};
timeout = setTimeout(() => {
this.websocket.removeListener("message", check);
this.client.removeListener("raw", check);
reject(new Error("No voice server details within 10 seconds"));
}, 10000);
this.websocket.on("message", check);
this.client.on("raw", check);
joinSendWS();
});
}