Hello,
with the basic rcon, i use xPaw source query ( php )
to send a command from external script.
Do you have a method for doing the same with Websockets ?
Websockets - Send a command from external script
Discussion in 'Rust Development' started by Loup-des-Neiges, Jun 1, 2016.
-
create a websocket server via your script.
connect to that socket with php and send all informations. -
Pretty sure the xPaw library still doesn't work correctly with Rust in particular because of a weird way that Rust implemented RCON. In terms of websockets that's going to be the future of Rust communication and you can enable it with your server by adding +rcon.web 1. Keep in mind this will break Rusty's interaction with the server and probably any regular RCON tools. To communicate client side you can use any standard websocket client code, there's a few examples on this forum such as Help with web RCON bot | Oxide
Here's a node.js websocket example I wrote that if you don't know is javascript that can run server side.
Code:/* setttings */ var server_ip = '127.0.0.1'; var server_port = 28018; var server_pass = 'abc';/* initialize */ var WebSocket = require('ws');/* connect */ var ws = new WebSocket('ws://'+server_ip+':'+server_port+'/'+server_pass+'/');/* we're connected */ ws.on('open', function open() { console.log('connected'); /* send a test command */ SendMsg('find *',1); });/* server sent us a message */ ws.on('message', function(data, flags) { // flags.binary will be set if a binary data is received. // flags.masked will be set if the data was masked. console.log('message:'+data); });/* our connection closed */ ws.on('close', function close() { console.log('disconnected'); });/* send a message */ function SendMsg(msg, identifier) { var packet = { Identifier: identifier, Message: msg, Name: "WebRcon" } ws.send(JSON.stringify(packet)); }
so you can npm install ws in your project directory to install the package or add to a package.json and do npm install. Then to run just save this code to test.js and do node test.js
output is like
Code:C:\web_rcon>node test.js connected message:{ "Message": "Variables:\n\nCommands:\n", "Identifier": 1, "Type": "Generic", "Stacktrace": "" } message:{ "Message": "Saved 14,659 ents, serialization(0.00), write(0.00), disk(0.00) to talstall(0.01).", "Identifier": 0, "Type": "Generic", "Stacktrace": "" } message:{ "Message": "Saving complete", "Identifier": 0, "Type": "Generic", "Stacktrace": "" } message:{ "Message": "[Oxide] 13:10 [Info] [ZPlayerStats] OnEntityDeath works!", "Identifier": 0, "Type": "Generic", "Stacktrace": "" } [/B]
Last edited by a moderator: Aug 7, 2016