add Lua bindings for ubus events
[project/ubus.git] / lua / test.lua
index d9ecb45..d24ac6e 100755 (executable)
@@ -20,9 +20,12 @@ local my_method = {
        },
        test = {
                hello = {
-                       function(req)
+                       function(req, msg)
                                conn:reply(req, {message="foo"});
                                print("Call to function 'hello'")
+                               for k, v in pairs(msg) do
+                                       print("key=" .. k .. " value=" .. tostring(v))
+                               end
                        end, {id = ubus.INT32, msg = ubus.STRING }
                },
                hello1 = {
@@ -36,4 +39,16 @@ local my_method = {
 }
 
 conn:add(my_method)
+
+local my_event = {
+       test = function(msg)
+               print("Call to test event")
+               for k, v in pairs(msg) do
+                       print("key=" .. k .. " value=" .. tostring(v))
+               end
+       end,
+}
+
+conn:listen(my_event)
+
 uloop.run()