Software /
code /
prosody
Comparison
core/componentmanager.lua @ 847:2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 28 Feb 2009 02:05:37 +0000 |
parent | 777:f7a87acea220 |
child | 896:2c0b9e3c11c3 |
comparison
equal
deleted
inserted
replaced
846:77244ba297ac | 847:2d424936723c |
---|---|
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 |