MUC: Use events for hooking stanzas instead of the component stanza handler.

Thu, 04 Nov 2010 19:38:05 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Thu, 04 Nov 2010 19:38:05 +0500
changeset 3560
fb49b63e3fe2
parent 3559
0708d42ef0d4
child 3561
579c087059fc

MUC: Use events for hooking stanzas instead of the component stanza handler.

plugins/muc/mod_muc.lua file | annotate | diff | comparison | revisions
--- a/plugins/muc/mod_muc.lua	Thu Nov 04 19:26:04 2010 +0500
+++ b/plugins/muc/mod_muc.lua	Thu Nov 04 19:38:05 2010 +0500
@@ -113,7 +113,8 @@
 	end
 end
 
-component = register_component(muc_host, function(origin, stanza)
+function stanza_handler(event)
+	local origin, stanza = event.origin, event.stanza;
 	local to_node, to_host, to_resource = jid_split(stanza.attr.to);
 	if to_node then
 		local bare = to_node.."@"..to_host;
@@ -142,7 +143,18 @@
 	end
 	-- to the main muc domain
 	handle_to_domain(origin, stanza);
-end);
+end
+module:hook("iq/bare", stanza_handler);
+module:hook("message/bare", stanza_handler);
+module:hook("presence/bare", stanza_handler);
+module:hook("iq/full", stanza_handler);
+module:hook("message/full", stanza_handler);
+module:hook("presence/full", stanza_handler);
+module:hook("iq/host", stanza_handler);
+module:hook("message/host", stanza_handler);
+module:hook("presence/host", stanza_handler);
+
+component = register_component(muc_host, function() end);
 function component.send(stanza) -- FIXME do a generic fix
 	if stanza.attr.type == "result" or stanza.attr.type == "error" then
 		core_post_stanza(component, stanza);

mercurial