Software /
code /
prosody
Diff
core/componentmanager.lua @ 1853:5da0e3b1f847
Merge with 0.5
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 30 Sep 2009 11:06:02 +0100 |
parent | 1775:5c035b7a6de1 |
parent | 1851:0a4d4ba01db8 |
child | 1939:2c295826a96d |
line wrap: on
line diff
--- a/core/componentmanager.lua Tue Sep 29 19:56:23 2009 +0100 +++ b/core/componentmanager.lua Wed Sep 30 11:06:02 2009 +0100 @@ -11,6 +11,7 @@ local configmanager = require "core.configmanager"; local modulemanager = require "core.modulemanager"; local jid_split = require "util.jid".split; +local fire_event = require "core.eventmanager".fire_event; local events_new = require "util.events".new; local st = require "util.stanza"; local hosts = hosts; @@ -36,12 +37,14 @@ 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 = {}, events = events_new() }; + hosts[host] = create_component(host); + hosts[host].connected = false; components[host] = default_component_handler; local ok, err = modulemanager.load(host, host_config.core.component_module); if not ok then log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err)); else + fire_event("component-activated", host, host_config); log("debug", "Activated %s component: %s", host_config.core.component_module, host); end end @@ -65,9 +68,9 @@ end end -function create_component(host, component) +function create_component(host, component, events) -- TODO check for host well-formedness - return { type = "component", host = host, connected = true, s2sout = {}, events = events_new() }; + return { type = "component", host = host, connected = true, s2sout = {}, events = events or events_new() }; end function register_component(host, component, session) @@ -75,7 +78,7 @@ local old_events = hosts[host] and hosts[host].events; components[host] = component; - hosts[host] = session or create_component(host, component); + hosts[host] = session or create_component(host, component, old_events); -- Add events object if not already one if not hosts[host].events then