Software /
code /
prosody
Diff
plugins/mod_websocket.lua @ 7315:4fd984d1e445
mod_websocket: Send a ping on read timeout
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 23 Mar 2016 23:21:03 +0100 |
parent | 7314:e327e5b592f5 |
child | 7340:7dea28dafc49 |
line wrap: on
line diff
--- a/plugins/mod_websocket.lua Wed Mar 23 14:31:35 2016 +0100 +++ b/plugins/mod_websocket.lua Wed Mar 23 23:21:03 2016 +0100 @@ -290,6 +290,12 @@ return ""; end +local function keepalive(event) + return conn:write(build_frame({ opcode = 0x9, })); +end + +module:hook("c2s-read-timeout", keepalive, -0.9); + function module.add_host(module) module:depends("http"); module:provides("http", { @@ -300,4 +306,5 @@ ["GET /"] = handle_request; }; }); + module:hook("c2s-read-timeout", keepalive, -0.9); end