From 8c4406b4a2b8e6edfc49f1bd71b0a49592fa4d04 Mon Sep 17 00:00:00 2001 From: deathcap Date: Mon, 25 Jan 2016 23:24:20 -0800 Subject: [PATCH] Move keepAlive/checkTimeoutInterval to client/keepalive --- src/client/keepalive.js | 7 ++++++- src/createClient.js | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/client/keepalive.js b/src/client/keepalive.js index 59b9b88..3fc817b 100644 --- a/src/client/keepalive.js +++ b/src/client/keepalive.js @@ -1,4 +1,9 @@ -module.exports = function(client) { +module.exports = function(client, options) { + var keepAlive = options.keepAlive == null ? true : options.keepAlive; + if (!keepAlive) return; + + var checkTimeoutInterval = options.checkTimeoutInterval || 10 * 1000; + client.on('keep_alive', onKeepAlive); var timeout = null; diff --git a/src/createClient.js b/src/createClient.js index 031e2d0..5e7ac3f 100644 --- a/src/createClient.js +++ b/src/createClient.js @@ -37,8 +37,6 @@ function createClient(options) { assert.ok(options.username, "username is required"); var haveCredentials = options.password != null || (clientToken != null && options.session != null); - var keepAlive = options.keepAlive == null ? true : options.keepAlive; - var checkTimeoutInterval = options.checkTimeoutInterval || 10 * 1000; var optVersion = options.version || require("./version").defaultVersion; var mcData=require("minecraft-data")(optVersion); @@ -47,7 +45,7 @@ function createClient(options) { var client = new Client(false,version.majorVersion); client.on('connect', onConnect); - if(keepAlive) keepalive(client); + keepalive(client, options); encrypt(client); client.once('success', onLogin); compress(client);