minecraft-protocol
Advanced tools
Comparing version 1.18.0 to 1.19.0
@@ -85,2 +85,3 @@ # Documentation | ||
* closeTimeout : end the connection after this delay in milliseconds if server doesn't answer to ping, default to `120*1000` | ||
* noPongTimeout : after the server opened the connection, wait for a default of `5*1000` after pinging and answers without the latency | ||
* checkTimeoutInterval : default to `30*1000` (30s), check if keepalive received at that period, disconnect otherwise. | ||
@@ -87,0 +88,0 @@ * version : 1.8 or 1.9 or false (to auto-negotiate): default to 1.8 |
# History | ||
## 1.19.0 | ||
* make auto version more robust by giving up after 5s if no answer to ping is given but the version is returned | ||
## 1.18.0 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "minecraft-protocol", | ||
"version": "1.18.0", | ||
"version": "1.19.0", | ||
"lockfileVersion": 1, | ||
@@ -5,0 +5,0 @@ "requires": true, |
{ | ||
"name": "minecraft-protocol", | ||
"version": "1.18.0", | ||
"version": "1.19.0", | ||
"description": "Parse and serialize minecraft packets, plus authentication and encryption.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -18,3 +18,4 @@ 'use strict' | ||
var closeTimer = null | ||
options.closeTimeout = 120 * 1000 | ||
options.closeTimeout = options.closeTimeout || 120 * 1000 | ||
options.noPongTimeout = options.noPongTimeout || 5 * 1000 | ||
@@ -30,4 +31,10 @@ const client = new Client(false, version.minecraftVersion) | ||
const start = Date.now() | ||
const maxTime = setTimeout(() => { | ||
clearTimeout(closeTimer) | ||
cb(null, data) | ||
client.end() | ||
}, options.noPongTimeout) | ||
client.once('ping', function (packet) { | ||
data.latency = Date.now() - start | ||
clearTimeout(maxTime) | ||
clearTimeout(closeTimer) | ||
@@ -34,0 +41,0 @@ cb(null, data) |
167040
3527