[FEATURE] RCON Connection Indicator

This commit is contained in:
Dunemask 2023-12-31 14:04:44 -07:00
parent 5f2a94dc14
commit 76b8bf91c9
4 changed files with 15 additions and 3 deletions

View file

@ -61,7 +61,7 @@ export async function webConsoleRcon(socket) {
try { try {
await rcon.connect(); await rcon.connect();
} catch (error) { } catch (error) {
socket.emit("push", "Could not connect RCON Input to server!"); socket.emit("rcon-error", "Could not connect RCON Input to server!");
WARN("RCON", `Could not connect to '${rconHost}'`); WARN("RCON", `Could not connect to '${rconHost}'`);
} }
socket.rconClient = rcon; socket.rconClient = rcon;

View file

@ -26,7 +26,7 @@ export default function RconDialog(props) {
sx={ sx={
fullScreen fullScreen
? {} ? {}
: { "& .mcl-MuiDialog-paper": { width: "80%", maxHeight: 525 } } : { "& .mcl-MuiDialog-paper": { width: "80%", maxHeight: 555 } }
} }
maxWidth="xs" maxWidth="xs"
open={open} open={open}

View file

@ -5,10 +5,13 @@ export default class RconSocket {
this.logUpdate = logUpdate; this.logUpdate = logUpdate;
this.sk.on("push", this.onPush.bind(this)); this.sk.on("push", this.onPush.bind(this));
this.sk.on("connect", this.onConnect.bind(this)); this.sk.on("connect", this.onConnect.bind(this));
this.sk.on("rcon-error", this.onRconError.bind(this));
this.sk.on("error", () => console.log("WHOOSPSIE I GUESS?")); this.sk.on("error", () => console.log("WHOOSPSIE I GUESS?"));
this.rconLive = false;
} }
onPush(p) { onPush(p) {
this.rconLive = true;
this.logs = [...this.logs, p]; this.logs = [...this.logs, p];
this.logUpdate(this.logs); this.logUpdate(this.logs);
} }
@ -17,6 +20,11 @@ export default class RconSocket {
this.sk.emit("msg", m); this.sk.emit("msg", m);
} }
onRconError(v) {
this.rconLive = false;
console.log("Server sent" + v);
}
onConnect() { onConnect() {
this.sk.readyState = 1; this.sk.readyState = 1;
this.logs = []; this.logs = [];

View file

@ -55,8 +55,12 @@ export default function RconView(props) {
variant="outlined" variant="outlined"
value={cmd} value={cmd}
onChange={updateCmd} onChange={updateCmd}
disabled={!(rcon && rcon.rconLive)}
/> />
<Button onClick={sendCommand}>Send</Button> {rcon && rcon.rconLive && <Button onClick={sendCommand}>Send</Button>}
{!(rcon && rcon.rconLive) && (
<Button color="secondary">Not Connected</Button>
)}
</Box> </Box>
</Box> </Box>
); );