From 48216c1dc849292323b016660e851f58aae2e325 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 16 Aug 2021 12:45:14 +0200 Subject: 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. --- plugins/mod_c2s.lua | 7 +++++++ plugins/mod_s2s.lua | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index 722932f6..8bd28782 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -393,6 +393,13 @@ function listener.ondrain(conn) 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 --git a/plugins/mod_s2s.lua b/plugins/mod_s2s.lua index 75eb15ca..d800138f 100644 --- a/plugins/mod_s2s.lua +++ b/plugins/mod_s2s.lua @@ -860,6 +860,13 @@ function listener.ondrain(conn) 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); -- cgit v1.2.3