Software /
code /
prosody
Annotate
core/componentmanager.lua @ 350:08f89c25e76e
Send version=1.0 again in s2s stream header
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 19 Nov 2008 22:05:44 +0000 |
parent | 270:837c7f701a56 |
child | 519:cccd610a0ef9 |
rev | line source |
---|---|
212 | 1 |
2 | |
3 local log = require "util.logger".init("componentmanager") | |
4 local jid_split = require "util.jid".split; | |
5 local hosts = hosts; | |
6 | |
7 local components = {}; | |
8 | |
9 module "componentmanager" | |
10 | |
11 function handle_stanza(origin, stanza) | |
12 local node, host = jid_split(stanza.attr.to); | |
13 local component = components[host]; | |
14 if not component then component = components[node.."@"..host]; end -- hack to allow hooking node@server | |
15 if not component then component = components[stanza.attr.to]; end -- hack to allow hooking node@server/resource and server/resource | |
16 if component then | |
17 log("debug", "stanza being handled by component: "..host); | |
217
d522f3a25dda
Re-applying my changes to componentmanager. Sigh.
Matthew Wild <mwild1@gmail.com>
parents:
212
diff
changeset
|
18 component(origin, stanza, hosts[host]); |
212 | 19 else |
20 log("error", "Component manager recieved a stanza for a non-existing component: " .. stanza.attr.to); | |
21 end | |
22 end | |
23 | |
24 function register_component(host, component) | |
25 if not hosts[host] then | |
26 -- TODO check for host well-formedness | |
27 components[host] = component; | |
261
790cf21e2af7
Fix outgoing s2s from components. Fixes #16
Matthew Wild <mwild1@gmail.com>
parents:
217
diff
changeset
|
28 hosts[host] = {type = "component", host = host, connected = true, s2sout = {} }; |
212 | 29 log("debug", "component added: "..host); |
270
837c7f701a56
Return registered host table when registering a component
Matthew Wild <mwild1@gmail.com>
parents:
261
diff
changeset
|
30 return hosts[host]; |
212 | 31 else |
32 log("error", "Attempt to set component for existing host: "..host); | |
33 end | |
34 end | |
35 | |
217
d522f3a25dda
Re-applying my changes to componentmanager. Sigh.
Matthew Wild <mwild1@gmail.com>
parents:
212
diff
changeset
|
36 return _M; |