Comparison

plugins/mod_iq.lua @ 3658:13600f0d56b5

mod_iq: Optimized a bit more (fewer table accesses).
author Waqas Hussain <waqas20@gmail.com>
date Sun, 28 Nov 2010 02:42:02 +0500
parent 3657:07f0c2ef16cb
child 3673:43b854062206
comparison
equal deleted inserted replaced
3657:07f0c2ef16cb 3658:13600f0d56b5
34 local origin, stanza = data.origin, data.stanza; 34 local origin, stanza = data.origin, data.stanza;
35 local type = stanza.attr.type; 35 local type = stanza.attr.type;
36 36
37 -- TODO fire post processing events 37 -- TODO fire post processing events
38 if type == "get" or type == "set" then 38 if type == "get" or type == "set" then
39 local ret = module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); 39 local child = stanza.tags[1];
40 local ret = module:fire_event("iq/bare/"..child.attr.xmlns..":"..child.name, data);
40 if ret ~= nil then return ret; end 41 if ret ~= nil then return ret; end
41 return module:fire_event("iq-"..type.."/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); 42 return module:fire_event("iq-"..type.."/bare/"..child.attr.xmlns..":"..child.name, data);
42 else 43 else
43 module:fire_event("iq-"..type.."/bare/"..stanza.attr.id, data); 44 module:fire_event("iq-"..type.."/bare/"..stanza.attr.id, data);
44 return true; 45 return true;
45 end 46 end
46 end); 47 end);
49 -- IQ to self JID recieved 50 -- IQ to self JID recieved
50 local origin, stanza = data.origin, data.stanza; 51 local origin, stanza = data.origin, data.stanza;
51 local type = stanza.attr.type; 52 local type = stanza.attr.type;
52 53
53 if type == "get" or type == "set" then 54 if type == "get" or type == "set" then
54 local ret = module:fire_event("iq/self/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); 55 local child = stanza.tags[1];
56 local ret = module:fire_event("iq/self/"..child.attr.xmlns..":"..child.name, data);
55 if ret ~= nil then return ret; end 57 if ret ~= nil then return ret; end
56 return module:fire_event("iq-"..type.."/self/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); 58 return module:fire_event("iq-"..type.."/self/"..child.attr.xmlns..":"..child.name, data);
57 else 59 else
58 module:fire_event("iq-"..type.."/self/"..stanza.attr.id, data); 60 module:fire_event("iq-"..type.."/self/"..stanza.attr.id, data);
59 return true; 61 return true;
60 end 62 end
61 end); 63 end);
64 -- IQ to a local host recieved 66 -- IQ to a local host recieved
65 local origin, stanza = data.origin, data.stanza; 67 local origin, stanza = data.origin, data.stanza;
66 local type = stanza.attr.type; 68 local type = stanza.attr.type;
67 69
68 if type == "get" or type == "set" then 70 if type == "get" or type == "set" then
69 local ret = module:fire_event("iq/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); 71 local child = stanza.tags[1];
72 local ret = module:fire_event("iq/host/"..child.attr.xmlns..":"..child.name, data);
70 if ret ~= nil then return ret; end 73 if ret ~= nil then return ret; end
71 return module:fire_event("iq-"..type.."/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); 74 return module:fire_event("iq-"..type.."/host/"..child.attr.xmlns..":"..child.name, data);
72 else 75 else
73 module:fire_event("iq-"..type.."/host/"..stanza.attr.id, data); 76 module:fire_event("iq-"..type.."/host/"..stanza.attr.id, data);
74 return true; 77 return true;
75 end 78 end
76 end); 79 end);