Skip to content

Promise-based JavaScript library for Rcon connection to the server with websockets. Made for Rust Experimental.

License

Notifications You must be signed in to change notification settings

acupofspirt/rust-experimental-webrcon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Experimental WebRcon

Rust Experimental is a game from British company Facepunch Studios. And this is Promise-based JavaScript library for Rcon connection to the server with websockets.

You may use source file rust-webrcon.js (ES6) or minified version rust-webrcon.min.js (ES5)

Usage

var rust = new RustWebRcon('rcon_password','server_ip','rcon_port')

// Use it in some event handler
rust.open()
$('button').click(() => {
	rust.cmd('status')
	.then(data => { '...do some work with response object' }) //see "Example of server response"
})

// Or execute commands with "then" chaining after connecting
rust.open()
.then(rust.cmdThen('status'))
.then(data => console.log(data.Message)) // hostname: Test Serv version : 1355 secure (secure...
.then(rust.cmdThen('another amazing command'))
.then(...)
	 
// And don't do this
// because connection may not yet be established
rust.open()
rust.cmd('status') //will throw error: Connection isn't established yet

API

open(): Promise

Open new connection

close(): Promise

Close current connection

cmd(string: command, number: identifier): Promise

Send Rcon command

Parameters

  • string: command - Command to execute. See full command list.
  • number: identifier - Used to link response with command. Optional.

cmdThen(string: command, number: identifier): Function

Send Rcon command - method for using with promise's .then()

Parameters

  • string: command - Command to execute. See full command list.
  • number: identifier - Used to link response with command. Optional.

Example of server response

// JSON string
{
"Identifier": 0,
"Message": "Saved 9,145 ents, serialization(0.00), write(0.00) ...",
"Stacktrace": "",
"Type": 3
}

License

This software is released under the terms of the MIT license.

About

Promise-based JavaScript library for Rcon connection to the server with websockets. Made for Rust Experimental.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published