Initial commit: browser-based TeamSpeak client

React frontend + Node gateway + Rust connector (tsclientlib) providing
connect, channel tree/switching, channel/server/private text chat, and
voice with voice activation and output device selection.
This commit is contained in:
Moepchi committed 2026-07-28 19:25:46 +02:00
commit b3e55a60b5
33 files changed
+7383

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
import { WebSocketServer, type WebSocket } from "ws";
import { Ts3Connection, type Ts3ConnectOptions } from "./ts3/connection.js";
const PORT = Number(process.env.PORT ?? 8080);
const wss = new WebSocketServer({ port: PORT });
console.log(`Gateway listening on ws://localhost:${PORT}`);
wss.on("connection", (socket: WebSocket) => {
let connection: Ts3Connection | undefined;
socket.on("message", async (raw) => {
const msg = JSON.parse(raw.toString());
switch (msg.type) {
case "connect": {
const options: Ts3ConnectOptions = {
host: msg.host,
nickname: msg.nickname,
};
connection = new Ts3Connection(options);
connection.onEvent((event) => socket.send(JSON.stringify(event)));
await connection.connect();
break;
}
case "switchChannel": {
await connection?.switchChannel(msg.channelId);
break;
}
case "sendChatMessage": {
await connection?.sendChatMessage(msg.message);
break;
}
case "sendServerMessage": {
await connection?.sendServerMessage(msg.message);
break;
}
case "sendPrivateMessage": {
await connection?.sendPrivateMessage(msg.clientId, msg.message);
break;
}
case "sendAudio": {
await connection?.sendAudio(msg.pcm);
break;
}
default:
socket.send(
JSON.stringify({ type: "error", message: `Unknown message type: ${msg.type}` })
);
}
});
socket.on("close", () => {
connection?.disconnect();
});
});