Changeset

3909:c2dc7f7eed94

util.pubsub: Modify new() to take a config, and add a default config via a metatable
author Matthew Wild <mwild1@gmail.com>
date Tue, 21 Dec 2010 03:22:40 +0000
parents 3908:4d8081c35f01
children 3910:80fe910f912a
files util/pubsub.lua
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/util/pubsub.lua	Tue Dec 21 03:18:17 2010 +0000
+++ b/util/pubsub.lua	Tue Dec 21 03:22:40 2010 +0000
@@ -3,8 +3,19 @@
 local service = {};
 local service_mt = { __index = service };
 
-function new(cb)
-	return setmetatable({ cb = cb or {}, nodes = {} }, service_mt);
+local default_config = {
+	broadcaster = function () end;
+	get_affiliation = function () end;
+	capabilities = {};
+};
+
+function new(config)
+	config = config or {};
+	return setmetatable({
+		config = setmetatable(config, { __index = default_config });
+		affiliations = {};
+		nodes = {};
+	}, service_mt);
 end
 
 function service:add_subscription(node, actor, jid)