xmppclient_listener: Allow the tcp_keepalives option in the config to control whether keepalives are used
authorMatthew Wild <mwild1@gmail.com>
Tue, 12 Jan 2010 15:17:08 +0000
changeset 2454 e4818c49192d
parent 2453 44d4c69155e0
child 2455 0b3184f3c9e4
xmppclient_listener: Allow the tcp_keepalives option in the config to control whether keepalives are used
net/xmppclient_listener.lua
--- a/net/xmppclient_listener.lua	Tue Jan 12 15:16:22 2010 +0000
+++ b/net/xmppclient_listener.lua	Tue Jan 12 15:17:08 2010 +0000
@@ -27,6 +27,9 @@
 local sm_streamclosed = sessionmanager.streamclosed;
 local st = require "util.stanza";
 
+local config = require "core.configmanager";
+local opt_keepalives = config.get("*", "core", "tcp_keepalives");
+
 local stream_callbacks = { stream_tag = "http://etherx.jabber.org/streams\1stream", 
 		default_ns = "jabber:client",
 		streamopened = sm_streamopened, streamclosed = sm_streamclosed, handlestanza = core_process_stanza };
@@ -121,6 +124,10 @@
 			session.secure = true;
 		end
 		
+		if opt_keepalives ~= nil then
+			conn:setoption("keepalive", opt_keepalives);
+		end
+		
 		session.reset_stream = session_reset_stream;
 		session.close = session_close;