Comparison

core/sessionmanager.lua @ 2591:d540a75a11db

sessionmanager: Fire resource-unbind event after removing session from sessions table
author Matthew Wild <mwild1@gmail.com>
date Thu, 11 Feb 2010 19:34:23 +0000
parent 2580:61f0acd9086f
child 2606:c3fe88d4b921
comparison
equal deleted inserted replaced
2590:2d7e2a28d1d5 2591:d540a75a11db
69 function destroy_session(session, err) 69 function destroy_session(session, err)
70 (session.log or log)("info", "Destroying session for %s (%s@%s)", session.full_jid or "(unknown)", session.username or "(unknown)", session.host or "(unknown)"); 70 (session.log or log)("info", "Destroying session for %s (%s@%s)", session.full_jid or "(unknown)", session.username or "(unknown)", session.host or "(unknown)");
71 71
72 -- Remove session/resource from user's session list 72 -- Remove session/resource from user's session list
73 if session.full_jid then 73 if session.full_jid then
74 hosts[session.host].events.fire_event("resource-unbind", {session=session, error=err});
75
76 hosts[session.host].sessions[session.username].sessions[session.resource] = nil; 74 hosts[session.host].sessions[session.username].sessions[session.resource] = nil;
77 full_sessions[session.full_jid] = nil; 75 full_sessions[session.full_jid] = nil;
78 76
79 if not next(hosts[session.host].sessions[session.username].sessions) then 77 if not next(hosts[session.host].sessions[session.username].sessions) then
80 log("debug", "All resources of %s are now offline", session.username); 78 log("debug", "All resources of %s are now offline", session.username);
81 hosts[session.host].sessions[session.username] = nil; 79 hosts[session.host].sessions[session.username] = nil;
82 bare_sessions[session.username..'@'..session.host] = nil; 80 bare_sessions[session.username..'@'..session.host] = nil;
83 end 81 end
82
83 hosts[session.host].events.fire_event("resource-unbind", {session=session, error=err});
84 end 84 end
85 85
86 for k in pairs(session) do 86 for k in pairs(session) do
87 if k ~= "trace" then 87 if k ~= "trace" then
88 session[k] = nil; 88 session[k] = nil;