Software / code / prosody
Comparison
core/componentmanager.lua @ 1851:0a4d4ba01db8
componentmanager: Preserve existing events table (if any) when registering a component
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 30 Sep 2009 11:05:01 +0100 |
| parent | 1850:8f1871c1d456 |
| child | 1853:5da0e3b1f847 |
comparison
equal
deleted
inserted
replaced
| 1850:8f1871c1d456 | 1851:0a4d4ba01db8 |
|---|---|
| 81 else | 81 else |
| 82 log("error", "Component manager recieved a stanza for a non-existing component: " .. (stanza.attr.to or serialize(stanza))); | 82 log("error", "Component manager recieved a stanza for a non-existing component: " .. (stanza.attr.to or serialize(stanza))); |
| 83 end | 83 end |
| 84 end | 84 end |
| 85 | 85 |
| 86 function create_component(host, component) | 86 function create_component(host, component, events) |
| 87 -- TODO check for host well-formedness | 87 -- TODO check for host well-formedness |
| 88 return { type = "component", host = host, connected = true, s2sout = {}, events = events_new() }; | 88 return { type = "component", host = host, connected = true, s2sout = {}, events = events or events_new() }; |
| 89 end | 89 end |
| 90 | 90 |
| 91 function register_component(host, component, session) | 91 function register_component(host, component, session) |
| 92 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then | 92 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then |
| 93 local old_events = hosts[host] and hosts[host].events; | 93 local old_events = hosts[host] and hosts[host].events; |
| 94 | 94 |
| 95 components[host] = component; | 95 components[host] = component; |
| 96 hosts[host] = session or create_component(host, component); | 96 hosts[host] = session or create_component(host, component, old_events); |
| 97 | 97 |
| 98 -- Add events object if not already one | 98 -- Add events object if not already one |
| 99 if not hosts[host].events then | 99 if not hosts[host].events then |
| 100 hosts[host].events = old_events or events_new(); | 100 hosts[host].events = old_events or events_new(); |
| 101 end | 101 end |