# HG changeset patch # User Matthew Wild # Date 1282686709 -3600 # Node ID c74380af7075c68e58377be7efb06626995bfe74 # Parent 4b08296a67485d2fd370de8bf92f026e7feb3cfd clix.lua: Add workaround for Tigase bug which discards stanzas sent immediately before stream close, use --close-delay=X to delay close for some seconds diff -r 4b08296a6748 -r c74380af7075 clix.lua --- a/clix.lua Tue Aug 24 10:55:49 2010 -0700 +++ b/clix.lua Tue Aug 24 22:51:49 2010 +0100 @@ -94,6 +94,30 @@ -- Connect! conn:connect_client(account.jid, opts.password or account.password); + -- COMPAT: Tigase discards stanzas sent at the same time as + local _real_close = conn.close; + function conn:close() + conn:debug("Delaying close..."); + conn:hook("drained", function () + local function do_close() + if _real_close then + conn:debug("Closing now..."); + local close = _real_close; + _real_close = nil; + close(conn); + end + end + local close_delay = tonumber(opts.close_delay) or 0; + if close_delay > 0 then + verse.add_task(close_delay, do_close); + else + do_close(); + end + end); + end + -- /COMPAT + + if type(opts.resource) == "string" then conn.resource = opts.resource; end