plugins/mod_compression.lua

changeset 2290
9c5941198719
parent 2289
c6bed51c6733
child 2291
abd28ed5d8b0
equal deleted inserted replaced
2289:c6bed51c6733 2290:9c5941198719
137 137
138 module:add_handler({"s2sout_unauthed", "s2sout"}, "compressed", xmlns_compression_protocol, 138 module:add_handler({"s2sout_unauthed", "s2sout"}, "compressed", xmlns_compression_protocol,
139 function(session ,stanza) 139 function(session ,stanza)
140 session.log("debug", "Activating compression...") 140 session.log("debug", "Activating compression...")
141 -- create deflate and inflate streams 141 -- create deflate and inflate streams
142 deflate_stream = get_deflate_stream(session); 142 local deflate_stream = get_deflate_stream(session);
143 if not deflate_stream then return end 143 if not deflate_stream then return end
144 144
145 inflate_stream = get_inflate_stream(session); 145 local inflate_stream = get_inflate_stream(session);
146 if not inflate_stream then return end 146 if not inflate_stream then return end
147 147
148 -- setup compression for session.w 148 -- setup compression for session.w
149 setup_compression(session, deflate_stream); 149 setup_compression(session, deflate_stream);
150 150
178 local method = stanza:child_with_name("method")[1]; 178 local method = stanza:child_with_name("method")[1];
179 if method == "zlib" then 179 if method == "zlib" then
180 session.log("info", method.." compression selected."); 180 session.log("info", method.." compression selected.");
181 181
182 -- create deflate and inflate streams 182 -- create deflate and inflate streams
183 deflate_stream = get_deflate_stream(session); 183 local deflate_stream = get_deflate_stream(session);
184 if not deflate_stream then return end 184 if not deflate_stream then return end
185 185
186 inflate_stream = get_inflate_stream(session); 186 local inflate_stream = get_inflate_stream(session);
187 if not inflate_stream then return end 187 if not inflate_stream then return end
188 188
189 (session.sends2s or session.send)(st.stanza("compressed", {xmlns=xmlns_compression_protocol})); 189 (session.sends2s or session.send)(st.stanza("compressed", {xmlns=xmlns_compression_protocol}));
190 session:reset_stream(); 190 session:reset_stream();
191 191

mercurial