Software /
code /
prosody
Comparison
core/stanza_router.lua @ 106:f2a3d204a76a
Added: presence broadcast
Added: some additional message broadcast checks
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Tue, 14 Oct 2008 10:26:33 +0500 |
parent | 105:b099f0f80775 |
child | 113:9026fdad1531 |
comparison
equal
deleted
inserted
replaced
105:b099f0f80775 | 106:f2a3d204a76a |
---|---|
65 if host_session and host_session.type == "local" then | 65 if host_session and host_session.type == "local" then |
66 -- Local host | 66 -- Local host |
67 local user = host_session.sessions[node]; | 67 local user = host_session.sessions[node]; |
68 if user then | 68 if user then |
69 local res = user.sessions[resource]; | 69 local res = user.sessions[resource]; |
70 -- TODO do something about presence broadcast | |
71 if not res then | 70 if not res then |
72 -- if we get here, resource was not specified or was unavailable | 71 -- if we get here, resource was not specified or was unavailable |
73 for k in pairs(user.sessions) do | 72 if stanza.name == "presence" then |
74 res = user.sessions[k]; | 73 for k in pairs(user.sessions) do -- presence broadcast to all user resources |
75 break; | 74 if user.sessions[k].full_jid then |
76 end | 75 stanza.attr.to = user.sessions[k].full_jid; |
77 -- TODO find resource with greatest priority | 76 send(user.sessions[k], stanza); |
78 end | 77 end |
79 stanza.attr.to = res.full_jid; | 78 end |
80 send(res, stanza); -- Yay \o/ | 79 else if stanza.name == "message" then -- select a resource to recieve message |
80 for k in pairs(user.sessions) do | |
81 if user.sessions[k].full_jid then | |
82 res = user.sessions[k]; | |
83 break; | |
84 end | |
85 end | |
86 -- TODO find resource with greatest priority | |
87 else | |
88 error("IQs should't get here"); | |
89 end | |
90 end | |
91 if res then | |
92 stanza.attr.to = res.full_jid; | |
93 send(res, stanza); -- Yay \o/ | |
94 elseif stanza.name == "message" then | |
95 -- TODO return message error | |
96 end | |
81 else | 97 else |
82 -- user not found | 98 -- user not found |
83 send(origin, st.error_reply(stanza, "cancel", "service-unavailable")); | 99 send(origin, st.error_reply(stanza, "cancel", "service-unavailable")); |
84 end | 100 end |
85 else | 101 else |