# 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](https://www.npmjs.com/package/sa-simple-rcon).

## Usage
### Creating an Instance
Instantiate `RconClient` by providing a configuration object which includes `gameId` and other connection-specific options.

```javascript
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
```javascript
rcon.login();
```

### Sending Commands
```javascript
rcon.send('status', 'ServerStatus', 1);
```

### Handling Responses
`RconClient` inherits from `EventEmitter`, allowing you to listen to various events.
```javascript
rcon.on('message', (data) => {
  console.log('Received:', data);
});
```

### Closing Connection
```javascript
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.