core/componentmanager.lua

changeset 217
d522f3a25dda
parent 212
9d6da9ed9063
child 261
790cf21e2af7
equal deleted inserted replaced
216:35f626e29fb0 217:d522f3a25dda
13 local component = components[host]; 13 local component = components[host];
14 if not component then component = components[node.."@"..host]; end -- hack to allow hooking node@server 14 if not component then component = components[node.."@"..host]; end -- hack to allow hooking node@server
15 if not component then component = components[stanza.attr.to]; end -- hack to allow hooking node@server/resource and server/resource 15 if not component then component = components[stanza.attr.to]; end -- hack to allow hooking node@server/resource and server/resource
16 if component then 16 if component then
17 log("debug", "stanza being handled by component: "..host); 17 log("debug", "stanza being handled by component: "..host);
18 component(origin, stanza); 18 component(origin, stanza, hosts[host]);
19 else 19 else
20 log("error", "Component manager recieved a stanza for a non-existing component: " .. stanza.attr.to); 20 log("error", "Component manager recieved a stanza for a non-existing component: " .. stanza.attr.to);
21 end 21 end
22 end 22 end
23 23
24 function register_component(host, component) 24 function register_component(host, component)
25 if not hosts[host] then 25 if not hosts[host] then
26 -- TODO check for host well-formedness 26 -- TODO check for host well-formedness
27 components[host] = component; 27 components[host] = component;
28 hosts[host] = {type = "component", connected = true}; 28 hosts[host] = {type = "component", host = host, connected = true};
29 log("debug", "component added: "..host); 29 log("debug", "component added: "..host);
30 else 30 else
31 log("error", "Attempt to set component for existing host: "..host); 31 log("error", "Attempt to set component for existing host: "..host);
32 end 32 end
33 end 33 end

mercurial