aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2008-10-14 10:26:33 +0500
committerWaqas Hussain <waqas20@gmail.com>2008-10-14 10:26:33 +0500
commit5a896f70f20cf967c120054a0ebab0a8e4368c4b (patch)
tree9346be5ce607787947a38fa4fd0ed8b5e27a3721
parent97f1c951bccbc080d45336d3e7fdf50a0b6eca14 (diff)
downloadprosody-5a896f70f20cf967c120054a0ebab0a8e4368c4b.tar.gz
prosody-5a896f70f20cf967c120054a0ebab0a8e4368c4b.zip
Added: presence broadcast
Added: some additional message broadcast checks
-rw-r--r--core/stanza_router.lua30
1 files changed, 23 insertions, 7 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index 7fa18eb0..f133f891 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -67,17 +67,33 @@ function core_route_stanza(origin, stanza)
local user = host_session.sessions[node];
if user then
local res = user.sessions[resource];
- -- TODO do something about presence broadcast
if not res then
-- if we get here, resource was not specified or was unavailable
- for k in pairs(user.sessions) do
- res = user.sessions[k];
- break;
+ if stanza.name == "presence" then
+ for k in pairs(user.sessions) do -- presence broadcast to all user resources
+ if user.sessions[k].full_jid then
+ stanza.attr.to = user.sessions[k].full_jid;
+ send(user.sessions[k], stanza);
+ end
+ end
+ else if stanza.name == "message" then -- select a resource to recieve message
+ for k in pairs(user.sessions) do
+ if user.sessions[k].full_jid then
+ res = user.sessions[k];
+ break;
+ end
+ end
+ -- TODO find resource with greatest priority
+ else
+ error("IQs should't get here");
end
- -- TODO find resource with greatest priority
end
- stanza.attr.to = res.full_jid;
- send(res, stanza); -- Yay \o/
+ if res then
+ stanza.attr.to = res.full_jid;
+ send(res, stanza); -- Yay \o/
+ elseif stanza.name == "message" then
+ -- TODO return message error
+ end
else
-- user not found
send(origin, st.error_reply(stanza, "cancel", "service-unavailable"));