Software /
code /
prosody
Annotate
core/componentmanager.lua @ 1088:7cf44a5c0991
Merge with 0.4
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 02 May 2009 17:03:48 +0100 |
parent | 1066:0cb325970a50 |
child | 1100:05d209ef9661 |
rev | line source |
---|---|
896 | 1 -- Prosody IM v0.4 |
760
90ce865eebd8
Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents:
759
diff
changeset
|
2 -- Copyright (C) 2008-2009 Matthew Wild |
90ce865eebd8
Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents:
759
diff
changeset
|
3 -- Copyright (C) 2008-2009 Waqas Hussain |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
4 -- |
758 | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
7 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
8 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
9 |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
10 |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
11 |
610
d98106902f74
Enable dialback for components
Waqas Hussain <waqas20@gmail.com>
parents:
519
diff
changeset
|
12 local log = require "util.logger".init("componentmanager"); |
751
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
13 local configmanager = require "core.configmanager"; |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
14 local eventmanager = require "core.eventmanager"; |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
15 local modulemanager = require "core.modulemanager"; |
985
2ecd38c73b50
componentmanager: Use core_route_stanza to reply in the default component
Matthew Wild <mwild1@gmail.com>
parents:
984
diff
changeset
|
16 local core_route_stanza = core_route_stanza; |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
17 local jid_split = require "util.jid".split; |
982
dbbeb73952e6
componentmanager: Improve default component stanza handler
Matthew Wild <mwild1@gmail.com>
parents:
970
diff
changeset
|
18 local st = require "util.stanza"; |
751
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
19 local hosts = hosts; |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
20 |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
21 local pairs, type, tostring = pairs, type, tostring; |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
22 |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
23 local components = {}; |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
24 |
939
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
25 local disco_items = require "util.multitable".new(); |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
26 local NULL = {}; |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
27 require "core.discomanager".addDiscoItemsHandler("*host", function(reply, to, from, node) |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
28 if #node == 0 and hosts[to] then |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
29 for jid in pairs(disco_items:get(to) or NULL) do |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
30 reply:tag("item", {jid = jid}):up(); |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
31 end |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
32 return true; |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
33 end |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
34 end); |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
35 |
986
ebd94ad97b75
componentmanager: Set core_route_stanza after stanza_router is loaded
Matthew Wild <mwild1@gmail.com>
parents:
985
diff
changeset
|
36 require "core.eventmanager".add_event_hook("server-starting", function () core_route_stanza = _G.core_route_stanza; end); |
939
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
37 |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
38 module "componentmanager" |
751
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
39 |
961
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
40 local function default_component_handler(origin, stanza) |
982
dbbeb73952e6
componentmanager: Improve default component stanza handler
Matthew Wild <mwild1@gmail.com>
parents:
970
diff
changeset
|
41 log("warn", "Stanza being handled by default component, bouncing error"); |
dbbeb73952e6
componentmanager: Improve default component stanza handler
Matthew Wild <mwild1@gmail.com>
parents:
970
diff
changeset
|
42 if stanza.attr.type ~= "error" then |
985
2ecd38c73b50
componentmanager: Use core_route_stanza to reply in the default component
Matthew Wild <mwild1@gmail.com>
parents:
984
diff
changeset
|
43 core_route_stanza(nil, st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable")); |
982
dbbeb73952e6
componentmanager: Improve default component stanza handler
Matthew Wild <mwild1@gmail.com>
parents:
970
diff
changeset
|
44 end |
961
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
45 end |
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
46 |
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
47 |
751
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
48 function load_enabled_components(config) |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
49 local defined_hosts = config or configmanager.getconfig(); |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
50 |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
51 for host, host_config in pairs(defined_hosts) do |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
52 if host ~= "*" and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then |
777
f7a87acea220
Component-host module loading code was breaking module reload, andduplicated older code. Changed to reuse older code.
Waqas Hussain <waqas20@gmail.com>
parents:
760
diff
changeset
|
53 hosts[host] = { type = "component", host = host, connected = false, s2sout = {} }; |
961
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
54 components[host] = default_component_handler; |
751
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
55 local ok, err = modulemanager.load(host, host_config.core.component_module); |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
56 if not ok then |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
57 log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err)); |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
58 else |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
59 log("info", "Activated %s component: %s", host_config.core.component_module, host); |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
60 end |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
61 end |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
62 end |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
63 end |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
64 |
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
65 eventmanager.add_event_hook("server-starting", load_enabled_components); |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
66 |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
67 function handle_stanza(origin, stanza) |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
68 local node, host = jid_split(stanza.attr.to); |
638
1915c64c9436
Changed order of checking for component hosts to check the full and bare JIDs before the hostname
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
69 local component = nil; |
1915c64c9436
Changed order of checking for component hosts to check the full and bare JIDs before the hostname
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
70 if not component then component = components[stanza.attr.to]; end -- hack to allow hooking node@server/resource and server/resource |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
71 if not component then component = components[node.."@"..host]; end -- hack to allow hooking node@server |
638
1915c64c9436
Changed order of checking for component hosts to check the full and bare JIDs before the hostname
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
72 if not component then component = components[host]; end |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
73 if component then |
983
460429a59c83
componentmanager: Small logging fix
Matthew Wild <mwild1@gmail.com>
parents:
982
diff
changeset
|
74 log("debug", "%s stanza being handled by component: %s", stanza.name, host); |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
75 component(origin, stanza, hosts[host]); |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
76 else |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
77 log("error", "Component manager recieved a stanza for a non-existing component: " .. stanza.attr.to); |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
78 end |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
79 end |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
80 |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
81 function create_component(host, component) |
970
5516f9e66482
sessionmanager, componentmanager: Fix some wacky indentation (thanks greyback!)
Matthew Wild <mwild1@gmail.com>
parents:
961
diff
changeset
|
82 -- TODO check for host well-formedness |
1041
07835534d996
core.componentmanager: Fix global access
Matthew Wild <mwild1@gmail.com>
parents:
1004
diff
changeset
|
83 return { type = "component", host = host, connected = true, s2sout = {} }; |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
84 end |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
85 |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
86 function register_component(host, component, session) |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
87 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
88 components[host] = component; |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
89 hosts[host] = session or create_component(host, component); |
939
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
90 -- add to disco_items |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
91 if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
92 disco_items:set(host:sub(host:find(".", 1, true)+1), host, true); |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
93 end |
610
d98106902f74
Enable dialback for components
Waqas Hussain <waqas20@gmail.com>
parents:
519
diff
changeset
|
94 -- FIXME only load for a.b.c if b.c has dialback, and/or check in config |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
95 modulemanager.load(host, "dialback"); |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
96 log("debug", "component added: "..host); |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
97 return session or hosts[host]; |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
98 else |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
99 log("error", "Attempt to set component for existing host: "..host); |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
100 end |
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
101 end |
673
c9bc58e84e96
componentmanager: Added support for component deregistering
Waqas Hussain <waqas20@gmail.com>
parents:
638
diff
changeset
|
102 |
703
f9909efed20c
componentmanager: Removed unneeded parameter from componentmanager.deregister_component
Waqas Hussain <waqas20@gmail.com>
parents:
673
diff
changeset
|
103 function deregister_component(host) |
673
c9bc58e84e96
componentmanager: Added support for component deregistering
Waqas Hussain <waqas20@gmail.com>
parents:
638
diff
changeset
|
104 if components[host] then |
751
7c22619fdb19
componentmanager: Add support for loading components defined in the config
Matthew Wild <mwild1@gmail.com>
parents:
703
diff
changeset
|
105 modulemanager.unload(host, "dialback"); |
1064
3e945c3938ad
core.componentmanager: Really fix marking components as disconnected when unregistered
Matthew Wild <mwild1@gmail.com>
parents:
1004
diff
changeset
|
106 hosts[host].connected = nil; |
984
9acc1c2ceb2c
componentmanager: Restore default component when unregistering
Matthew Wild <mwild1@gmail.com>
parents:
983
diff
changeset
|
107 local host_config = configmanager.getconfig()[host]; |
9acc1c2ceb2c
componentmanager: Restore default component when unregistering
Matthew Wild <mwild1@gmail.com>
parents:
983
diff
changeset
|
108 if host_config and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then |
961
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
109 -- Set default handler |
984
9acc1c2ceb2c
componentmanager: Restore default component when unregistering
Matthew Wild <mwild1@gmail.com>
parents:
983
diff
changeset
|
110 components[host] = default_component_handler; |
961
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
111 else |
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
112 -- Component not in config, or disabled, remove |
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
113 hosts[host] = nil; |
984
9acc1c2ceb2c
componentmanager: Restore default component when unregistering
Matthew Wild <mwild1@gmail.com>
parents:
983
diff
changeset
|
114 components[host] = nil; |
961
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
115 end |
939
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
116 -- remove from disco_items |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
117 if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
118 disco_items:remove(host:sub(host:find(".", 1, true)+1), host); |
b832f786af62
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Waqas Hussain <waqas20@gmail.com>
parents:
896
diff
changeset
|
119 end |
673
c9bc58e84e96
componentmanager: Added support for component deregistering
Waqas Hussain <waqas20@gmail.com>
parents:
638
diff
changeset
|
120 log("debug", "component removed: "..host); |
c9bc58e84e96
componentmanager: Added support for component deregistering
Waqas Hussain <waqas20@gmail.com>
parents:
638
diff
changeset
|
121 return true; |
c9bc58e84e96
componentmanager: Added support for component deregistering
Waqas Hussain <waqas20@gmail.com>
parents:
638
diff
changeset
|
122 else |
c9bc58e84e96
componentmanager: Added support for component deregistering
Waqas Hussain <waqas20@gmail.com>
parents:
638
diff
changeset
|
123 log("error", "Attempt to remove component for non-existing host: "..host); |
c9bc58e84e96
componentmanager: Added support for component deregistering
Waqas Hussain <waqas20@gmail.com>
parents:
638
diff
changeset
|
124 end |
c9bc58e84e96
componentmanager: Added support for component deregistering
Waqas Hussain <waqas20@gmail.com>
parents:
638
diff
changeset
|
125 end |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
126 |
961
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
127 function set_component_handler(host, handler) |
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
128 components[host] = handler; |
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
129 end |
b48ed2149d0a
componentmanager: Reply with service-unavailable for unconnected components
Matthew Wild <mwild1@gmail.com>
parents:
945
diff
changeset
|
130 |
847
2d424936723c
core.componentmanager: Refactor a little to make XEP-0114 plugin a little simpler
Matthew Wild <mwild1@gmail.com>
parents:
777
diff
changeset
|
131 return _M; |