X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=jsapi%2Fjs-hello.js;fp=jsapi%2Fjs-hello.js;h=c6c41dfc2ebb69a0a2bbded89e45c3a4417b9a87;hb=7aad83842cdab620e91fe73ac4731d75eb9c283a;hp=0000000000000000000000000000000000000000;hpb=9a623c3aa32ec0fbf9682f37a990abd00f38da60;p=src%2Fapp-framework-binder.git diff --git a/jsapi/js-hello.js b/jsapi/js-hello.js new file mode 100644 index 00000000..c6c41dfc --- /dev/null +++ b/jsapi/js-hello.js @@ -0,0 +1,28 @@ +var counter = 0; + +exports.ping = function(req, args) { + + afb_req_success(req, args, String(++counter)); +}; + +exports.fail = function(req, args) { + + afb_req_fail(req, "fail", String(++counter)); +}; + +exports.subcall = function(req, args) { + + if (!args.api || !args.verb) + afb_req_fail(req, "bad-args", String(++counter)); + else { + var x = afb_req_subcall_sync(req, args.api, args.verb, args.args); + if (!x) + afb_req_fail(req, "null-answer", String(++counter)); + else if (x.request.status == "success") + afb_req_success(req, x.response, String(++counter)); + else + afb_req_fail(req, x.request.status, String(++counter)); + } +}; + +