Update to support PrismarineJS/nethernet
This commit is contained in:
parent
754563742d
commit
9f6e19cde8
2 changed files with 5 additions and 4 deletions
|
|
@ -10,7 +10,7 @@ c.once('pong', (pong) => {
|
|||
|
||||
const client = createClient({
|
||||
transport: 'nethernet', // Use the Nethernet transport
|
||||
networkId: pong.senderId,
|
||||
networkId: pong.sender_id,
|
||||
useSignalling: false
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ function createClient (options) {
|
|||
|
||||
/** @param {Client} client */
|
||||
async function connect (client) {
|
||||
if (client.transport === 'nethernet') {
|
||||
if (client.options.transport === 'nethernet') {
|
||||
if (client.options.useSignalling) {
|
||||
client.nethernet.signalling = new NethernetSignal(client.connection.nethernet.networkId, client.options.authflow, client.options.version)
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ async function connect (client) {
|
|||
|
||||
client.nethernet.signalling.on('signal', signal => client.connection.nethernet.handleSignal(signal))
|
||||
} else {
|
||||
await client.connection.nethernet.ping()
|
||||
await client.connection.ping()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -126,10 +126,11 @@ async function connect (client) {
|
|||
}
|
||||
|
||||
async function ping ({ host, port, networkId }) {
|
||||
console.log(`Pinging ${host}:${port} with networkId ${networkId}`)
|
||||
if (networkId) {
|
||||
const con = new NethernetClient({ networkId })
|
||||
try {
|
||||
return advertisement.NethernetServerAdvertisement.fromBuffer(await con.ping())
|
||||
return advertisement.NethernetServerAdvertisement.fromBuffer(Buffer.from(await con.ping(), 'hex'))
|
||||
} finally {
|
||||
con.close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue