Fri, 01 Jan 2016 20:45:22 +0000
client: Wait for 'drained' event when sending stanzas (experimental, may help with syncing to server's logs)
scansion/objects/client.lua | file | annotate | diff | comparison | revisions |
--- a/scansion/objects/client.lua Fri Jan 01 20:44:44 2016 +0000 +++ b/scansion/objects/client.lua Fri Jan 01 20:45:22 2016 +0000 @@ -73,7 +73,14 @@ sends = function (client, data) local stanza = fill_vars(client.script, assert(parse_xml((table.concat(data):gsub("\t", " "))))); + local wait, done = async.waiter(); + local function handle_drained() + client.stream:unhook("drained", handle_drained); + done(); + end + client.stream:hook("drained", handle_drained); client.stream:send(stanza); + wait(); end; receives = function (client, data)