X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fubus.git;a=blobdiff_plain;f=lua%2Ftest.lua;fp=lua%2Ftest.lua;h=d9ecb4535affb1a0ce8bf4d62b69899626d1d922;hp=0000000000000000000000000000000000000000;hb=73380e45c9c73a425b304a9081be62d2aeaa5a3f;hpb=c382792d9893ed1b0c1e1b0db2ad9a7eaa7a78e1 diff --git a/lua/test.lua b/lua/test.lua new file mode 100755 index 0000000..d9ecb45 --- /dev/null +++ b/lua/test.lua @@ -0,0 +1,39 @@ +#!/usr/bin/env lua + +require "ubus" +require "uloop" + +uloop.init() + +local conn = ubus.connect() +if not conn then + error("Failed to connect to ubus") +end + +local my_method = { + broken = { + hello = 1, + hello1 = { + function(req) + end, {id = "fail" } + }, + }, + test = { + hello = { + function(req) + conn:reply(req, {message="foo"}); + print("Call to function 'hello'") + end, {id = ubus.INT32, msg = ubus.STRING } + }, + hello1 = { + function(req) + conn:reply(req, {message="foo1"}); + conn:reply(req, {message="foo2"}); + print("Call to function 'hello1'") + end, {id = ubus.INT32, msg = ubus.STRING } + } + } +} + +conn:add(my_method) +uloop.run()