subscriber.lua 389 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env lua
  2. --[[
  3. A demo of ubus subscriber binding. Should be run after publisher.lua
  4. --]]
  5. require "ubus"
  6. require "uloop"
  7. uloop.init()
  8. local conn = ubus.connect()
  9. if not conn then
  10. error("Failed to connect to ubus")
  11. end
  12. local sub = {
  13. notify = function( msg, name )
  14. print("name:", name)
  15. print(" count:", msg["count"])
  16. end,
  17. }
  18. conn:subscribe( "test", sub )
  19. uloop.run()