From ff0fe0544adcca56ea47acdfda9c76dfe990ee61 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 23 Oct 2008 16:07:40 +0100 Subject: Fix for not destroying sessions when connection closed. --- net/xmppclient_listener.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'net') diff --git a/net/xmppclient_listener.lua b/net/xmppclient_listener.lua index 7d5b3abe..e722e55b 100644 --- a/net/xmppclient_listener.lua +++ b/net/xmppclient_listener.lua @@ -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); -- cgit v1.2.3