Diff

plugins/mod_presence.lua @ 1480:93d3295fb064

mod_presence: Send unavailable presence to resources from non-available resources on disconnect
author Waqas Hussain <waqas20@gmail.com>
date Sun, 05 Jul 2009 20:40:31 +0500
parent 1479:eef17ebe3ca1
child 1488:0d1aff918303
line wrap: on
line diff
--- a/plugins/mod_presence.lua	Sun Jul 05 17:45:44 2009 +0500
+++ b/plugins/mod_presence.lua	Sun Jul 05 20:40:31 2009 +0500
@@ -324,5 +324,14 @@
 		if not(err) or err == "closed" then err = "connection closed"; end
 		pres:tag("status"):text("Disconnected: "..err):up();
 		session:dispatch_stanza(pres);
+	elseif session.directed then
+		local pres = st.presence{ type = "unavailable" };
+		if not(err) or err == "closed" then err = "connection closed"; end
+		pres:tag("status"):text("Disconnected: "..err):up();
+		for jid in pairs(session.directed) do
+			pres.attr.to = jid;
+			core_route_stanza(session, pres);
+		end
+		session.directed = nil;
 	end
 end);