scansion/objects/client.lua

changeset 73
1c07ef6c6502
parent 66
909c00296c2a
child 82
f90056b8e278
equal deleted inserted replaced
72:4fde8d4a4c76 73:1c07ef6c6502
71 client.host = client.stream.host; 71 client.host = client.stream.host;
72 end; 72 end;
73 73
74 sends = function (client, data) 74 sends = function (client, data)
75 local stanza = fill_vars(client.script, assert(parse_xml((table.concat(data):gsub("\t", " "))))); 75 local stanza = fill_vars(client.script, assert(parse_xml((table.concat(data):gsub("\t", " ")))));
76 local wait, done = async.waiter();
77 local function handle_drained()
78 client.stream:unhook("drained", handle_drained);
79 done();
80 end
81 client.stream:hook("drained", handle_drained);
76 client.stream:send(stanza); 82 client.stream:send(stanza);
83 wait();
77 end; 84 end;
78 85
79 receives = function (client, data) 86 receives = function (client, data)
80 local wait, done = async.waiter(); 87 local wait, done = async.waiter();
81 local expected_stanza = fill_vars(client.script, assert(parse_xml((table.concat(data):gsub("\t", " "))))); 88 local expected_stanza = fill_vars(client.script, assert(parse_xml((table.concat(data):gsub("\t", " ")))));

mercurial