mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 06:03:33 -04:00
Move keepAlive/checkTimeoutInterval to client/keepalive
This commit is contained in:
parent
20e076ebcf
commit
8c4406b4a2
@ -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);
|
client.on('keep_alive', onKeepAlive);
|
||||||
|
|
||||||
var timeout = null;
|
var timeout = null;
|
||||||
|
@ -37,8 +37,6 @@ function createClient(options) {
|
|||||||
|
|
||||||
assert.ok(options.username, "username is required");
|
assert.ok(options.username, "username is required");
|
||||||
var haveCredentials = options.password != null || (clientToken != null && options.session != null);
|
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 optVersion = options.version || require("./version").defaultVersion;
|
||||||
var mcData=require("minecraft-data")(optVersion);
|
var mcData=require("minecraft-data")(optVersion);
|
||||||
@ -47,7 +45,7 @@ function createClient(options) {
|
|||||||
|
|
||||||
var client = new Client(false,version.majorVersion);
|
var client = new Client(false,version.majorVersion);
|
||||||
client.on('connect', onConnect);
|
client.on('connect', onConnect);
|
||||||
if(keepAlive) keepalive(client);
|
keepalive(client, options);
|
||||||
encrypt(client);
|
encrypt(client);
|
||||||
client.once('success', onLogin);
|
client.once('success', onLogin);
|
||||||
compress(client);
|
compress(client);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user