ubus/lua/subscriber.lua
Dirk Feytons 5bae22eb54 ubus/lua: pass notification name to callback
The callback function registered to be invoked when subscribing to a
notification was only passed the notification data (if any) but not the name
of the notification.

This name is now passed as second argument to remain backwards compatible.
The example subscriber.lua has also be updated.

Signed-off-by: Dirk Feytons <dirk.feytons@gmail.com>
2018-01-17 09:59:58 +01:00

26 lines
389 B
Lua
Executable file

#!/usr/bin/env lua
--[[
A demo of ubus subscriber binding. Should be run after publisher.lua
--]]
require "ubus"
require "uloop"
uloop.init()
local conn = ubus.connect()
if not conn then
error("Failed to connect to ubus")
end
local sub = {
notify = function( msg, name )
print("name:", name)
print(" count:", msg["count"])
end,
}
conn:subscribe( "test", sub )
uloop.run()