]> git.wh0rd.org - chrome-ext/music-player-client.git/commitdiff
tcp-client: allow caller to force pulling of more data
authorMike Frysinger <vapier@gentoo.org>
Sun, 1 Sep 2013 09:25:32 +0000 (05:25 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sun, 1 Sep 2013 09:25:32 +0000 (05:25 -0400)
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
main.js

index c46921f2396d48d263e326f9ed7c04dd08ec3798..ed3b598126db85ed7b51d930337771921bc58fe1 100644 (file)
@@ -124,7 +124,7 @@ Author: Boris Smus (smus@chromium.org)
    */
   TcpClient.prototype._onConnectComplete = function(resultCode) {
     // Start polling for reads.
    */
   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');
 
     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
    */
    *
    * @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));
   };
 
     socket.read(this.socketId, null, this._onDataRead.bind(this));
   };
 
diff --git a/main.js b/main.js
index fefb964e54b8974fe12f5949f18d0ed65f527881..b83e0a219739a85ff931f8129635815c3eb3b533 100644 (file)
--- 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.send = function(data, cb) {
        this.tcpclient.sendMessage(data, cb);
 }
+TcpClientSender.prototype.poll = function() {
+       this.tcpclient.poll();
+}
 
 function tramp_mpc_recv(data) {
        mpc.recv(data);
 
 function tramp_mpc_recv(data) {
        mpc.recv(data);