# HG changeset patch # User Kim Alvefur # Date 1629110714 -7200 # Node ID 9c450185bac1fb92b2b7033ab1c409c07dd37b01 # Parent dcf38ac6a38c88d314c851f477ccca156d94df35 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. diff -r dcf38ac6a38c -r 9c450185bac1 plugins/mod_c2s.lua --- 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 diff -r dcf38ac6a38c -r 9c450185bac1 plugins/mod_s2s.lua --- 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);