Enforce server auth, ping on createClient, update docs (#68)

* Add createServer, ping on createClient, update README

* fix createClient keepalive

* resort readme, fix node 14

* Enforce auth on server connections, fix close/connect issues

* add type definitions, update readme, docs

* Wait some time before closing connection, update docs

* wait for server close in tests, fix race bug

* export a ping api

* Rename api.md to API.md

* add ping example
This commit is contained in:
extremeheat 2021-04-18 09:19:59 -04:00 committed by GitHub
commit 999bfd3569
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 580 additions and 135 deletions

View file

@ -0,0 +1,14 @@
/* eslint-disable */
const bedrock = require('bedrock-protocol')
const server = new bedrock.createServer({
host: '0.0.0.0', // optional
port: 19132, // optional
version: '1.16.220' // The server version
})
server.on('connect', client => {
client.on('join', () => { // The client has joined the server.
const d = new Date() // Once client is in the server, send a colorful kick message
client.disconnect(`Good ${d.getHours() < 12 ? '§emorning§r' : '§3afternoon§r'} :)\n\nMy time is ${d.toLocaleString()} !`)
})
})