This commit is contained in:
Morgan Massens 2020-05-10 21:21:02 -03:00 committed by GitHub
commit 5661482df3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View file

@ -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();

View file

@ -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 () {

View file

@ -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 () {