summaryrefslogtreecommitdiff
path: root/lua/subscriber.lua
blob: f59448db72c5e233ce70c908df0ccf21791f31c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/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()