update connect version based on ping response & fix typings (#101)

* update connect ver based on ping resp& add typings

* Fixed and added extremeheat suggestion

* Update API.md

* Update createClient.js
This commit is contained in:
u9g 2021-06-09 13:40:45 -04:00 committed by GitHub
commit d02eb6c041
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -4,7 +4,7 @@ const assert = require('assert')
const advertisement = require('./server/advertisement')
const { sleep } = require('./datatypes/util')
/** @param {{ version?: number, host: string, port?: number, connectTimeout?: number }} options */
/** @param {{ version?: number, host: string, port?: number, connectTimeout?: number, skipPing?: boolean }} options */
function createClient (options) {
assert(options)
const client = new Client({ port: 19132, ...options })
@ -15,7 +15,7 @@ function createClient (options) {
client.ping().then(data => {
const advert = advertisement.fromServerName(data)
console.log(`Connecting to server ${advert.motd} (${advert.name}), version ${advert.version}`)
// TODO: update connect version based on ping response
client.version = options.version ?? advert.version
connect(client)
}, client)
}