From c683790de791878dc99f6358651a0b14c73badaa Mon Sep 17 00:00:00 2001 From: Schuyler Cebulskie Date: Fri, 25 Nov 2016 19:40:53 -0500 Subject: [PATCH] Remove old uws-specific code (0.11.1 has the good stuff) --- package.json | 2 +- src/client/voice/VoiceWebSocket.js | 9 ++------- src/client/websocket/WebSocketManager.js | 15 +++++---------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 9a0671943..147904163 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "pako": "^1.0.3", "superagent": "^3.0.0", "tweetnacl": "^0.14.3", - "uws": "^0.11.0" + "uws": "^0.11.1" }, "peerDependencies": { "node-opus": "^0.2.0", diff --git a/src/client/voice/VoiceWebSocket.js b/src/client/voice/VoiceWebSocket.js index ea2b04cda..6c7303e27 100644 --- a/src/client/voice/VoiceWebSocket.js +++ b/src/client/voice/VoiceWebSocket.js @@ -72,15 +72,10 @@ class VoiceWebSocket extends EventEmitter { * @type {WebSocket} */ this.ws = new WebSocket(`wss://${this.voiceConnection.authentication.endpoint}`); - if (typeof window !== 'undefined') { - this.ws.onopen = this.onOpen.bind(this); - this.ws.onerror = this.onError.bind(this); - } else { - this.ws.on('open', this.onOpen.bind(this)); - this.ws.on('error', this.onError.bind(this)); - } + this.ws.onopen = this.onOpen.bind(this); this.ws.onmessage = this.onMessage.bind(this); this.ws.onclose = this.onClose.bind(this); + this.ws.onerror = this.onError.bind(this); } /** diff --git a/src/client/websocket/WebSocketManager.js b/src/client/websocket/WebSocketManager.js index 8fa4fd35a..43d3e7155 100644 --- a/src/client/websocket/WebSocketManager.js +++ b/src/client/websocket/WebSocketManager.js @@ -79,16 +79,11 @@ class WebSocketManager extends EventEmitter { this.normalReady = false; if (this.status !== Constants.Status.RECONNECTING) this.status = Constants.Status.CONNECTING; this.ws = new WebSocket(gateway); - if (browser) { - this.ws.binaryType = 'arraybuffer'; - this.ws.onopen = () => this.eventOpen(); - this.ws.onerror = (e) => this.eventError(e); - } else { - this.ws.on('open', this.eventOpen.bind(this)); - this.ws.on('error', this.eventError.bind(this)); - } - this.ws.onclose = (d) => this.eventClose(d); - this.ws.onmessage = (e) => this.eventMessage(e); + if (browser) this.ws.binaryType = 'arraybuffer'; + this.ws.onopen = this.eventOpen.bind(this); + this.ws.onmessage = this.eventMessage.bind(this); + this.ws.onclose = this.eventClose.bind(this); + this.ws.onerror = this.eventError.bind(this); this._queue = []; this._remaining = 3; }