(feature) Update UI & Resource Availability
This commit is contained in:
parent
11d8229eb5
commit
929193d272
44 changed files with 4747 additions and 27 deletions
27
src/servers/RconSocket.js
Normal file
27
src/servers/RconSocket.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { io } from "socket.io-client";
|
||||
export default class RconSocket {
|
||||
constructor(logUpdate, serverName) {
|
||||
(this.sk = io("/", { query: { serverName } })), (this.logs = []);
|
||||
this.logUpdate = logUpdate;
|
||||
this.sk.on("push", this.onPush.bind(this));
|
||||
this.sk.on("connect", this.onConnect.bind(this));
|
||||
}
|
||||
|
||||
onPush(p) {
|
||||
this.logs = [...this.logs, p];
|
||||
this.logUpdate(this.logs);
|
||||
}
|
||||
|
||||
send(m) {
|
||||
this.sk.emit("msg", m);
|
||||
}
|
||||
|
||||
onConnect() {
|
||||
this.logs = [];
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
if (!this.sk) return;
|
||||
this.sk.disconnect();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue