From 0b7db07ef2e799220a7211622abefbb36e7387e1 Mon Sep 17 00:00:00 2001 From: Stephen Pair Date: Thu, 18 Jul 2013 16:21:48 -0400 Subject: [PATCH] add batched call support to RpcClient --- RpcClient.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/RpcClient.js b/RpcClient.js index 1a091ef6e..53bef8d53 100644 --- a/RpcClient.js +++ b/RpcClient.js @@ -14,6 +14,14 @@ function ClassSpec(b) { this.user = opts.user || 'user'; this.pass = opts.pass || 'pass'; this.protocol = (opts.protocol == 'http') ? http : https; + this.batchedCalls = null; + } + + RpcClient.prototype.batch = function(batchCallback, resultCallback) { + this.batchedCalls = []; + batchCallback(); + rpc.call(this, this.batchedCalls, resultCallback); + this.batchedCalls = null; } var callspec = { @@ -90,10 +98,16 @@ function ClassSpec(b) { function generateRPCMethods(constructor, apiCalls, rpc) { function createRPCMethod(methodName, argMap) { return function() { - for (var i=0; i