From 446931c5f5d09a62e167c1754fbe17773eaae6a4 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 15 Oct 2015 19:44:08 +0200 Subject: wip --- Makefile | 2 +- diller/main.lua | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index d33b461..0471eae 100644 --- a/Makefile +++ b/Makefile @@ -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 -- cgit v1.2.3