bedrock-protocol/examples/clientReadmeExample.js
extremeheat 76febb29f1
Support xbox title + live.com auth (#86)
* preliminary support for xbox title + live.com auth

* cleanup

* export title list

* add to api docs

* Verify that minecraft token has titleId if did titleAuth

* Minor changes
2021-05-19 09:53:55 -04:00

19 lines
No EOL
906 B
JavaScript

/* eslint-disable */
const bedrock = require('bedrock-protocol')
const client = bedrock.createClient({
host: 'localhost', // optional
port: 19132, // optional, default 19132
username: 'Notch', // the username you want to join as, optional if online mode
offline: false, // optional, default false. if true, do not login with Xbox Live. You will not be asked to sign-in if set to true.
// Optional for some servers which verify the title ID:
// authTitle: bedrock.title.MinecraftNintendoSwitch
})
client.on('text', (packet) => { // Listen for chat messages and echo them back.
if (packet.source_name != client.options.username) {
client.queue('text', {
type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '',
message: `${packet.source_name} said: ${packet.message} on ${new Date().toLocaleString()}`
})
}
})