A simple and easy to use RCON client made to work with Minecraft servers. It's written in TypeScript and uses async methods.
rcon-client
has a built-in packet queue with a max pending setting which limits
the number of packets sent before one is received. It can be useful against bad
server implementations.
import { RconClient } from "rcon-client"
const rcon = await RconClient.connect("localhost", 25575, "password")
console.log(await rcon.send("list"))
const responses = await Promise.all([
rcon.send("help"),
rcon.send("whitelist list")
])
for (response of responses) {
console.log(response)
}
rcon.end()
Or alternatively you can create an instance via the constructor.
const rcon = new RconClient()
await rcon.connect("localhost", 25575, "password")
rcon.end()
More examples can be found in the repository's examples/
folder.
The class RconClient
extends Node's EventEmitter
. All methods of it will be available.
These are all the events the clients might emit:
error
- Socket error has occuredconnect
- Socket is connected but not yet authenticated.authenticated
- Client has successfully authenticated with the server.end
- Client connection was closed.
Make sure to add a error
event handler to the RconClient
instance to prevent
unexpected crashes.