scansion/objects/client.lua

changeset 66
909c00296c2a
parent 60
e032cdb517ab
child 73
1c07ef6c6502
equal deleted inserted replaced
65:629162fc0681 66:909c00296c2a
1 local async = require "scansion.async"; 1 local async = require "scansion.async";
2 local new_error = require "scansion.error".new_error;
2 local verse = require "verse".init("client"); 3 local verse = require "verse".init("client");
3 4
4 local parse_xml = require "scansion.xml".parse; 5 local parse_xml = require "scansion.xml".parse;
5 6
6 local stanza_timeout = 5; 7 local stanza_timeout = 5;
81 local function stanza_handler(received_stanza) 82 local function stanza_handler(received_stanza)
82 if not stanzacmp.stanzas_match(expected_stanza, received_stanza) then 83 if not stanzacmp.stanzas_match(expected_stanza, received_stanza) then
83 client.log("NOT IT!") 84 client.log("NOT IT!")
84 client.log("Expected: %s", expected_stanza); 85 client.log("Expected: %s", expected_stanza);
85 client.log("Received: %s", received_stanza); 86 client.log("Received: %s", received_stanza);
86 error("Received unexpected stanza"); 87 error(new_error("Received unexpected stanza", { stanza = tostring(received_stanza) }));
87 else 88 else
88 client.log("YES! %s", expected_stanza) 89 client.log("YES! %s", expected_stanza)
89 end 90 end
90 expected_stanza = nil; 91 expected_stanza = nil;
91 client.stream:unhook("stanza", stanza_handler); 92 client.stream:unhook("stanza", stanza_handler);

mercurial