Mercurial > prosody-hg
diff plugins/mod_c2s.lua @ 5720:449399a7e136
Merge
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 29 Jun 2013 14:45:47 +0100 |
| parents | 9345c161481f |
| children | cef2a1122b43 |
line wrap: on
line diff
--- a/plugins/mod_c2s.lua Sat Jun 29 14:45:38 2013 +0100 +++ b/plugins/mod_c2s.lua Sat Jun 29 14:45:47 2013 +0100 @@ -50,7 +50,7 @@ session.streamid = uuid_generate(); (session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host); - if not hosts[session.host] then + if not hosts[session.host] or not hosts[session.host].modules.c2s then -- We don't serve this host... session:close{ condition = "host-unknown", text = "This server does not serve "..tostring(session.host)}; return; @@ -262,10 +262,27 @@ end end +function listener.onreadtimeout(conn) + local session = sessions[conn]; + if session then + return (hosts[session.host] or prosody).events.fire_event("c2s-read-timeout", { session = session }); + end +end + +local function keepalive(event) + return event.session.send(' '); +end + function listener.associate_session(conn, session) sessions[conn] = session; end +function module.add_host(module) + module:hook("c2s-read-timeout", keepalive, -1); +end + +module:hook("c2s-read-timeout", keepalive, -1); + module:hook("server-stopping", function(event) local reason = event.reason; for _, session in pairs(sessions) do
