d9ecb4535affb1a0ce8bf4d62b69899626d1d922
[project/ubus.git] / lua / test.lua
1 #!/usr/bin/env lua
2
3 require "ubus"
4 require "uloop"
5
6 uloop.init()
7
8 local conn = ubus.connect()
9 if not conn then
10         error("Failed to connect to ubus")
11 end
12
13 local my_method = {
14         broken = {
15                 hello = 1,
16                 hello1 = {
17                         function(req)
18                         end, {id = "fail" }
19                 },
20         },
21         test = {
22                 hello = {
23                         function(req)
24                                 conn:reply(req, {message="foo"});
25                                 print("Call to function 'hello'")
26                         end, {id = ubus.INT32, msg = ubus.STRING }
27                 },
28                 hello1 = {
29                         function(req)
30                                 conn:reply(req, {message="foo1"});
31                                 conn:reply(req, {message="foo2"});
32                                 print("Call to function 'hello1'")
33                         end, {id = ubus.INT32, msg = ubus.STRING }
34                 }
35         }
36 }
37
38 conn:add(my_method)
39 uloop.run()