Diff

util/pubsub.lua @ 3672:b24db47995ac

mod_pubsub, util.pubsub: Support node creation
author Florian Zeitz <florob@babelmonkeys.de>
date Wed, 01 Dec 2010 23:38:47 +0100
parent 3641:3603aeb325de
child 3698:77171fd1dc3c
line wrap: on
line diff
--- a/util/pubsub.lua	Sun Nov 28 21:19:18 2010 +0000
+++ b/util/pubsub.lua	Wed Dec 01 23:38:47 2010 +0100
@@ -28,6 +28,14 @@
 	end
 end
 
+function service:create(node, actor)
+	if not self.nodes[node] then
+		self.nodes[node] = { name = node, subscribers = {}, config = {}, data = {} };
+		return true;
+	end
+	return false, "conflict";
+end
+
 function service:publish(node, actor, id, item)
 	local node_obj = self.nodes[node];
 	if not node_obj then