scansion/objects/client.lua

changeset 26
c32334d33438
parent 25
9f8166238993
child 27
34d405303242
--- a/scansion/objects/client.lua	Sat Sep 19 21:50:11 2015 +0100
+++ b/scansion/objects/client.lua	Sat Sep 19 21:51:08 2015 +0100
@@ -53,6 +53,7 @@
 	end;
 
 	receives = function (client, data)
+		local wait, done = async.waiter();
 		local expected_stanza = fill_vars(client.script, assert(parse_xml((table.concat(data):gsub("\t", "  ")))));
 		local function stanza_handler(received_stanza)
 			if not stanzacmp.stanzas_match(expected_stanza, received_stanza) then
@@ -64,13 +65,16 @@
 				client.log("YES! %s", expected_stanza)
 			end
 			expected_stanza = nil;
+			done();
 		end
 		client.stream:hook("stanza", stanza_handler, 100);
 		verse.add_task(stanza_timeout, function ()
 			if not expected_stanza then return; end
 			client.log("TIMEOUT waiting for %s", expected_stanza)
 			error("Timed out waiting for stanza");
+			done();
 		end);
+		wait();
 	end;
 
 	disconnects = function (client)

mercurial