diff options
author | Iain Fraser <iainf@netduma.com> | 2016-05-19 14:40:42 +0100 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2016-06-06 14:47:10 +0200 |
commit | 976719d89ca58cb6d393ded3a8451b7ba6567361 (patch) | |
tree | 3b00a7af8c5007c1afe5837e83d1a764245cc063 /lua/subscriber.lua | |
parent | 96ab0b3032f5caf443162f38073403a372b3e1c1 (diff) | |
download | ubus-976719d89ca58cb6d393ded3a8451b7ba6567361.tar.gz |
Implemented publish/subscribe lua bindings to libubus-lua with example lua files.
Diffstat (limited to 'lua/subscriber.lua')
-rwxr-xr-x | lua/subscriber.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lua/subscriber.lua b/lua/subscriber.lua new file mode 100755 index 0000000..e1d3a9f --- /dev/null +++ b/lua/subscriber.lua @@ -0,0 +1,25 @@ +#!/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 ) + print("Count: ", msg["count"]) + end, +} + +conn:subscribe( "test", sub ) + +uloop.run() |