mirror of
https://codeberg.org/spire/webrcon.git
synced 2026-06-03 17:24:07 +02:00
Merge d5877b02cf into d407f5b2e8
This commit is contained in:
commit
5661482df3
3 changed files with 6 additions and 5 deletions
|
|
@ -33,7 +33,7 @@ npm install --save webrcon
|
||||||
```js
|
```js
|
||||||
import Rcon from 'webrcon';
|
import Rcon from 'webrcon';
|
||||||
|
|
||||||
const rcon = new Rcon('127.0.0.1', 'secret_rcon_password');
|
const rcon = new Rcon('127.0.0.1', 'secret_rcon_password', '27021');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const result = await rcon.status();
|
const result = await rcon.status();
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,10 @@ export default class Connection {
|
||||||
receivedBuffer = '';
|
receivedBuffer = '';
|
||||||
errorCount = 0;
|
errorCount = 0;
|
||||||
|
|
||||||
constructor (host, password) {
|
constructor (host, password, port = 27021) {
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
|
this.port = port;
|
||||||
this.errorListeners = [];
|
this.errorListeners = [];
|
||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
|
|
@ -23,7 +24,7 @@ export default class Connection {
|
||||||
if (this.rcon) {
|
if (this.rcon) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.rcon = new WebRcon(this.host, this.password);
|
this.rcon = new WebRcon(this.host, this.password, this.port);
|
||||||
}
|
}
|
||||||
|
|
||||||
init () {
|
init () {
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import ChangeLevel from './command/changelevel';
|
||||||
import Status from './command/status';
|
import Status from './command/status';
|
||||||
|
|
||||||
export default class Rcon {
|
export default class Rcon {
|
||||||
constructor (host, password) {
|
constructor (host, password, port = 27021) {
|
||||||
this.connection = new Connection(host, password);
|
this.connection = new Connection(host, password, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect () {
|
disconnect () {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue