projects
/
prosody.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util.openssl: remove unused one-letter loop variable [luacheck]
[prosody.git]
/
plugins
/
mod_websocket.lua
diff --git
a/plugins/mod_websocket.lua
b/plugins/mod_websocket.lua
index 418cd84639f0aa07df2ec6d3d9c512103eeee6be..a3f5318c9b54636f8caec1b747bf39fd56bd9033 100644
(file)
--- a/
plugins/mod_websocket.lua
+++ b/
plugins/mod_websocket.lua
@@
-226,8
+226,7
@@
function handle_request(event)
frame.opcode = 0xA;
conn:write(build_frame(frame));
return "";
frame.opcode = 0xA;
conn:write(build_frame(frame));
return "";
- elseif opcode == 0xA then -- Pong frame
- module:log("warn", "Received unexpected pong frame: " .. tostring(frame.data));
+ elseif opcode == 0xA then -- Pong frame, MAY be sent unsolicited, eg as keepalive
return "";
else
log("warn", "Received frame with unsupported opcode %i", opcode);
return "";
else
log("warn", "Received frame with unsupported opcode %i", opcode);
@@
-275,7
+274,7
@@
function handle_request(event)
attr["xmlns:stream"] = attr["xmlns:stream"] or xmlns_streams;
end
return stanza;
attr["xmlns:stream"] = attr["xmlns:stream"] or xmlns_streams;
end
return stanza;
- end);
+ end
, -1000
);
add_filter(session, "bytes/out", function(data)
return build_frame({ FIN = true, opcode = 0x01, data = tostring(data)});
add_filter(session, "bytes/out", function(data)
return build_frame({ FIN = true, opcode = 0x01, data = tostring(data)});
@@
-291,6
+290,15
@@
function handle_request(event)
return "";
end
return "";
end
+local function keepalive(event)
+ local session = event.session;
+ if session.open_stream == session_open_stream then
+ return session.conn:write(build_frame({ opcode = 0x9, }));
+ end
+end
+
+module:hook("c2s-read-timeout", keepalive, -0.9);
+
function module.add_host(module)
module:depends("http");
module:provides("http", {
function module.add_host(module)
module:depends("http");
module:provides("http", {
@@
-301,4
+309,5
@@
function module.add_host(module)
["GET /"] = handle_request;
};
});
["GET /"] = handle_request;
};
});
+ module:hook("c2s-read-timeout", keepalive, -0.9);
end
end