From: Mike Frysinger Date: Sun, 1 Sep 2013 09:25:32 +0000 (-0400) Subject: tcp-client: allow caller to force pulling of more data X-Git-Tag: v3.0~11 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=0a3a435e6ad8fcd1232675e09a07baa73be09497;p=chrome-ext%2Fmusic-player-client.git tcp-client: allow caller to force pulling of more data When we get a burst of data that fills up the buffer, we don't want to delay 500 msecs for the buffer to refill. So let the caller force a fresh pull of data when it knows it is expecting more. --- diff --git a/js/tcp-client.js b/js/tcp-client.js index c46921f..ed3b598 100644 --- a/js/tcp-client.js +++ b/js/tcp-client.js @@ -124,7 +124,7 @@ Author: Boris Smus (smus@chromium.org) */ TcpClient.prototype._onConnectComplete = function(resultCode) { // Start polling for reads. - setInterval(this._periodicallyRead.bind(this), 500); + setInterval(this.poll.bind(this), 500); if (this.callbacks.connect) { log('connect complete'); @@ -138,7 +138,7 @@ Author: Boris Smus (smus@chromium.org) * * @see http://developer.chrome.com/apps/socket.html#method-read */ - TcpClient.prototype._periodicallyRead = function() { + TcpClient.prototype.poll = function() { socket.read(this.socketId, null, this._onDataRead.bind(this)); }; diff --git a/main.js b/main.js index fefb964..b83e0a2 100644 --- a/main.js +++ b/main.js @@ -11,6 +11,9 @@ function TcpClientSender(tcpclient) { TcpClientSender.prototype.send = function(data, cb) { this.tcpclient.sendMessage(data, cb); } +TcpClientSender.prototype.poll = function() { + this.tcpclient.poll(); +} function tramp_mpc_recv(data) { mpc.recv(data);