# HG changeset patch # User Waqas Hussain # Date 1243620897 -18000 # Node ID 35fa588e43a6b84ede5030f8e45eded83300b341 # Parent 9767e52f861cff0a038e7de6fdfcbba603f7f1e3 sessionmanager: Add/remove sessions from full_sessions and bare_sessions when binding/unbinding sessions diff -r 9767e52f861c -r 35fa588e43a6 core/sessionmanager.lua --- 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);