Software / code / verse
Comparison
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 |
comparison
equal
deleted
inserted
replaced
| 27:a4a6a33a34c1 | 28:afe9e6d6c87a |
|---|---|
| 31 if stanza.attr.xmlns == xmlns_stream then | 31 if stanza.attr.xmlns == xmlns_stream then |
| 32 return stream:event("stream-"..stanza.name, stanza); | 32 return stream:event("stream-"..stanza.name, stanza); |
| 33 elseif stanza.attr.xmlns then | 33 elseif stanza.attr.xmlns then |
| 34 return stream:event("stream/"..stanza.attr.xmlns, stanza); | 34 return stream:event("stream/"..stanza.attr.xmlns, stanza); |
| 35 end | 35 end |
| 36 | |
| 37 stream:hook("stanza", function (stanza) | |
| 38 if stanza.attr.xmlns == nil or stanza.attr.xmlns == "jabber:client" then | |
| 39 if stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then | |
| 40 local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns; | |
| 41 if xmlns then | |
| 42 ret = stream:event("iq/"..xmlns, stanza); | |
| 43 if not ret then | |
| 44 ret = stream:event("iq", stanza); | |
| 45 end | |
| 46 end | |
| 47 else | |
| 48 ret = stream:event(stanza.name, stanza); | |
| 49 end | |
| 50 end | |
| 51 return ret; | |
| 52 end, -1); | |
| 53 | |
| 36 return stream:event("stanza", stanza); | 54 return stream:event("stanza", stanza); |
| 37 end | 55 end |
| 38 | 56 |
| 39 local function reset_stream(stream) | 57 local function reset_stream(stream) |
| 40 -- Reset stream | 58 -- Reset stream |