Software /
code /
prosody
Annotate
core/componentmanager.lua @ 519:cccd610a0ef9
Insert copyright/license headers
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 03 Dec 2008 14:39:07 +0000 |
parent | 270:837c7f701a56 |
child | 610:d98106902f74 |
rev | line source |
---|---|
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
1 -- Prosody IM v0.1 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
2 -- Copyright (C) 2008 Matthew Wild |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
3 -- Copyright (C) 2008 Waqas Hussain |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
4 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
5 -- This program is free software; you can redistribute it and/or |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
6 -- modify it under the terms of the GNU General Public License |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
7 -- as published by the Free Software Foundation; either version 2 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
8 -- of the License, or (at your option) any later version. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
9 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
10 -- This program is distributed in the hope that it will be useful, |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
13 -- GNU General Public License for more details. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
14 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
15 -- You should have received a copy of the GNU General Public License |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
16 -- along with this program; if not, write to the Free Software |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
18 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
19 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
270
diff
changeset
|
20 |
212 | 21 |
22 | |
23 local log = require "util.logger".init("componentmanager") | |
24 local jid_split = require "util.jid".split; | |
25 local hosts = hosts; | |
26 | |
27 local components = {}; | |
28 | |
29 module "componentmanager" | |
30 | |
31 function handle_stanza(origin, stanza) | |
32 local node, host = jid_split(stanza.attr.to); | |
33 local component = components[host]; | |
34 if not component then component = components[node.."@"..host]; end -- hack to allow hooking node@server | |
35 if not component then component = components[stanza.attr.to]; end -- hack to allow hooking node@server/resource and server/resource | |
36 if component then | |
37 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
|
38 component(origin, stanza, hosts[host]); |
212 | 39 else |
40 log("error", "Component manager recieved a stanza for a non-existing component: " .. stanza.attr.to); | |
41 end | |
42 end | |
43 | |
44 function register_component(host, component) | |
45 if not hosts[host] then | |
46 -- TODO check for host well-formedness | |
47 components[host] = component; | |
261
790cf21e2af7
Fix outgoing s2s from components. Fixes #16
Matthew Wild <mwild1@gmail.com>
parents:
217
diff
changeset
|
48 hosts[host] = {type = "component", host = host, connected = true, s2sout = {} }; |
212 | 49 log("debug", "component added: "..host); |
270
837c7f701a56
Return registered host table when registering a component
Matthew Wild <mwild1@gmail.com>
parents:
261
diff
changeset
|
50 return hosts[host]; |
212 | 51 else |
52 log("error", "Attempt to set component for existing host: "..host); | |
53 end | |
54 end | |
55 | |
217
d522f3a25dda
Re-applying my changes to componentmanager. Sigh.
Matthew Wild <mwild1@gmail.com>
parents:
212
diff
changeset
|
56 return _M; |