Software /
code /
prosody
Diff
plugins/mod_compression.lua @ 2283:156bb00ba5c0
mod_compression: Moving compression setup in a dedicated function.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Sun, 29 Nov 2009 22:18:06 +0100 |
parent | 2282:6f54dac3ec2d |
child | 2284:491b89d6816b |
line wrap: on
line diff
--- 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)