From 8e309100651a073d344211284434644c0a403199 Mon Sep 17 00:00:00 2001 From: Mark Hindess Date: Wed, 30 Jul 2014 13:57:25 +0100 Subject: [PATCH] Add webSocketKeepAliveTime setting to aid testing. --- red/comms.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/red/comms.js b/red/comms.js index be23729a6..3664f55cc 100644 --- a/red/comms.js +++ b/red/comms.js @@ -35,6 +35,8 @@ function init(_server,_settings) { } function start() { + + var webSocketKeepAliveTime = settings.webSocketKeepAliveTime || 15000; var path = settings.httpAdminRoot || "/"; path = path + (path.slice(-1) == "/" ? "":"/") + "comms"; wsServer = new ws.Server({server:server,path:path}); @@ -74,11 +76,11 @@ function start() { heartbeatTimer = setInterval(function() { var now = Date.now(); - if (now-lastSentTime > 15000) { + if (now-lastSentTime > webSocketKeepAliveTime) { lastSentTime = now; publish("hb",lastSentTime); } - }, 15000); + }, webSocketKeepAliveTime); } function publish(topic,data,retain) {