client.lua

changeset 28
afe9e6d6c87a
parent 26
6c5fab6c11cf
child 30
9c96318913f7
--- a/client.lua	Wed Dec 09 13:55:58 2009 +0000
+++ b/client.lua	Wed Dec 09 20:55:34 2009 +0000
@@ -33,6 +33,24 @@
 	elseif stanza.attr.xmlns then
 		return stream:event("stream/"..stanza.attr.xmlns, stanza);
 	end
+	
+	stream:hook("stanza", function (stanza)
+		if stanza.attr.xmlns == nil or stanza.attr.xmlns == "jabber:client" then
+			if stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then
+				local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns;
+				if xmlns then
+					ret = stream:event("iq/"..xmlns, stanza);
+					if not ret then
+						ret = stream:event("iq", stanza);
+					end
+				end
+			else
+				ret = stream:event(stanza.name, stanza);
+			end
+		end
+		return ret;
+	end, -1);
+
 	return stream:event("stanza", stanza);
 end
 

mercurial