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:
parent
e16e8381e5
commit
d02eb6c041
3 changed files with 6 additions and 6 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue