scansion/objects/client.lua

changeset 82
f90056b8e278
parent 73
1c07ef6c6502
child 83
52f8fa7f999e
--- a/scansion/objects/client.lua	Thu Feb 18 19:02:28 2016 +0000
+++ b/scansion/objects/client.lua	Fri Feb 19 11:47:33 2016 +0000
@@ -4,7 +4,7 @@
 
 local parse_xml = require "scansion.xml".parse;
 
-local stanza_timeout = 5;
+local default_stanza_timeout = 3;
 
 local stanzacmp = require "scansion.stanzacmp";
 
@@ -101,11 +101,15 @@
 			done();
 		end
 		client.stream:hook("stanza", stanza_handler, 100);
-		verse.add_task(stanza_timeout, function ()
-			if not expected_stanza then return; end -- Stanza already received
-			client.log("TIMEOUT waiting for %s", expected_stanza)
-			error("Timed out waiting for stanza");
-			done();
+		verse.add_task(client.stanza_timeout or default_stanza_timeout, function ()
+			if expected_stanza then
+				client.log("TIMEOUT waiting for %s", expected_stanza)
+				error("Timed out waiting for stanza");
+			end
+			if expected_stanza == false then
+				client.log("Good - no stanzas were received (expected)");
+				done();
+			end
 		end);
 		client.stream.conn:resume();
 		wait();

mercurial