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(); } }