Software /
code /
prosody
Changeset
11974:a7c183bb4e64
mod_c2s: Add event just before closing as session
To allow modules to do things just before the session is closed. The
'(pre-)resource-unbind' events are fired after the stream is closed,
leaving no way to send something.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 01 Dec 2021 15:06:48 +0100 |
parents | 11973:d4730ae60226 |
children | 11975:fcea4d9e7502 |
files | plugins/mod_c2s.lua |
diffstat | 1 files changed, 3 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_c2s.lua Tue Nov 30 22:04:00 2021 +0100 +++ b/plugins/mod_c2s.lua Wed Dec 01 15:06:48 2021 +0100 @@ -190,6 +190,9 @@ if session.notopen then session:open_stream(); end + local close_event_payload = { session = session, reason = reason }; + module:context(session.host):fire_event("pre-session-close", close_event_payload); + reason = close_event_payload.reason; if reason then -- nil == no err, initiated by us, false == initiated by client local stream_error = st.stanza("stream:error"); if type(reason) == "string" then -- assume stream error