mirror of
https://github.com/bjc/prosody.git
synced 2025-04-04 13:47:41 +03:00
Added: presence broadcast
Added: some additional message broadcast checks
This commit is contained in:
parent
97f1c951bc
commit
5a896f70f2
1 changed files with 23 additions and 7 deletions
|
@ -67,17 +67,33 @@ function core_route_stanza(origin, stanza)
|
||||||
local user = host_session.sessions[node];
|
local user = host_session.sessions[node];
|
||||||
if user then
|
if user then
|
||||||
local res = user.sessions[resource];
|
local res = user.sessions[resource];
|
||||||
-- TODO do something about presence broadcast
|
|
||||||
if not res then
|
if not res then
|
||||||
-- if we get here, resource was not specified or was unavailable
|
-- if we get here, resource was not specified or was unavailable
|
||||||
for k in pairs(user.sessions) do
|
if stanza.name == "presence" then
|
||||||
res = user.sessions[k];
|
for k in pairs(user.sessions) do -- presence broadcast to all user resources
|
||||||
break;
|
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
|
end
|
||||||
-- TODO find resource with greatest priority
|
|
||||||
end
|
end
|
||||||
stanza.attr.to = res.full_jid;
|
if res then
|
||||||
send(res, stanza); -- Yay \o/
|
stanza.attr.to = res.full_jid;
|
||||||
|
send(res, stanza); -- Yay \o/
|
||||||
|
elseif stanza.name == "message" then
|
||||||
|
-- TODO return message error
|
||||||
|
end
|
||||||
else
|
else
|
||||||
-- user not found
|
-- user not found
|
||||||
send(origin, st.error_reply(stanza, "cancel", "service-unavailable"));
|
send(origin, st.error_reply(stanza, "cancel", "service-unavailable"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue