8000 GitHub - thecatontheflat/rcon-client at next
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

thecatontheflat/rcon-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rcon-client

npm downloads

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.

Usage

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.

Events and error handling

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 occured
  • connect - 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.

About

A simple and modern RCON client made to work with Minecraft

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 78.7%
  • JavaScript 21.3%
0