core/stanza_router.lua

changeset 1228
853d3d76ba94
parent 1212
3be23cf5a659
child 1230
53555f58586f
equal deleted inserted replaced
1226:3b5f9dac2045 1228:853d3d76ba94
122 function core_post_stanza(origin, stanza) 122 function core_post_stanza(origin, stanza)
123 local to = stanza.attr.to; 123 local to = stanza.attr.to;
124 local node, host, resource = jid_split(to); 124 local node, host, resource = jid_split(to);
125 local to_bare = node and (node.."@"..host) or host; -- bare JID 125 local to_bare = node and (node.."@"..host) or host; -- bare JID
126 126
127 local to_type;
128 if node then
129 if resource then
130 to_type = '/full';
131 else
132 to_type = '/bare';
133 end
134 else
135 if host then
136 to_type = '/host';
137 else
138 to_type = '/bare';
139 end
140 end
141
127 local event_data = {origin=origin, stanza=stanza}; 142 local event_data = {origin=origin, stanza=stanza};
143 if origin.full_jid then -- c2s connection
144 if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data); then return; end -- do preprocessing
145 end
146 local h = hosts[to_bare] or hosts[host or origin.host];
147 if h then
148 if h.type == "component" then
149 component_handle_stanza(origin, stanza);
150 return;
151 else
152 if h.events.fire_event(stanza.name..to_type, event_data); then return; end -- do processing
153 end
154 else -- non-local recipient
155 core_route_stanza(origin, stanza);
156 return;
157 end
158
128 if host and fire_event(host.."/"..stanza.name, event_data) then 159 if host and fire_event(host.."/"..stanza.name, event_data) then
129 -- event handled 160 -- event handled
130 elseif stanza.name == "presence" and origin.host and fire_event(origin.host.."/"..stanza.name, event_data) then 161 elseif stanza.name == "presence" and origin.host and fire_event(origin.host.."/"..stanza.name, event_data) then
131 -- event handled 162 -- event handled
132 elseif not to then 163 elseif not to then

mercurial