Software /
code /
clix
Comparison
clix.lua @ 40:c74380af7075
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
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 24 Aug 2010 22:51:49 +0100 |
parent | 38:eb9f706324c7 |
child | 41:89070edde205 |
comparison
equal
deleted
inserted
replaced
39:4b08296a6748 | 40:c74380af7075 |
---|---|
92 conn.connect_port = account.port; | 92 conn.connect_port = account.port; |
93 | 93 |
94 -- Connect! | 94 -- Connect! |
95 conn:connect_client(account.jid, opts.password or account.password); | 95 conn:connect_client(account.jid, opts.password or account.password); |
96 | 96 |
97 -- COMPAT: Tigase discards stanzas sent at the same time as </stream:stream> | |
98 local _real_close = conn.close; | |
99 function conn:close() | |
100 conn:debug("Delaying close..."); | |
101 conn:hook("drained", function () | |
102 local function do_close() | |
103 if _real_close then | |
104 conn:debug("Closing now..."); | |
105 local close = _real_close; | |
106 _real_close = nil; | |
107 close(conn); | |
108 end | |
109 end | |
110 local close_delay = tonumber(opts.close_delay) or 0; | |
111 if close_delay > 0 then | |
112 verse.add_task(close_delay, do_close); | |
113 else | |
114 do_close(); | |
115 end | |
116 end); | |
117 end | |
118 -- /COMPAT | |
119 | |
120 | |
97 if type(opts.resource) == "string" then | 121 if type(opts.resource) == "string" then |
98 conn.resource = opts.resource; | 122 conn.resource = opts.resource; |
99 end | 123 end |
100 | 124 |
101 local ok, ret = pcall(verse.loop); | 125 local ok, ret = pcall(verse.loop); |