Skip to content

Commit 20af110

Browse files
committed
convert to ESM
export RCONOptions interface change default encoding to utf8 Adjust readme
1 parent 686bdea commit 20af110

File tree

7 files changed

+986
-946
lines changed

7 files changed

+986
-946
lines changed

README.md

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,53 @@
22
[According to Valve's RCON specification](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol)
33

44
## Install
5+
This version of rcon-srcds is an ES Module and requires Node 14+.
6+
57
```console
68
npm install rcon-srcds --save
79
```
810

911
## Usage
1012
```typescript
11-
// ES5 import
12-
const server = new Rcon(options);
13-
14-
// ES5+ import
15-
import Rcon from 'rcon-srcds';
16-
```
13+
import { RCON, RCONOptions } from 'rcon-srcds';
1714

18-
### Options
19-
These are the default values.
20-
```typescript
21-
{
15+
// These are the default values.
16+
const options: RCONOptions = {
2217
host: '127.0.0.1', // Host
2318
port: 27015, // Port
2419
maximumPacketSize: 0, // Maximum packet bytes (0 = no limit)
25-
encoding: 'ascii', // Packet encoding (ascii, utf8)
20+
encoding: 'utf8', // Packet encoding (ascii, utf8)
2621
timeout: 1000 // in ms
2722
}
28-
```
29-
30-
*The maximum possible value of packet size is **4096** bytes*: https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Packet_Size
31-
32-
## Minecraft Compatibility
33-
Although the package name implies exclusive compatibility with Source games, Minecraft servers also use Valve's RCON implementation, so there should not be any issues using this package for your Minecraft projects!
23+
const rcon = new RCON(options);
3424

35-
## Examples
36-
Using async/await:
37-
```typescript
38-
import Rcon from 'rcon-srcds';
39-
const server = new Rcon({ host: '127.0.0.1', port: 25010 });
25+
// using async/await
4026
try {
41-
await server.authenticate('your_rcon_password');
27+
await rcon.authenticate('your_rcon_password');
4228
console.log('authenticated');
43-
let status = await server.execute('status'); // You can read `status` reponse
44-
server.execute('mp_autokick 0'); // no need to read the response
29+
let status = await rcon.execute('status'); // You can read `status` reponse
30+
rcon.execute('mp_autokick 0'); // no need to read the response
4531
} catch(e) {
4632
console.error(e);
4733
}
48-
```
49-
Using (native) promises:
50-
```typescript
51-
import Rcon from 'rcon-srcds';
52-
const server = new Rcon({ port: 25010 });
5334

54-
server.authenticate('rcon_password')
35+
// Using promises
36+
rcon.authenticate('your_rcon_password')
5537
.then(() => {
5638
console.log('authenticated');
57-
return server.execute('status');
39+
return rcon.execute('status');
40+
})
41+
.then((response) => {
42+
console.log(response)
5843
})
59-
.then(console.log)
60-
.catch(console.error);
44+
.catch((e) => {
45+
console.log(e);
46+
});
6147
```
48+
49+
*The maximum possible value of packet size is **4096** bytes*:
50+
https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Packet_Size
51+
52+
## Minecraft Compatibility
53+
Although the package name implies exclusive compatibility with Source games, Minecraft servers also use Valve's RCON
54+
implementation, so there should not be any issues using this package for your Minecraft projects!

0 commit comments

Comments
 (0)