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)
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
Open new connection
Close current connection
Send Rcon command
Parameters
string: command
- Command to execute. See full command list.number: identifier
- Used to link response with command. Optional.
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.
// JSON string
{
"Identifier": 0,
"Message": "Saved 9,145 ents, serialization(0.00), write(0.00) ...",
"Stacktrace": "",
"Type": 3
}
This software is released under the terms of the MIT license.