# HG changeset patch # User Tobias Markmann # Date 1259529486 -3600 # Node ID 156bb00ba5c01c31bb2b4904a4d96d999e12a0e5 # Parent 6f54dac3ec2d32d0b33e465f6237898454904563 mod_compression: Moving compression setup in a dedicated function. diff -r 6f54dac3ec2d -r 156bb00ba5c0 plugins/mod_compression.lua --- a/plugins/mod_compression.lua Sun Nov 29 22:02:21 2009 +0100 +++ b/plugins/mod_compression.lua Sun Nov 29 22:18:06 2009 +0100 @@ -108,21 +108,24 @@ end -- setup compression for session.w - local old_send = session.send; + local function setup_compression(session) + local old_send = session.send; - session.send = function(t) - local status, compressed, eof = pcall(deflate_stream, tostring(t), 'sync'); - if status == false then - session:close({ - condition = "undefined-condition"; - text = compressed; - extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed"); - }); - module:log("warn", compressed); - return; - end - old_send(compressed); - end; + session.send = function(t) + local status, compressed, eof = pcall(deflate_stream, tostring(t), 'sync'); + if status == false then + session:close({ + condition = "undefined-condition"; + text = compressed; + extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed"); + }); + module:log("warn", compressed); + return; + end + old_send(compressed); + end; + end + setup_compression(session); -- setup decompression for session.data local function setup_decompression(session)