Software /
code /
prosody
Diff
plugins/mod_component.lua @ 7886:679746cdf3cc
mod_component: Add read timeout handler (same behaviour as c2s and s2s)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 10 Feb 2017 21:25:12 +0100 |
parent | 7873:8d1ebb9a9b44 |
child | 7887:93fd15b5ec1b |
child | 8134:b87e281a7d59 |
line wrap: on
line diff
--- a/plugins/mod_component.lua Sat Feb 04 00:59:10 2017 +0100 +++ b/plugins/mod_component.lua Fri Feb 10 21:25:12 2017 +0100 @@ -29,6 +29,13 @@ local sessions = module:shared("sessions"); +local function keepalive(event) + local session = event.session; + if not session.notopen then + return event.session.send(' '); + end +end + function module.add_host(module) if module:get_host_type() ~= "component" then error("Don't load mod_component manually, it should be for a component, please see http://prosody.im/doc/components", 0); @@ -135,8 +142,12 @@ module:hook("iq/host", handle_stanza, -1); module:hook("message/host", handle_stanza, -1); module:hook("presence/host", handle_stanza, -1); + + module:hook("component-read-timeout", keepalive, -1); end +module:hook("component-read-timeout", keepalive, -1); + --- Network and stream part --- local xmlns_component = 'jabber:component:accept'; @@ -332,6 +343,13 @@ sessions[conn] = nil; end +function listener.onreadtimeout(conn) + local session = sessions[conn]; + if session then + return (hosts[session.host] or prosody).events.fire_event("component-read-timeout", { session = session }); + end +end + module:provides("net", { name = "component"; private = true;