scansion/objects/client.lua

changeset 25
9f8166238993
parent 24
3c572d238d9e
child 26
c32334d33438
equal deleted inserted replaced
24:3c572d238d9e 25:9f8166238993
54 54
55 receives = function (client, data) 55 receives = function (client, data)
56 local expected_stanza = fill_vars(client.script, assert(parse_xml((table.concat(data):gsub("\t", " "))))); 56 local expected_stanza = fill_vars(client.script, assert(parse_xml((table.concat(data):gsub("\t", " ")))));
57 local function stanza_handler(received_stanza) 57 local function stanza_handler(received_stanza)
58 if not stanzacmp.stanzas_match(expected_stanza, received_stanza) then 58 if not stanzacmp.stanzas_match(expected_stanza, received_stanza) then
59 verse.quit();
60 client.log("NOT IT!") 59 client.log("NOT IT!")
61 client.log("Expected: %s", expected_stanza); 60 client.log("Expected: %s", expected_stanza);
62 client.log("Received: %s", received_stanza); 61 client.log("Received: %s", received_stanza);
62 error("Received unexpected stanza");
63 else 63 else
64 client.log("YES! %s", expected_stanza) 64 client.log("YES! %s", expected_stanza)
65 end 65 end
66 expected_stanza = nil; 66 expected_stanza = nil;
67 end 67 end
68 client.stream:hook("stanza", stanza_handler, 100); 68 client.stream:hook("stanza", stanza_handler, 100);
69 verse.add_task(stanza_timeout, function () 69 verse.add_task(stanza_timeout, function ()
70 if not expected_stanza then return; end 70 if not expected_stanza then return; end
71 client.log("TIMEOUT waiting for %s", expected_stanza) 71 client.log("TIMEOUT waiting for %s", expected_stanza)
72 error("Timed out waiting for stanza");
72 end); 73 end);
73 end; 74 end;
74 75
75 disconnects = function (client) 76 disconnects = function (client)
76 end; 77 end;

mercurial