client: Send whitespace keeplives

Sun, 06 Jun 2021 16:43:36 +0200

author
Kim Alvefur <zash@zash.se>
date
Sun, 06 Jun 2021 16:43:36 +0200
changeset 444
12c1be0044c6
parent 443
89526c890363
child 445
b119dc4d8bc2

client: Send whitespace keeplives

This is to prevent net.server from timing out connections.

client.lua file | annotate | diff | comparison | revisions
init.lua file | annotate | diff | comparison | revisions
--- a/client.lua	Wed Feb 17 14:57:59 2021 +0100
+++ b/client.lua	Sun Jun 06 16:43:36 2021 +0200
@@ -91,6 +91,7 @@
 
 	self:hook("connected", function () self:reopen(); end);
 	self:hook("incoming-raw", function (data) return self.data(self.conn, data); end);
+	self:hook("read-timeout", function () self:send(" "); return true; end, -1);
 
 	self.curr_id = 0;
 
--- a/init.lua	Wed Feb 17 14:57:59 2021 +0100
+++ b/init.lua	Sun Jun 06 16:43:36 2021 +0200
@@ -244,6 +244,9 @@
 		stream:event("status", new_status);
 	end
 
+	function conn_listener.onreadtimeout(conn)
+		return stream:event("read-timeout");
+	end
 	return conn_listener;
 end
 

mercurial