Changeset

11742:9c450185bac1

mod_c2s,mod_s2s: Fire event just before writes Could allow e.g. a XEP-0198 implementation to efficiently send ack requests at optimal times without using timers or nextTick.
author Kim Alvefur <zash@zash.se>
date Mon, 16 Aug 2021 12:45:14 +0200
parents 11741:dcf38ac6a38c
children 11743:856dada099fa
files plugins/mod_c2s.lua plugins/mod_s2s.lua
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_c2s.lua	Mon Aug 16 12:34:52 2021 +0200
+++ b/plugins/mod_c2s.lua	Mon Aug 16 12:45:14 2021 +0200
@@ -393,6 +393,13 @@
 	end
 end
 
+function listener.onpredrain(conn)
+	local session = sessions[conn];
+	if session then
+		return (hosts[session.host] or prosody).events.fire_event("c2s-pre-ondrain", { session = session });
+	end
+end
+
 local function keepalive(event)
 	local session = event.session;
 	if not session.notopen then
--- a/plugins/mod_s2s.lua	Mon Aug 16 12:34:52 2021 +0200
+++ b/plugins/mod_s2s.lua	Mon Aug 16 12:45:14 2021 +0200
@@ -860,6 +860,13 @@
 	end
 end
 
+function listener.onpredrain(conn)
+	local session = sessions[conn];
+	if session then
+		return (hosts[session.host] or prosody).events.fire_event("s2s-pre-ondrain", { session = session });
+	end
+end
+
 function listener.register_outgoing(conn, session)
 	sessions[conn] = session;
 	initialize_session(session);