aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-08-16 12:45:14 +0200
committerKim Alvefur <zash@zash.se>2021-08-16 12:45:14 +0200
commit48216c1dc849292323b016660e851f58aae2e325 (patch)
treef67338c752bace5fbd37855a37973d425037890e
parentd06ae1629513e0a8ab8c1a24566226dddc93e8e1 (diff)
downloadprosody-48216c1dc849292323b016660e851f58aae2e325.tar.gz
prosody-48216c1dc849292323b016660e851f58aae2e325.zip
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.
-rw-r--r--plugins/mod_c2s.lua7
-rw-r--r--plugins/mod_s2s.lua7
2 files changed, 14 insertions, 0 deletions
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);