client.lua: Handle unexpected disconnects in the middle of a test

Thu, 17 Dec 2015 14:25:33 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 17 Dec 2015 14:25:33 +0000
changeset 60
e032cdb517ab
parent 59
909305ae72ac
child 61
21871fb2db99

client.lua: Handle unexpected disconnects in the middle of a test

scansion/objects/client.lua file | annotate | diff | comparison | revisions
--- a/scansion/objects/client.lua	Thu Dec 17 14:25:09 2015 +0000
+++ b/scansion/objects/client.lua	Thu Dec 17 14:25:33 2015 +0000
@@ -49,6 +49,11 @@
 		client.stream:hook("outgoing-raw", function (s) client.log("Data out: %s", s); end, 1000);
 		-- And incoming, parsed, stanzas
 		client.stream:hook("stanza", function (s) client.log("Stanza: %s", s) end);
+		-- Handle unexpected disconnects
+		client.stream:hook("disconnected", function (s)
+			client.log("Unexpected disconnect!");
+			error("Unexpected disconnect");
+		end);
 	end;
 
 	connects = function (client)

mercurial