Comparison

core/sessionmanager.lua @ 331:830fd67f9378

Quite some changes, to: - Small logging fix for s2smanager - Send a stream error if an incoming s2s connection is to an unrecognised hostname (fixes #11) - init_xmlhandlers now takes a table of callbacks (includes changes to net/xmpp*_listener for this) - Move sending of unavailable presence to where it should be, sessionmanager.destroy_session - Fix sending of stream errors to wrong connection
author Matthew Wild <mwild1@gmail.com>
date Tue, 18 Nov 2008 17:52:33 +0000
parent 329:3be63719428e
child 332:51e130b5c8de
comparison
equal deleted inserted replaced
330:d9d4c1de16ce 331:830fd67f9378
33 return session; 33 return session;
34 end 34 end
35 35
36 function destroy_session(session) 36 function destroy_session(session)
37 (session.log or log)("info", "Destroying session"); 37 (session.log or log)("info", "Destroying session");
38
39 -- Send unavailable presence
40 if session.presence and session.presence.attr.type ~= "unavailable" then
41 local pres = st.presence{ type = "unavailable" };
42 if err == "closed" then err = "connection closed"; end
43 pres:tag("status"):text("Disconnected: "..err);
44 session.stanza_dispatch(pres);
45 end
46
47 -- Remove session/resource from user's session list
38 if session.host and session.username then 48 if session.host and session.username then
39 if session.resource then 49 if session.resource then
40 hosts[session.host].sessions[session.username].sessions[session.resource] = nil; 50 hosts[session.host].sessions[session.username].sessions[session.resource] = nil;
41 end 51 end
42 if hosts[session.host] and hosts[session.host].sessions[session.username] then 52 if hosts[session.host] and hosts[session.host].sessions[session.username] then
44 log("debug", "All resources of %s are now offline", session.username); 54 log("debug", "All resources of %s are now offline", session.username);
45 hosts[session.host].sessions[session.username] = nil; 55 hosts[session.host].sessions[session.username] = nil;
46 end 56 end
47 end 57 end
48 end 58 end
49 session.conn = nil; 59
50 session.disconnect = nil;
51 for k in pairs(session) do 60 for k in pairs(session) do
52 if k ~= "trace" then 61 if k ~= "trace" then
53 session[k] = nil; 62 session[k] = nil;
54 end 63 end
55 end 64 end