Changeset

339:c6446bbfe40c

Fix sending of unavailable presence on disconnect
author Matthew Wild <mwild1@gmail.com>
date Wed, 19 Nov 2008 05:07:52 +0000
parents 338:804f5e62a41f
children 340:a31715bf08eb
files core/sessionmanager.lua
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
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