Fix for not destroying sessions when connection closed.

This commit is contained in:
Matthew Wild 2008-10-23 16:07:40 +01:00
parent b13393bcd9
commit ff0fe0544a
2 changed files with 18 additions and 9 deletions

View file

@ -69,6 +69,19 @@ function xmppclient.listener(conn, data)
end
function xmppclient.disconnect(conn)
local session = sessions[conn];
if session then
if session.last_presence and session.last_presence.attr.type ~= "unavailable" then
local pres = st.presence{ type = "unavailable" };
if err == "closed" then err = "connection closed"; end
pres:tag("status"):text("Disconnected: "..err);
session.stanza_dispatch(pres);
end
sm_destroy_session(session);
sessions[conn] = nil;
session = nil;
collectgarbage("collect");
end
end
connlisteners_register("xmppclient", xmppclient);