mirror of
https://github.com/DerTyp7/teamspeak-obs-overlay.git
synced 2025-10-30 13:17:11 +01:00
using spaces instead of tabs now & added prettier config
This commit is contained in:
122
js/app.js
122
js/app.js
@@ -1,70 +1,70 @@
|
||||
function main() {
|
||||
const ws = new WebSocket(`ws://localhost:${CONFIG.remoteAppPort}`);
|
||||
const paylaod = {
|
||||
type: "auth",
|
||||
payload: {
|
||||
identifier: "de.tealfire.obs",
|
||||
version: "0.0.1",
|
||||
name: "TS5 OBS Overlay",
|
||||
description: "A simple OBS overlay for TS5 by DerTyp876",
|
||||
content: {
|
||||
apiKey: CONFIG.apiKey,
|
||||
},
|
||||
},
|
||||
};
|
||||
const ws = new WebSocket(`ws://localhost:${CONFIG.remoteAppPort}`);
|
||||
const paylaod = {
|
||||
type: "auth",
|
||||
payload: {
|
||||
identifier: "de.tealfire.obs",
|
||||
version: "0.0.1",
|
||||
name: "TS5 OBS Overlay",
|
||||
description: "A simple OBS overlay for TS5 by DerTyp876",
|
||||
content: {
|
||||
apiKey: CONFIG.apiKey,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
clientList.clear();
|
||||
channelList.clear();
|
||||
clientList.clear();
|
||||
channelList.clear();
|
||||
|
||||
ws.onopen = (event) => {
|
||||
// Send payload to TS5 client
|
||||
ws.send(JSON.stringify(paylaod));
|
||||
};
|
||||
ws.onopen = (event) => {
|
||||
// Send payload to TS5 client
|
||||
ws.send(JSON.stringify(paylaod));
|
||||
};
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
let data = JSON.parse(event.data);
|
||||
// console.log(data);
|
||||
switch (data.type) {
|
||||
case "auth":
|
||||
handleAuthMessage(data);
|
||||
console.log(
|
||||
"%c --> API-KEY: %s ",
|
||||
"color:red;font-weight:bold;",
|
||||
` ${data.payload.apiKey}`
|
||||
);
|
||||
break;
|
||||
case "clientMoved":
|
||||
handleClientMoved(data);
|
||||
break;
|
||||
case "clientPropertiesUpdated":
|
||||
handleClientPropertiesUpdate(data);
|
||||
break;
|
||||
case "talkStatusChanged":
|
||||
handleTalkStatusChanged(data);
|
||||
break;
|
||||
case "serverPropertiesUpdated":
|
||||
ws.close();
|
||||
default:
|
||||
console.log(`No handler for event type: ${data.type}`);
|
||||
break;
|
||||
}
|
||||
ws.onmessage = (event) => {
|
||||
let data = JSON.parse(event.data);
|
||||
// console.log(data);
|
||||
switch (data.type) {
|
||||
case "auth":
|
||||
handleAuthMessage(data);
|
||||
console.log(
|
||||
"%c --> API-KEY: %s ",
|
||||
"color:red;font-weight:bold;",
|
||||
` ${data.payload.apiKey}`
|
||||
);
|
||||
break;
|
||||
case "clientMoved":
|
||||
handleClientMoved(data);
|
||||
break;
|
||||
case "clientPropertiesUpdated":
|
||||
handleClientPropertiesUpdate(data);
|
||||
break;
|
||||
case "talkStatusChanged":
|
||||
handleTalkStatusChanged(data);
|
||||
break;
|
||||
case "serverPropertiesUpdated":
|
||||
ws.close();
|
||||
default:
|
||||
console.log(`No handler for event type: ${data.type}`);
|
||||
break;
|
||||
}
|
||||
|
||||
// Draw clientList in HTML object
|
||||
drawClients();
|
||||
};
|
||||
// Draw clientList in HTML object
|
||||
drawClients();
|
||||
};
|
||||
|
||||
ws.onerror = (err) => {
|
||||
console.error(err);
|
||||
ws.close();
|
||||
return;
|
||||
};
|
||||
ws.onerror = (err) => {
|
||||
console.error(err);
|
||||
ws.close();
|
||||
return;
|
||||
};
|
||||
|
||||
ws.onclose = (event) => {
|
||||
console.log("Disconnected: " + event.reason);
|
||||
clientList.clear();
|
||||
channelList.clear();
|
||||
drawClients();
|
||||
main(); // Reconnected
|
||||
};
|
||||
ws.onclose = (event) => {
|
||||
console.log("Disconnected: " + event.reason);
|
||||
clientList.clear();
|
||||
channelList.clear();
|
||||
drawClients();
|
||||
main(); // Reconnected
|
||||
};
|
||||
}
|
||||
main();
|
||||
|
||||
Reference in New Issue
Block a user