Software /
code /
verse
Diff
client.lua @ 28:afe9e6d6c87a
verse.client: New stanza dispatcher to fire events based on the name (and in the case of iq, xmlns) of the stanza
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 09 Dec 2009 20:55:34 +0000 |
parent | 26:6c5fab6c11cf |
child | 30:9c96318913f7 |
line wrap: on
line diff
--- 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