Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sharpen RPC result wrapping
  • Loading branch information
Tobias Oberstein committed Apr 20, 2014
1 parent 9830a6e commit 8a7e132
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions package/lib/session.js
Expand Up @@ -621,15 +621,18 @@ var Session = function (socket, defer, onchallenge) {

var details = msg[2];

var args = msg[3] || [];
var kwargs = msg[4] || {};

// maybe wrap complex result:
var result = null;
if (msg.length > 3) {
if (msg.length > 4 || msg[3].length > 1) {
// wrap complex result
result = new Result(msg[3], msg[4]);
} else {
// single positional result
result = msg[3][0];
}
if (args.length > 1 || Object.keys(kwargs).length > 0) {
// wrap complex result is more than 1 positional result OR
// non-empty keyword result
result = new Result(args, kwargs);
} else if (args.length > 0) {
// single positional result
result = args[0];
}

var r = self._call_reqs[request];
Expand Down

0 comments on commit 8a7e132

Please sign in to comment.