Package Exports
- battleye
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (battleye) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
battleye
Battleye rcon client built in nodejs.
Example usage:
import * as readline from 'readline'
import { readCfg, Socket } from 'battleye'
readCfg(process.cwd())
.then(cfg => {
console.log(cfg)
const socket = new Socket()
const connection = socket.connection({
password: cfg.rconpassword,
ip: cfg.rconip,
port: parseInt(cfg.rconport, 10)
})
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
socket.on('listening', (socket) => {
const addr = socket.address()
console.log(`Socket listening on ${typeof addr === 'string' ? addr : `${addr.address}:${addr.port}`}`)
})
socket.on('received', (resolved, packet, buffer, connection, info) => {
console.log(`received: ${connection.ip}:${connection.port} => packet:`, packet)
})
socket.on('sent', (packet, buffer, bytes, connection) => {
console.log(`sent: ${connection.ip}:${connection.port} => packet:`, packet)
})
socket.on('error', (err) => { console.error(`SOCKET ERROR:`, err) })
connection.on('message', (message, packet) => {
console.log(`message: ${connection.ip}:${connection.port} => message: ${message}`)
})
connection.on('command', (data, resolved, packet) => {
console.log(`command: ${connection.ip}:${connection.port} => packet:`, packet)
})
connection.on('disconnected', (reason) => {
console.warn(`disconnected from ${connection.ip}:${connection.port},`, reason)
})
connection.on('connected', () => {
console.error(`connected to ${connection.ip}:${connection.port}`)
})
connection.on('message', (message, packet) => {
console.error(`message: ${connection.ip}:${connection.port} => ${message}`)
})
connection.on('debug', console.log)
connection.on('error', (err) => {
console.error(`CONNECTION ERROR:`, err)
})
rl.on('line', input => {
connection
.command(input)
.then(response => {
console.log(`response: ${connection.ip}:${connection.port} => ${response.command}\n${response.data}`)
})
.catch(console.error)
console.log(`send: ${connection.ip}:${connection.port} => ${input}`)
})
})
.catch(err => { console.error(`Error reading config:`, err) })