mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
feat: add direct P2P screen sharing signaling
This commit is contained in:
1 parent
dc63f4b45b
commit
d75bdccfd9
7 files changed
+1038
-4
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
type VoiceData,
|
||||
type DirectoryClientInfo,
|
||||
type DirectorySnapshot,
|
||||
type RawNotification,
|
||||
type TextMessage,
|
||||
} from "@echosixhiya/teamspeak-client";
|
||||
import type { Logger } from "../logger.js";
|
||||
@@ -46,6 +47,7 @@ const MAX_CLIENT_AVATAR_BYTES = 120 * 1024;
|
||||
|
||||
export type TSDirectorySnapshot = DirectorySnapshot;
|
||||
export type TSDirectoryClient = DirectoryClientInfo;
|
||||
export type TSRawNotification = RawNotification;
|
||||
|
||||
export type TSChatScope = "channel" | "server" | "private";
|
||||
|
||||
@@ -134,6 +136,22 @@ export class TSClient extends EventEmitter {
|
||||
err: error instanceof Error ? error.message : String(error),
|
||||
}, "Could not subscribe to all TeamSpeak channels");
|
||||
}
|
||||
// TS6 stream/screen-share notifications are delivered through the normal
|
||||
// server notification channel. Keep this subscription in the same client
|
||||
// session so a browser can participate in the native TS6 P2P signaling
|
||||
// flow without a second query connection.
|
||||
for (const event of ["server", "channel", "textchannel"] as const) {
|
||||
try {
|
||||
await client.execCommand(`servernotifyregister event=${event}`, 5_000);
|
||||
} catch (error: unknown) {
|
||||
// Older TeamSpeak servers may reject one of the newer event scopes.
|
||||
// This is optional: voice and directory sync must remain available.
|
||||
this.logger.debug({
|
||||
event,
|
||||
err: error instanceof Error ? error.message : String(error),
|
||||
}, "Optional TeamSpeak notification scope unavailable");
|
||||
}
|
||||
}
|
||||
// Directory snapshots are dispatched through two setImmediate layers in
|
||||
// the SDK. Let both flush before reconciling with a direct client-protocol
|
||||
// snapshot so the gateway's first connected state contains every member.
|
||||
@@ -240,6 +258,13 @@ export class TSClient extends EventEmitter {
|
||||
});
|
||||
});
|
||||
|
||||
client.on("rawNotification", (notification: RawNotification) => {
|
||||
this.emit("rawNotification", {
|
||||
name: notification.name,
|
||||
params: { ...notification.params },
|
||||
} satisfies TSRawNotification);
|
||||
});
|
||||
|
||||
client.on("textMessage", (msg) => {
|
||||
this.emit("textMessage", toTSChatMessage(msg));
|
||||
});
|
||||
@@ -373,6 +398,16 @@ export class TSClient extends EventEmitter {
|
||||
return this.client.execCommandWithResponse(command, timeoutMs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a TeamSpeak protocol command whose response is delivered later as a
|
||||
* notification (for example setupstream/streamsignaling). The command is
|
||||
* assembled by the trusted server-side stream adapter, never by the browser.
|
||||
*/
|
||||
async sendProtocolCommand(command: string): Promise<void> {
|
||||
if (!this.client || !this.connected) throw new Error("TeamSpeak session is not ready");
|
||||
await this.client.sendCommandNoWait(command);
|
||||
}
|
||||
|
||||
getIdentityString(): string {
|
||||
return this.identity.toString();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user