Software / code / prosody
Comparison
core/componentmanager.lua @ 985:2ecd38c73b50
componentmanager: Use core_route_stanza to reply in the default component
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 11 Apr 2009 23:15:04 +0100 |
| parent | 984:9acc1c2ceb2c |
| child | 986:ebd94ad97b75 |
comparison
equal
deleted
inserted
replaced
| 984:9acc1c2ceb2c | 985:2ecd38c73b50 |
|---|---|
| 11 | 11 |
| 12 local log = require "util.logger".init("componentmanager"); | 12 local log = require "util.logger".init("componentmanager"); |
| 13 local configmanager = require "core.configmanager"; | 13 local configmanager = require "core.configmanager"; |
| 14 local eventmanager = require "core.eventmanager"; | 14 local eventmanager = require "core.eventmanager"; |
| 15 local modulemanager = require "core.modulemanager"; | 15 local modulemanager = require "core.modulemanager"; |
| 16 local core_route_stanza = core_route_stanza; | |
| 16 local jid_split = require "util.jid".split; | 17 local jid_split = require "util.jid".split; |
| 17 local st = require "util.stanza"; | 18 local st = require "util.stanza"; |
| 18 local hosts = hosts; | 19 local hosts = hosts; |
| 19 | 20 |
| 20 local pairs, type, tostring = pairs, type, tostring; | 21 local pairs, type, tostring = pairs, type, tostring; |
| 36 module "componentmanager" | 37 module "componentmanager" |
| 37 | 38 |
| 38 local function default_component_handler(origin, stanza) | 39 local function default_component_handler(origin, stanza) |
| 39 log("warn", "Stanza being handled by default component, bouncing error"); | 40 log("warn", "Stanza being handled by default component, bouncing error"); |
| 40 if stanza.attr.type ~= "error" then | 41 if stanza.attr.type ~= "error" then |
| 41 origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable")); | 42 core_route_stanza(nil, st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable")); |
| 42 end | 43 end |
| 43 end | 44 end |
| 44 | 45 |
| 45 | 46 |
| 46 function load_enabled_components(config) | 47 function load_enabled_components(config) |
| 76 end | 77 end |
| 77 end | 78 end |
| 78 | 79 |
| 79 function create_component(host, component) | 80 function create_component(host, component) |
| 80 -- TODO check for host well-formedness | 81 -- TODO check for host well-formedness |
| 81 local session = session or { type = "component", host = host, connected = true, s2sout = {}, send = component }; | 82 local session = session or { type = "component", host = host, connected = true, s2sout = {} }; |
| 82 return session; | 83 return session; |
| 83 end | 84 end |
| 84 | 85 |
| 85 function register_component(host, component, session) | 86 function register_component(host, component, session) |
| 86 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then | 87 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then |