feat: per-speaker volume and a gateway feature handshake

The gateway now greets every browser with {type:"hello", features:[...]} so
the hosted client, which updates on every push, can hide what an older
gateway cannot do instead of hanging on it. A gateway without "hello" is
treated as the v0.14 feature set, which replaces the hand-flipped
STREAM_UI_ENABLED switch.

First feature behind it: "clientVolume". The client context menu gets a
0-200% slider, stored per client UID in localStorage. The connector applies
it to tsclientlib's per-speaker AudioQueue.volume while mixing, and keeps the
value across talk pauses, when that queue is torn down and recreated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
MoepchiandClaude Opus 5.5 committed 2026-10-03 00:34:12 +00:00
1 parent c0778c8adb
commit 7b3cb5ef09
10 files changed
+150 -31

No files matched your search

+13
View File
@@ -115,6 +115,9 @@ const SERVE_STATIC = process.env.WEB_STATIC !== "0";
// issue #12): set on the container, these end up in the served index.html as
// <meta> tags the client reads at startup, so changing them needs no rebuild.
// Meta tags rather than an inline script, which CONTENT_SECURITY_POLICY forbids.
// Sent to every browser in the "hello" message on socket open; see there.
const GATEWAY_FEATURES = ["clientVolume"];
const RUNTIME_CONFIG_META = Object.entries({
"webspeak3-default-server": process.env.DEFAULT_SERVER,
"webspeak3-default-channel": process.env.DEFAULT_CHANNEL,
@@ -628,6 +631,12 @@ wss.on("connection", (socket: WebSocket, req: IncomingMessage) => {
const ip = clientIp(req);
connectionsPerIp.set(ip, (connectionsPerIp.get(ip) ?? 0) + 1);
// The hosted UI updates on every push, the gateway only when its image is
// pulled, so the browser must not assume a feature exists just because it
// knows about it. A gateway without "hello" (before v0.15) supports the
// v0.14 feature set, streaming included; anything newer gets a name here.
socket.send(JSON.stringify({ type: "hello", features: GATEWAY_FEATURES }));
heartbeats.set(socket, { isAlive: true });
socket.on("pong", () => {
const state = heartbeats.get(socket);
@@ -809,6 +818,10 @@ wss.on("connection", (socket: WebSocket, req: IncomingMessage) => {
await connection?.setOutputMuted(msg.muted);
break;
}
case "setClientVolume": {
connection?.setClientVolume(Number(msg.clientId), Number(msg.volume));
break;
}
case "setNickname": {
await connection?.setNickname(msg.nickname);
break;
+5
View File
@@ -930,6 +930,11 @@ export class Ts3Connection {
this.writeLine(`muteoutput ${muted ? "1" : "0"}`);
}
/** Playback volume for one speaker, mixed in the connector (1 = unchanged). */
setClientVolume(clientId: number, volume: number): void {
if (Number.isInteger(clientId) && Number.isFinite(volume)) this.writeLine(`clientvolume ${clientId} ${volume}`);
}
async setNickname(nickname: string): Promise<void> {
const sanitized = nickname.replace(/[\r\n]+/g, " ").trim();
if (sanitized) this.writeLine(`nickname ${sanitized}`);