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:
parent
d3723ef42a
commit
999bfd3569
29 changed files with 580 additions and 135 deletions
14
examples/serverReadmeExample.js
Normal file
14
examples/serverReadmeExample.js
Normal 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()} !`)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue