aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-03-24 20:41:25 +0100
committerKim Alvefur <zash@zash.se>2019-03-24 20:41:25 +0100
commit1e77bb6ed2ac00b1e5f64f39da41ec140fe425ce (patch)
tree8bc78282e4f05ad9fb8361b1e0414a8e137515b5 /plugins
parent6c89a86e0df62c51e0fb12596d3999324245c9fe (diff)
downloadprosody-1e77bb6ed2ac00b1e5f64f39da41ec140fe425ce.tar.gz
prosody-1e77bb6ed2ac00b1e5f64f39da41ec140fe425ce.zip
mod_csi_simple: Separate out functions to enable/disable optimizations
This allows reusing this logic outside the events. Letting the functions be module globals makes it easier to access from eg the telnet console.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_csi_simple.lua18
1 files changed, 13 insertions, 5 deletions
diff --git a/plugins/mod_csi_simple.lua b/plugins/mod_csi_simple.lua
index 0fa0d083..14abbc68 100644
--- a/plugins/mod_csi_simple.lua
+++ b/plugins/mod_csi_simple.lua
@@ -75,8 +75,7 @@ local function flush_buffer(data, session)
return data;
end
-module:hook("csi-client-inactive", function (event)
- local session = event.origin;
+function enable_optimizations(session)
if session.conn and session.conn and session.conn.pause_writes then
session.conn:pause_writes();
filters.add_filter(session, "stanzas/out", manage_buffer);
@@ -84,15 +83,24 @@ module:hook("csi-client-inactive", function (event)
else
session.log("warn", "Session connection does not support write pausing");
end
-end);
+end
-module:hook("csi-client-active", function (event)
- local session = event.origin;
+function disble_optimizations(session)
if session.conn and session.conn and session.conn.resume_writes then
filters.remove_filter(session, "stanzas/out", manage_buffer);
filters.remove_filter(session, "bytes/in", flush_buffer);
session.conn:resume_writes();
end
+end
+
+module:hook("csi-client-inactive", function (event)
+ local session = event.origin;
+ enable_optimizations(session);
+end);
+
+module:hook("csi-client-active", function (event)
+ local session = event.origin;
+ disble_optimizations(session);
end);