Software /
code /
prosody
Diff
core/sessionmanager.lua @ 1224:35fa588e43a6
sessionmanager: Add/remove sessions from full_sessions and bare_sessions when binding/unbinding sessions
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 29 May 2009 23:14:57 +0500 |
parent | 1223:9767e52f861c |
child | 1225:1e01a913baf5 |
line wrap: on
line diff
--- a/core/sessionmanager.lua Fri May 29 23:01:05 2009 +0500 +++ b/core/sessionmanager.lua Fri May 29 23:14:57 2009 +0500 @@ -70,11 +70,13 @@ if hosts[session.host] and hosts[session.host].sessions[session.username] then if session.resource then hosts[session.host].sessions[session.username].sessions[session.resource] = nil; + full_sessions[session.full_jid] = nil; end if not next(hosts[session.host].sessions[session.username].sessions) then log("debug", "All resources of %s are now offline", session.username); hosts[session.host].sessions[session.username] = nil; + bare_sessions[session.host..'@'..session.username] = nil; end else log("error", "host or session table didn't exist, please report this! Host: %s [%s] Sessions: %s [%s]", @@ -110,7 +112,9 @@ --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing if not hosts[session.host].sessions[session.username] then - hosts[session.host].sessions[session.username] = { sessions = {} }; + local sessions = { sessions = {} }; + hosts[session.host].sessions[session.username] = sessions; + bare_sessions[session.host..'@'..session.username] = sessions; else local sessions = hosts[session.host].sessions[session.username].sessions; local limit = config_get(session.host, "core", "max_resources") or 10; @@ -150,6 +154,7 @@ session.resource = resource; session.full_jid = session.username .. '@' .. session.host .. '/' .. resource; hosts[session.host].sessions[session.username].sessions[resource] = session; + full_sessions[session.full_jid] = session; session.roster = rm_load_roster(session.username, session.host);