mirror of
https://github.com/DerTyp7/teamspeak-obs-overlay.git
synced 2025-10-29 12:52:09 +01:00
[feature] integrated Logger
This commit is contained in:
@@ -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":
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user