Software /
code /
prosody
Comparison
plugins/mod_compression.lua @ 2609:2ee28cae530a
mod_compression: Hook stream-features event using new events API.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 12 Feb 2010 04:21:34 +0500 |
parent | 2324:9f7eb1054a2f |
child | 2613:afa20941e098 |
comparison
equal
deleted
inserted
replaced
2608:68c43aaf681f | 2609:2ee28cae530a |
---|---|
23 module:log("warn", "Invalid compression level in config: %s", tostring(compression_level)); | 23 module:log("warn", "Invalid compression level in config: %s", tostring(compression_level)); |
24 module:log("warn", "Module loading aborted. Compression won't be available."); | 24 module:log("warn", "Module loading aborted. Compression won't be available."); |
25 return; | 25 return; |
26 end | 26 end |
27 | 27 |
28 module:add_event_hook("stream-features", | 28 module:hook("stream-features", function(event) |
29 function (session, features) | 29 local origin, features = event.origin, event.features; |
30 if not session.compressed then | 30 if not origin.compressed then |
31 -- FIXME only advertise compression support when TLS layer has no compression enabled | 31 -- FIXME only advertise compression support when TLS layer has no compression enabled |
32 features:add_child(compression_stream_feature); | 32 features:add_child(compression_stream_feature); |
33 end | 33 end |
34 end | 34 end); |
35 ); | 35 |
36 | 36 module:hook("s2s-stream-features", function(event) |
37 module:hook("s2s-stream-features", | 37 local session, features = event.session, event.features; |
38 function (data) | 38 -- FIXME only advertise compression support when TLS layer has no compression enabled |
39 local session, features = data.session, data.features; | 39 if not session.compressed then |
40 -- FIXME only advertise compression support when TLS layer has no compression enabled | 40 features:add_child(compression_stream_feature); |
41 if not session.compressed then | 41 end |
42 features:add_child(compression_stream_feature); | 42 end); |
43 end | |
44 end | |
45 ); | |
46 | 43 |
47 -- Hook to activate compression if remote server supports it. | 44 -- Hook to activate compression if remote server supports it. |
48 module:hook_stanza(xmlns_stream, "features", | 45 module:hook_stanza(xmlns_stream, "features", |
49 function (session, stanza) | 46 function (session, stanza) |
50 if not session.compressed then | 47 if not session.compressed then |