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); |