sa-simple-rcon
v1.1.9-dev26
Published
> A simplified rcon client for rust and ark
Downloads
235
Readme
RconClient
Overview
RconClient
is a flexible remote console client that supports multiple connection types (WebSocket and NetSocket) for game server management. It leverages event-driven architecture to handle RCON commands and responses efficiently.
Features
- Supports both WebSocket and TCP connections.
- Event-driven approach for robust and scalable server command handling.
- Easy to integrate with various game servers by configuring the
gameId
.
Installation
To install RconClient
, run the following npm command:
npm install sa-simple-rcon
For more details, visit the npm package page.
Usage
Creating an Instance
Instantiate RconClient
by providing a configuration object which includes gameId
and other connection-specific options.
import { RconClient } from 'sa-simple-rcon';
const options = {
host: 'localhost',
port: 25575,
password: 'your_password',
timeout: 5000,
gameId: 252490 // Use 346110 for ARK
};
const rcon = new RconClient(options);
Connecting to the Server
rcon.login();
Sending Commands
rcon.send('status', 'ServerStatus', 1);
Handling Responses
RconClient
inherits from EventEmitter
, allowing you to listen to various events.
rcon.on('message', (data) => {
console.log('Received:', data);
});
Closing Connection
rcon.close(); // Gracefully closes the connection
API
login()
Initiates the connection based on the provided options.
send(message: string, name: string, identifier: string | number)
Sends a message/command to the server. name
and identifier
can be used to handle responses.
close()
Closes the connection gracefully.
terminate()
Forcibly closes the connection.