[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 {
await rcon.connect();
} 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}'`);
}
socket.rconClient = rcon;

View file

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

View file

@ -5,10 +5,13 @@ export default class RconSocket {
this.logUpdate = logUpdate;
this.sk.on("push", this.onPush.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.rconLive = false;
}
onPush(p) {
this.rconLive = true;
this.logs = [...this.logs, p];
this.logUpdate(this.logs);
}
@ -17,6 +20,11 @@ export default class RconSocket {
this.sk.emit("msg", m);
}
onRconError(v) {
this.rconLive = false;
console.log("Server sent" + v);
}
onConnect() {
this.sk.readyState = 1;
this.logs = [];

View file

@ -55,8 +55,12 @@ export default function RconView(props) {
variant="outlined"
value={cmd}
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>
);