equal
deleted
inserted
replaced
6 local os_time = os.time; |
6 local os_time = os.time; |
7 local tonumber, tostring = tonumber, tostring; |
7 local tonumber, tostring = tonumber, tostring; |
8 local add_filter = require "util.filters".add_filter; |
8 local add_filter = require "util.filters".add_filter; |
9 local timer = require "util.timer"; |
9 local timer = require "util.timer"; |
10 local datetime = require "util.datetime"; |
10 local datetime = require "util.datetime"; |
|
11 local connlisteners = require "net.connlisteners"; |
11 |
12 |
12 local xmlns_sm = "urn:xmpp:sm:2"; |
13 local xmlns_sm = "urn:xmpp:sm:2"; |
13 local xmlns_errors = "urn:ietf:params:xml:ns:xmpp-stanzas"; |
14 local xmlns_errors = "urn:ietf:params:xml:ns:xmpp-stanzas"; |
14 local xmlns_delay = "urn:xmpp:delay"; |
15 local xmlns_delay = "urn:xmpp:delay"; |
15 |
16 |
253 session.log("debug", "mod_smacks resuming existing session..."); |
254 session.log("debug", "mod_smacks resuming existing session..."); |
254 -- TODO: All this should move to sessionmanager (e.g. session:replace(new_session)) |
255 -- TODO: All this should move to sessionmanager (e.g. session:replace(new_session)) |
255 if original_session.conn then |
256 if original_session.conn then |
256 session.log("debug", "mod_smacks closing an old connection for this session"); |
257 session.log("debug", "mod_smacks closing an old connection for this session"); |
257 local conn = original_session.conn; |
258 local conn = original_session.conn; |
258 require "net.connlisteners".get("xmppclient").associate_session(conn, nil); |
259 connlisteners.get("xmppclient").associate_session(conn, nil); |
259 conn:close(); |
260 conn:close(); |
260 end |
261 end |
261 original_session.ip = session.ip; |
262 original_session.ip = session.ip; |
262 original_session.conn = session.conn; |
263 original_session.conn = session.conn; |
263 original_session.send = session.send; |
264 original_session.send = session.send; |
278 end |
279 end |
279 wrap_session(original_session, true); |
280 wrap_session(original_session, true); |
280 -- Inform xmppstream of the new session (passed to its callbacks) |
281 -- Inform xmppstream of the new session (passed to its callbacks) |
281 stream:set_session(original_session); |
282 stream:set_session(original_session); |
282 -- Similar for connlisteners |
283 -- Similar for connlisteners |
283 require "net.connlisteners".get("xmppclient").associate_session(session.conn, original_session); |
284 connlisteners.get("xmppclient").associate_session(session.conn, original_session); |
284 |
285 |
285 session.send(st.stanza("resumed", { xmlns = xmlns_sm, |
286 session.send(st.stanza("resumed", { xmlns = xmlns_sm, |
286 h = original_session.handled_stanza_count, previd = id })); |
287 h = original_session.handled_stanza_count, previd = id })); |
287 |
288 |
288 -- Fake an <a> with the h of the <resume/> from the client |
289 -- Fake an <a> with the h of the <resume/> from the client |