From 0a3a435e6ad8fcd1232675e09a07baa73be09497 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 1 Sep 2013 05:25:32 -0400 Subject: [PATCH] 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. --- js/tcp-client.js | 4 ++-- main.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) 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); -- 2.39.2