X-Git-Url: https://git.wh0rd.org/?p=chrome-ext%2Fmusic-player-client.git;a=blobdiff_plain;f=js%2Ftcp-client.js;fp=js%2Ftcp-client.js;h=55bdaafa658d55ed7e798076542fdb8dfb45a206;hp=ed3b598126db85ed7b51d930337771921bc58fe1;hb=e7d6adb435d30041cb586158b52fd4fdd71cd088;hpb=ccfc12deb15558bccd7d1c5a586fef5b86d386ea diff --git a/js/tcp-client.js b/js/tcp-client.js index ed3b598..55bdaaf 100644 --- a/js/tcp-client.js +++ b/js/tcp-client.js @@ -42,6 +42,7 @@ Author: Boris Smus (smus@chromium.org) // Socket. this.socketId = null; this.isConnected = false; + this.pollerId = null; log('initialized tcp client'); } @@ -92,6 +93,8 @@ Author: Boris Smus (smus@chromium.org) */ TcpClient.prototype.disconnect = function() { socket.disconnect(this.socketId); + clearInterval(this.pollerId); + this.pollerId = null; this.isConnected = false; }; @@ -124,7 +127,8 @@ Author: Boris Smus (smus@chromium.org) */ TcpClient.prototype._onConnectComplete = function(resultCode) { // Start polling for reads. - setInterval(this.poll.bind(this), 500); + clearInterval(this.pollerId); + this.pollerId = setInterval(this.poll.bind(this), 500); if (this.callbacks.connect) { log('connect complete');