# HG changeset patch # User Matthew Wild # Date 1243818619 -3600 # Node ID 498293bce4bf5ba2db4f40438bd98965c83f7a25 # Parent 7797354dc9b53402f48b7e6464fb45cb82cba8e9 componentmanager: Create events object for configured hosts, and carry it over to a new component if one is registered with no events object diff -r 7797354dc9b5 -r 498293bce4bf core/componentmanager.lua --- a/core/componentmanager.lua Mon Jun 01 02:06:02 2009 +0100 +++ b/core/componentmanager.lua Mon Jun 01 02:10:19 2009 +0100 @@ -51,7 +51,7 @@ 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 @@ 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