Changeset

324:dbb3362c1ff3

plugins.smacks: Don't try to reconnect on gracefull stream closure
author Kim Alvefur <zash@zash.se>
date Sun, 10 Feb 2013 02:54:01 +0100
parents 323:5bf3b13edb80
children 325:843fabce2fc7
files plugins/smacks.lua
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/smacks.lua	Sun Feb 10 02:53:03 2013 +0100
+++ b/plugins/smacks.lua	Sun Feb 10 02:54:01 2013 +0100
@@ -44,6 +44,12 @@
 			return true;
 		end
 	end	
+
+	-- Graceful shutdown
+	local function on_close()
+		stream.resumption_token = nil;
+		stream:unhook("disconnected", on_disconnect);
+	end
 	
 	local function handle_sm_command(stanza)
 		if stanza.name == "r" then -- Request for acks for stanzas we received
@@ -67,9 +73,10 @@
 			-- Catch stanzas
 			stream:hook("stanza", incoming_stanza);
 			stream:hook("outgoing", outgoing_stanza);
-			
+
 			if stanza.attr.id then
 				stream.resumption_token = stanza.attr.id;
+				stream:hook("closed", on_close, 100);
 				stream:hook("disconnected", on_disconnect, 100);
 			end
 		elseif stanza.name == "resumed" then