Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update lib/introspect.js

1. The "add method" procedure does not belong in the loop that builds the signature. It is just re-defined for each new signature part.

2. Made callback optional for cases in which we do not care about the method result. E.g.
player.playPause(false);
  • Loading branch information...
commit 7b8455d973d5b32d19cf356bea0de0a2e1d2b88b 1 parent 35e2578
@Ivshti Ivshti authored
Showing with 20 additions and 19 deletions.
  1. +20 −19 lib/introspect.js
View
39 lib/introspect.js
@@ -51,26 +51,27 @@ module.exports = function(obj, callback) {
console.log(arg);
if (arg.direction === 'in')
signature += arg.type;
-
- // add method
- currentIface[name] = (function(ifName, methodName, signature) {
- return function() {
- var args = Array.prototype.slice.apply(arguments);
- var callback = args[args.length - 1];
- var msg = {
- destination: obj.service.name,
- path: obj.name,
- 'interface': ifName,
- member: methodName
- };
- if (signature !== '') {
- msg.signature = signature;
- msg.body = args.slice(0,-1);
- }
- bus.invoke(msg, callback);
- };
- })(ifaceName, name, signature);
}
+
+ // add method
+ currentIface[name] = (function(ifName, methodName, signature) {
+ return function() {
+ var args = Array.prototype.slice.apply(arguments);
+ var callback = (typeof(args[args.length - 1]) == "function") ? args.pop() : function() {};
+ var msg = {
+ destination: obj.service.name,
+ path: obj.name,
+ 'interface': ifName,
+ member: methodName
+ };
+ if (signature !== '') {
+ msg.signature = signature;
+ msg.body = args;
+ }
+ bus.invoke(msg, callback);
+ };
+ })(ifaceName, name, signature);
+
console.log(' method: ', name, signature);
}
for (p=0; iface.property && p < iface.property.length; ++p)
Please sign in to comment.
Something went wrong with that request. Please try again.