3 local log = require "util.logger".init("componentmanager")
\r
4 local jid_split = require "util.jid".split;
\r
7 local components = {};
\r
9 module "componentmanager"
\r
11 function handle_stanza(origin, stanza)
\r
12 local node, host = jid_split(stanza.attr.to);
\r
13 local component = components[host];
\r
14 if not component then component = components[node.."@"..host]; end -- hack to allow hooking node@server
\r
15 if not component then component = components[stanza.attr.to]; end -- hack to allow hooking node@server/resource and server/resource
\r
17 log("debug", "stanza being handled by component: "..host);
\r
18 component(origin, stanza);
\r
20 log("error", "Component manager recieved a stanza for a non-existing component: " .. stanza.attr.to);
\r
24 function register_component(host, component)
\r
25 if not hosts[host] then
\r
26 -- TODO check for host well-formedness
\r
27 components[host] = component;
\r
28 hosts[host] = {type = "component", connected = true};
\r
29 log("debug", "component added: "..host);
\r
31 log("error", "Attempt to set component for existing host: "..host);
\r