mirror of
https://github.com/DerTyp7/teamspeak-obs-overlay.git
synced 2025-10-30 05:07:12 +01:00
[feature] integrated Logger
This commit is contained in:
@@ -35,7 +35,7 @@ export class TS5ConnectionHandler implements ITS5ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reconnect() {
|
reconnect() {
|
||||||
console.log("Reconnecting...")
|
Logger.log("Reconnecting...")
|
||||||
this.ws.close();
|
this.ws.close();
|
||||||
|
|
||||||
this.ws = new WebSocket(`ws://localhost:${this.remoteAppPort}`);
|
this.ws = new WebSocket(`ws://localhost:${this.remoteAppPort}`);
|
||||||
@@ -47,8 +47,7 @@ export class TS5ConnectionHandler implements ITS5ConnectionHandler {
|
|||||||
|
|
||||||
// Connect to TS5 client
|
// Connect to TS5 client
|
||||||
connect() {
|
connect() {
|
||||||
console.log('Connecting to TS5 client...');
|
Logger.log('Connecting to TS5 client...');
|
||||||
console.log(localStorage.getItem("apiKey"))
|
|
||||||
|
|
||||||
// Create authentication payload
|
// Create authentication payload
|
||||||
const initalPayload: IAuthSenderPayload = {
|
const initalPayload: IAuthSenderPayload = {
|
||||||
@@ -66,17 +65,17 @@ export class TS5ConnectionHandler implements ITS5ConnectionHandler {
|
|||||||
|
|
||||||
this.ws.onopen = () => {
|
this.ws.onopen = () => {
|
||||||
// Send authentication payload to TS5 client
|
// Send authentication payload to TS5 client
|
||||||
console.log("Sending auth payload...")
|
|
||||||
this.ws.send(JSON.stringify(initalPayload));
|
this.ws.send(JSON.stringify(initalPayload));
|
||||||
|
Logger.wsSent(initalPayload);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.ws.onclose = (event) => {
|
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
|
// 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")
|
// OBS weirdly caches the localstorage and is very stubborn about clearing it (even when clicken "Clear Cache")
|
||||||
if (!this.authenticated) {
|
if (!this.authenticated) {
|
||||||
console.log("WebSocket connection closed before authentication");
|
Logger.log("WebSocket connection closed before authentication");
|
||||||
localStorage.removeItem("apiKey");
|
localStorage.removeItem("apiKey");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +89,7 @@ export class TS5ConnectionHandler implements ITS5ConnectionHandler {
|
|||||||
this.ws.onmessage = (event) => {
|
this.ws.onmessage = (event) => {
|
||||||
const data = JSON.parse(event.data);
|
const data = JSON.parse(event.data);
|
||||||
|
|
||||||
console.log(data)
|
Logger.wsRecieved(data)
|
||||||
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case "auth":
|
case "auth":
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export default class Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log message received from the websocket to the console
|
// 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);
|
console.log(`%c[WS Recieved] ${message ?? ""}`.trim(), "color: #8258c7", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user