From f412d395d98104240e9e6e26fc292c7c2c62944f Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 6 Apr 2018 01:20:34 +0200 Subject: [PATCH] unknown fix --- webpack/lib/audio-manager.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/webpack/lib/audio-manager.js b/webpack/lib/audio-manager.js index 01c0d53..7da9647 100644 --- a/webpack/lib/audio-manager.js +++ b/webpack/lib/audio-manager.js @@ -32,18 +32,17 @@ export default class AudioManager{ /* (7) Create websocket connection */ this.ws = new WebSocket('wss://ws.douscord.xdrm.io/audio/2'); - let self = this; /* (8) Manage websocket requests */ this._ws = { stack: [], - send(_data){ - if( self.ws.readyState !== 1 ) // not connected -> stack - return self._ws.stack.push(_data); + send: function(_data){ + if( this.ws.readyState !== 1 ) // not connected -> stack + return this._ws.stack.push(_data); console.warn(`send buffer[${_data.length}]`); - self.ws.send(_data); - }, + this.ws.send(_data); + }.bind(this) }; /* (9) Manage websocket message stack */ @@ -65,9 +64,9 @@ export default class AudioManager{ let fr = new FileReader(); fr.onload = function(){ - let buf16 = new Int16Array(this.result); - self.receive(buf16).bind(self); - }; + let buf16 = new Int16Array(fr.result); + this.receive(buf16).bind(this); + }.bind(this); fr.readAsArrayBuffer(_msg.data);