Software /
code /
prosody
Comparison
core/sessionmanager.lua @ 2140:94b7ba39787d
sessionmanager: Fixed and cleaned function send_to_available_resources(). The 'to' attribute for presence subscription stanzas is now preserved.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 22 Nov 2009 21:40:01 +0500 |
parent | 1929:b8e6764ffefd |
child | 2141:f544729f9228 |
comparison
equal
deleted
inserted
replaced
2139:625b2d3e8900 | 2140:94b7ba39787d |
---|---|
199 session.send("</stream:stream>"); | 199 session.send("</stream:stream>"); |
200 session.notopen = true; | 200 session.notopen = true; |
201 end | 201 end |
202 | 202 |
203 function send_to_available_resources(user, host, stanza) | 203 function send_to_available_resources(user, host, stanza) |
204 local jid = user.."@"..host; | |
204 local count = 0; | 205 local count = 0; |
205 local to = stanza.attr.to; | 206 local user = bare_sessions[jid]; |
206 stanza.attr.to = nil; | 207 if user then |
207 local h = hosts[host]; | 208 for k, session in pairs(user.sessions) do |
208 if h and h.type == "local" then | 209 if session.presence then |
209 local u = h.sessions[user]; | 210 session.send(stanza); |
210 if u then | 211 count = count + 1; |
211 for k, session in pairs(u.sessions) do | 212 end |
212 if session.presence then | 213 end |
213 session.send(stanza); | 214 end |
214 count = count + 1; | |
215 end | |
216 end | |
217 end | |
218 end | |
219 stanza.attr.to = to; | |
220 return count; | 215 return count; |
221 end | 216 end |
222 | 217 |
223 return _M; | 218 return _M; |