diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | diller/main.lua | 23 |
2 files changed, 19 insertions, 6 deletions
@@ -9,5 +9,5 @@ compile-%: @$(MAKE) -j 8 $(patsubst %.lua,%.lc,$(wildcard $(patsubst compile-%,%,$@)/*.lua)) upload-%: -# @$(MAKE) $(patsubst upload-%,compile-%,$@) + @$(MAKE) $(patsubst upload-%,compile-%,$@) ./upload.sh $(patsubst upload-%,%,$@) diff --git a/diller/main.lua b/diller/main.lua index f982f8c..234a84b 100644 --- a/diller/main.lua +++ b/diller/main.lua @@ -9,6 +9,8 @@ local P = {} local inter = require('inter') local mq = require('mq') +local properties = {} + local function on_cmd(cmd, args) if not cmd then return @@ -44,21 +46,32 @@ local function on_cmd(cmd, args) if not id then print("fail status=missing-id") else - local name_path = id.."/name" - mq.subscribe(name_path, function() print('message on '..path) end) + property = properties[id] + local name_path = id.."/name" local description_path = id.."/description" - mq.subscribe(description_path, function() print('message on '..path) end) + + if not property then + print("new property: "..id) + property = {} + properties[id] = property + mq.subscribe(name_path, function() print('message on '..path) end) + mq.subscribe(description_path, function() print('message on '..path) end) + end if args.value then local path = id.."/value" mq.publish(path, args.value) end - if args.name then + if args.name and property.name ~= args.name then + print("publishing name") mq.publish(name_path, args.name) + property.name = args.name end - if args.description then + if args.description and property.description ~= args.description then + print("publishing description") mq.publish(description_path, args.description) + property.description = args.description end end elseif cmd == "publish" then |