Diff

core/sessionmanager.lua @ 339:c6446bbfe40c

Fix sending of unavailable presence on disconnect
author Matthew Wild <mwild1@gmail.com>
date Wed, 19 Nov 2008 05:07:52 +0000
parent 333:8d15b073fdbe
child 356:8ff322b550a3
line wrap: on
line diff
--- a/core/sessionmanager.lua	Wed Nov 19 05:02:13 2008 +0000
+++ b/core/sessionmanager.lua	Wed Nov 19 05:07:52 2008 +0000
@@ -14,6 +14,8 @@
 local uuid_generate = require "util.uuid".generate;
 local rm_load_roster = require "core.rostermanager".load_roster;
 
+local st = require "util.stanza";
+
 local newproxy = newproxy;
 local getmetatable = getmetatable;
 
@@ -33,13 +35,13 @@
 	return session;
 end
 
-function destroy_session(session)
+function destroy_session(session, err)
 	(session.log or log)("info", "Destroying session");
 	
 	-- Send unavailable presence
 	if session.presence then
 		local pres = st.presence{ type = "unavailable" };
-		if err == "closed" then err = "connection closed"; end
+		if (not err) or err == "closed" then err = "connection closed"; end
 		pres:tag("status"):text("Disconnected: "..err);
 		session.stanza_dispatch(pres);
 	end