Comparison

core/componentmanager.lua @ 1774:53bd9c9f3103

ComponentManager: Removed dependency on core_route_stanza. The default component handler now replies using origin.send().
author Waqas Hussain <waqas20@gmail.com>
date Fri, 11 Sep 2009 16:28:52 +0500
parent 1773:f47aa1d336b5
child 1775:5c035b7a6de1
comparison
equal deleted inserted replaced
1773:f47aa1d336b5 1774:53bd9c9f3103
8 8
9 local prosody = prosody; 9 local prosody = prosody;
10 local log = require "util.logger".init("componentmanager"); 10 local log = require "util.logger".init("componentmanager");
11 local configmanager = require "core.configmanager"; 11 local configmanager = require "core.configmanager";
12 local modulemanager = require "core.modulemanager"; 12 local modulemanager = require "core.modulemanager";
13 local core_route_stanza = core_route_stanza;
14 local jid_split = require "util.jid".split; 13 local jid_split = require "util.jid".split;
15 local events_new = require "util.events".new; 14 local events_new = require "util.events".new;
16 local st = require "util.stanza"; 15 local st = require "util.stanza";
17 local hosts = hosts; 16 local hosts = hosts;
18 17
21 local components = {}; 20 local components = {};
22 21
23 local disco_items = require "util.multitable".new(); 22 local disco_items = require "util.multitable".new();
24 local NULL = {}; 23 local NULL = {};
25 24
26 prosody.events.add_handler("server-starting", function () core_route_stanza = _G.core_route_stanza; end);
27
28 module "componentmanager" 25 module "componentmanager"
29 26
30 local function default_component_handler(origin, stanza) 27 local function default_component_handler(origin, stanza)
31 log("warn", "Stanza being handled by default component, bouncing error"); 28 log("warn", "Stanza being handled by default component, bouncing error");
32 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then 29 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
33 core_route_stanza(nil, st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable")); 30 origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable"));
34 end 31 end
35 end 32 end
36 33
37 local components_loaded_once; 34 local components_loaded_once;
38 function load_enabled_components(config) 35 function load_enabled_components(config)