diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-06-01 02:10:19 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-06-01 02:10:19 +0100 |
commit | a76311bca74ca7cda677497ea9639757f8502884 (patch) | |
tree | d4db0051edaf35f928cf32e0566ff2a9d8a31ab6 | |
parent | f6b9a17b954f345038eb6d06d4ac3399f56a3d14 (diff) | |
download | prosody-a76311bca74ca7cda677497ea9639757f8502884.tar.gz prosody-a76311bca74ca7cda677497ea9639757f8502884.zip |
componentmanager: Create events object for configured hosts, and carry it over to a new component if one is registered with no events object
-rw-r--r-- | core/componentmanager.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/componentmanager.lua b/core/componentmanager.lua index 8f624f15..fe4a6999 100644 --- a/core/componentmanager.lua +++ b/core/componentmanager.lua @@ -51,7 +51,7 @@ function load_enabled_components(config) for host, host_config in pairs(defined_hosts) do if host ~= "*" and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then - hosts[host] = { type = "component", host = host, connected = false, s2sout = {} }; + hosts[host] = { type = "component", host = host, connected = false, s2sout = {}, events = events_new() }; components[host] = default_component_handler; local ok, err = modulemanager.load(host, host_config.core.component_module); if not ok then @@ -87,12 +87,14 @@ end function register_component(host, component, session) if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then + local old_events = hosts[host] and hosts[host].events; + components[host] = component; hosts[host] = session or create_component(host, component); -- Add events object if not already one if not hosts[host].events then - hosts[host].events = events_new(); + hosts[host].events = old_events or events_new(); end -- add to disco_items |