aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_c2s.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-12-01 15:06:48 +0100
committerKim Alvefur <zash@zash.se>2021-12-01 15:06:48 +0100
commitd02e79c6a99ffc318530ded9ace026ee24c10eae (patch)
treeb295474d963ef158d9ece0c33eb189ee92a53ccf /plugins/mod_c2s.lua
parentbdea7033a7b22fa0de69a93293f2d20c9db24788 (diff)
downloadprosody-d02e79c6a99ffc318530ded9ace026ee24c10eae.tar.gz
prosody-d02e79c6a99ffc318530ded9ace026ee24c10eae.zip
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.
Diffstat (limited to 'plugins/mod_c2s.lua')
-rw-r--r--plugins/mod_c2s.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua
index 8a7c8306..204ac16d 100644
--- a/plugins/mod_c2s.lua
+++ b/plugins/mod_c2s.lua
@@ -190,6 +190,9 @@ local function session_close(session, reason)
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