mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Pass TS6 stream signaling through connector and gateway
tsclientlib dropped every command missing from the message declarations, which silently swallowed TS6's whole Stream/Call signaling exchange: none of the stream commands are declared, so notifystreamsignaling never reached a consumer. That is why the protocol could only be captured with a standalone raw-tsproto tool. handle_command now splits the parse failure - ParseError::UnknownCommand hands the raw line up as StreamItem::UnknownCommand instead of warning and returning, everything else keeps the old behaviour. The connector unescapes the TS wire format and forwards the stream commands as a streamEvent, filtered to notifystream*/notifyrespondjoinstream* so unrelated undeclared commands stay dropped. The JSON payload stays opaque the whole way - SDP and ICE belong to the browser's RTCPeerConnection, not to the connector. Outbound, streamjoin/streamleave/streamsignal join the existing raw OutCommand handlers; parameter names and order are as recovered from TeamSpeak.dll and confirmed against a live TS6 client. The gateway serializes the payload itself so no literal newline can reach the line-based stdin protocol. Nothing renders video yet - the browser side is still missing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
7776a71e84
commit
9f1a63c9d3
3 files changed
+155
-1
No files matched your search
@@ -415,6 +415,27 @@ wss.on("connection", (socket: WebSocket) => {
|
||||
await connection?.sendAudio(msg.pcm);
|
||||
break;
|
||||
}
|
||||
case "joinStream": {
|
||||
const clientId = Number(msg.clientId);
|
||||
if (Number.isFinite(clientId)) {
|
||||
await connection?.joinStream(String(msg.streamId ?? ""), clientId, msg.message ?? "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "leaveStream": {
|
||||
const clientId = Number(msg.clientId);
|
||||
if (Number.isFinite(clientId)) {
|
||||
await connection?.leaveStream(String(msg.streamId ?? ""), clientId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "streamSignal": {
|
||||
const clientId = Number(msg.clientId);
|
||||
if (Number.isFinite(clientId) && msg.payload !== undefined) {
|
||||
await connection?.sendStreamSignal(String(msg.streamId ?? ""), clientId, msg.payload);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "setAway": {
|
||||
await connection?.setAway(msg.away, msg.message ?? "");
|
||||
break;
|
||||
|
||||
@@ -774,6 +774,30 @@ export class Ts3Connection {
|
||||
this.child?.stdin.write(`audio ${pcmBase64}\n`);
|
||||
}
|
||||
|
||||
/** Ask the client publishing a TS6 stream to let us watch. The answer comes
|
||||
* back as a `streamEvent` of type `notifyrespondjoinstreamrequest`, which
|
||||
* carries the SDP offer. */
|
||||
async joinStream(streamId: string, clientId: number, message = ""): Promise<void> {
|
||||
const id = streamId.replace(/[\s]+/g, "");
|
||||
const sanitized = message.replace(/[\r\n]+/g, " ").trim();
|
||||
if (id) this.child?.stdin.write(`streamjoin ${id} ${clientId} ${sanitized}\n`);
|
||||
}
|
||||
|
||||
async leaveStream(streamId: string, clientId: number): Promise<void> {
|
||||
const id = streamId.replace(/[\s]+/g, "");
|
||||
if (id) this.child?.stdin.write(`streamleave ${id} ${clientId}\n`);
|
||||
}
|
||||
|
||||
/** Relays one signaling payload (SDP answer, ICE candidate) to a stream peer.
|
||||
* `payload` is passed straight through - the connector only escapes it for
|
||||
* the TS wire, nobody in this path interprets it. Serializing here rather
|
||||
* than accepting a string keeps literal newlines out of the line-based
|
||||
* stdin protocol. */
|
||||
async sendStreamSignal(streamId: string, clientId: number, payload: unknown): Promise<void> {
|
||||
const id = streamId.replace(/[\s]+/g, "");
|
||||
if (id) this.child?.stdin.write(`streamsignal ${id} ${clientId} ${JSON.stringify(payload)}\n`);
|
||||
}
|
||||
|
||||
async setAway(away: boolean, message: string): Promise<void> {
|
||||
if (away) {
|
||||
const sanitized = message.replace(/[\r\n]+/g, " ").trim();
|
||||
|
||||
Reference in new issue
Block a user