diff --git a/src/handlers/teamspeak/connectionHandler.ts b/src/handlers/teamspeak/connectionHandler.ts index cb1ddeb..5ee218b 100644 --- a/src/handlers/teamspeak/connectionHandler.ts +++ b/src/handlers/teamspeak/connectionHandler.ts @@ -35,7 +35,7 @@ export class TS5ConnectionHandler implements ITS5ConnectionHandler { } reconnect() { - console.log("Reconnecting...") + Logger.log("Reconnecting...") this.ws.close(); this.ws = new WebSocket(`ws://localhost:${this.remoteAppPort}`); @@ -47,8 +47,7 @@ export class TS5ConnectionHandler implements ITS5ConnectionHandler { // Connect to TS5 client connect() { - console.log('Connecting to TS5 client...'); - console.log(localStorage.getItem("apiKey")) + Logger.log('Connecting to TS5 client...'); // Create authentication payload const initalPayload: IAuthSenderPayload = { @@ -66,17 +65,17 @@ export class TS5ConnectionHandler implements ITS5ConnectionHandler { this.ws.onopen = () => { // Send authentication payload to TS5 client - console.log("Sending auth payload...") this.ws.send(JSON.stringify(initalPayload)); + Logger.wsSent(initalPayload); }; this.ws.onclose = (event) => { - console.log("WebSocket connection closed", event); + Logger.log("WebSocket connection closed", event); // If the connection was closed before authentication, remove the API key from local storage // OBS weirdly caches the localstorage and is very stubborn about clearing it (even when clicken "Clear Cache") if (!this.authenticated) { - console.log("WebSocket connection closed before authentication"); + Logger.log("WebSocket connection closed before authentication"); localStorage.removeItem("apiKey"); } @@ -90,7 +89,7 @@ export class TS5ConnectionHandler implements ITS5ConnectionHandler { this.ws.onmessage = (event) => { const data = JSON.parse(event.data); - console.log(data) + Logger.wsRecieved(data) switch (data.type) { case "auth": diff --git a/src/utils/logger.tsx b/src/utils/logger.tsx index 0427b75..279adb5 100644 --- a/src/utils/logger.tsx +++ b/src/utils/logger.tsx @@ -15,7 +15,7 @@ export default class Logger { } // Log message received from the websocket to the console - public static wsReicved(data: object, message: string | undefined = undefined): void { + public static wsReceived(data: object, message: string | undefined = undefined): void { console.log(`%c[WS Recieved] ${message ?? ""}`.trim(), "color: #8258c7", data); }