52 else |
52 else |
53 log("error", "Component manager recieved a stanza for a non-existing component: " .. stanza.attr.to); |
53 log("error", "Component manager recieved a stanza for a non-existing component: " .. stanza.attr.to); |
54 end |
54 end |
55 end |
55 end |
56 |
56 |
57 function register_component(host, component) |
57 function create_component(host, component) |
|
58 -- TODO check for host well-formedness |
|
59 session = session or { type = "component", host = host, connected = true, s2sout = {}, send = component }; |
|
60 return session; |
|
61 end |
|
62 |
|
63 function register_component(host, component, session) |
58 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then |
64 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then |
59 -- TODO check for host well-formedness |
|
60 components[host] = component; |
65 components[host] = component; |
61 hosts[host] = { type = "component", host = host, connected = true, s2sout = {} }; |
66 hosts[host] = session or create_component(host, component); |
|
67 |
62 -- FIXME only load for a.b.c if b.c has dialback, and/or check in config |
68 -- FIXME only load for a.b.c if b.c has dialback, and/or check in config |
63 modulemanager.load(host, "dialback"); |
69 modulemanager.load(host, "dialback"); |
64 log("debug", "component added: "..host); |
70 log("debug", "component added: "..host); |
65 return hosts[host]; |
71 return session or hosts[host]; |
66 else |
72 else |
67 log("error", "Attempt to set component for existing host: "..host); |
73 log("error", "Attempt to set component for existing host: "..host); |
68 end |
74 end |
69 end |
75 end |
70 |
76 |