plugins.smacks: Don't try to reconnect on gracefull stream closure

Sun, 10 Feb 2013 02:54:01 +0100

author
Kim Alvefur <zash@zash.se>
date
Sun, 10 Feb 2013 02:54:01 +0100
changeset 324
dbb3362c1ff3
parent 323
5bf3b13edb80
child 325
843fabce2fc7

plugins.smacks: Don't try to reconnect on gracefull stream closure

plugins/smacks.lua file | annotate | diff | comparison | revisions
--- 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

mercurial