Mercurial > prosody-hg
comparison core/sessionmanager.lua @ 12821:a4ac16e5b655
sessionmanager: Fire event before retiring old session
This allows for modules to update fields, which is generally better than
maintaining this hard-coded list of transferable properties here.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 29 Dec 2022 16:25:00 +0000 |
| parents | b95771171439 |
| children | b56a2731bf00 |
comparison
equal
deleted
inserted
replaced
| 12820:b95771171439 | 12821:a4ac16e5b655 |
|---|---|
| 124 from_session.log = to_session.log; | 124 from_session.log = to_session.log; |
| 125 from_session.type = to_session.type; | 125 from_session.type = to_session.type; |
| 126 -- Inform xmppstream of the new session (passed to its callbacks) | 126 -- Inform xmppstream of the new session (passed to its callbacks) |
| 127 to_session.stream:set_session(to_session); | 127 to_session.stream:set_session(to_session); |
| 128 | 128 |
| 129 -- Retire the session we've pulled from, to avoid two sessions on the same connection | 129 -- Notify modules, allowing them to copy further fields or update state |
| 130 retire_session(from_session); | |
| 131 | |
| 132 prosody.events.fire_event("c2s-session-updated", { | 130 prosody.events.fire_event("c2s-session-updated", { |
| 133 session = to_session; | 131 session = to_session; |
| 134 from_session = from_session; | 132 from_session = from_session; |
| 135 replaced_conn = replaced_conn; | 133 replaced_conn = replaced_conn; |
| 136 }); | 134 }); |
| 135 | |
| 136 -- Retire the session we've pulled from, to avoid two sessions on the same connection | |
| 137 retire_session(from_session); | |
| 137 end | 138 end |
| 138 | 139 |
| 139 local function destroy_session(session, err) | 140 local function destroy_session(session, err) |
| 140 (session.log or log)("debug", "Destroying session for %s (%s@%s)%s", | 141 (session.log or log)("debug", "Destroying session for %s (%s@%s)%s", |
| 141 session.full_jid or "(unknown)", session.username or "(unknown)", | 142 session.full_jid or "(unknown)", session.username or "(unknown)", |
