2016-05-19 15:40:42 +02:00
|
|
|
#!/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 = {
|
2018-01-16 18:13:39 +01:00
|
|
|
notify = function( msg, name )
|
|
|
|
print("name:", name)
|
|
|
|
print(" count:", msg["count"])
|
2016-05-19 15:40:42 +02:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
conn:subscribe( "test", sub )
|
|
|
|
|
|
|
|
uloop.run()
|