commit 5a07647f39affcbdce6a801851e014f3002a1f4c
parent 144f05c4c23a6243806e10caa910e1af396ab03d
Author: MTRNord <mtrnord1@gmail.com>
Date: Wed, 23 Mar 2016 21:33:13 +0100
Add some basic Buttons and add default Config
Diffstat:
4 files changed, 69 insertions(+), 4 deletions(-)
diff --git a/backend/rcon.js b/backend/rcon.js
@@ -21,7 +21,7 @@ module.exports = {
},
restart_game: function () {
rcon.connect().then(() => {
- return rcon.command('mp_restartgame 1').then(() => {
+ return rcon.command('mp_restartgame 1').then(() =>{
console.log('game restarted');
});
}).then(
@@ -31,6 +31,18 @@ module.exports = {
console.log(err.stack);
});
},
+ status: function () {
+ rcon.connect().then(() => {
+ rcon.command('status').then(() => {
+ console.log('status check');
+ });
+ }).then(
+ () => rcon.disconnect()
+ ).catch(err => {
+ console.log('caught', err);
+ console.log(err.stack);
+ });
+ },
live_on: function () {
rcon.connect().then(() => {
return rcon.command('mp_restartgame 1').then(() => {
diff --git a/config/default.json b/config/default.json
@@ -0,0 +1,29 @@
+{
+ "firstrun": 1,
+ "server": [
+ {
+ "name": "server1",
+ "ip": "x.x.x.x",
+ "port": "27015",
+ "pass": "",
+ "rcon_pass": "",
+ "owner": "USERNAME",
+ "whitelist": [
+ {
+ "name": "MTRNord"
+ }
+ ]
+ }
+ ],
+ "admins": [
+ {
+ "name": "MTRNord"
+ }
+ ],
+ "user": [
+ {
+ "name": "MTRNord",
+ "Steam_ID": "STEAMID"
+ }
+ ]
+}
diff --git a/web/server.js b/web/server.js
@@ -3,6 +3,7 @@ var express = require('express')
var http = require('http').Server(app);
var io = require('socket.io')(http);
var rcon = require("../backend/rcon.js")
+var util = require('util');
module.exports = {
start: function () {
@@ -33,7 +34,13 @@ module.exports = {
if (command.command == "live_on") {
rcon.live_on()
}else {
- console.log("unknown command");
+ if (command.command == "status") {
+ rcon.status()
+
+ console.log("Status: " + util.inspect(rcon.status(), {showHidden: false, depth: null}));
+ }else {
+ console.log("unknown command");
+ }
}
}
socket.broadcast.emit('alert', "command executed");
diff --git a/web/theme/index.html b/web/theme/index.html
@@ -63,8 +63,16 @@
</div>
<div class="panel-body">
<p>
- <button type="button" class="btn btn-danger btn-lg" id="restart">Restart Game</button>
- <button type="button" class="btn btn-success btn-lg" id="live_on">LIVE!!!</button>
+ <ul class="list-group">
+ <li class="list-group-item">
+ <button type="button" class="btn btn-danger btn-lg" id="restart">Restart Game</button>
+ <button type="button" class="btn btn-success btn-lg" id="live_on">LIVE!!!</button>
+ </li>
+ <li class="list-group-item">
+ <p id="status"></p>
+ <button type="button" class="btn btn-info btn-lg" id="check_status">Check Status</button>
+ </li>
+ </ul>
</p>
</div>
@@ -311,6 +319,15 @@
socket.on('alert', function (message) {
console.log(message);
});
+ socket.on('status_alert', function (message) {
+ console.log("response " + message);
+ });
+ $(document).off('click', '#check_status').on('click', '#check_status', function (e) {
+ console.log('Check Status');
+
+ socket.emit('command', {command: 'status'});
+ e.preventDefault();
+ });
</script>
</body>
</html>