mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-02 17:32:50 +08:00
Adds TeaSpeak/GreenTeaSpeak protocol support and multi-join session tabs plus a GreenteaSpeak UI theme. Key changes: connector (Rust) supports --server-type, privilege key, server variables, license formatting, Query-client filtering and extra metrics; gateway accepts serverType/privilegeKey, optional static serving (WEB_STATIC), and per-tab /ws sessions; web frontend: multi-session parking (connectionSessions), channel spacer parsing, talk-lamp UI, extended server connection info, connect dialog serverType/privilegeKey, GreenteaSpeak CSS & chrome, i18n updates, and demo updates. Also adds docs/teaspeak.md and dependency num-traits.
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
/**
|
|
* Maps WebSpeak gateway WebSocket payloads to the shape the GreenTeaSpeak
|
|
* shell expects. The browser UI still uses App.tsx state; this module is the
|
|
* contract layer so GTS chrome never talks to Electron IPC.
|
|
*/
|
|
|
|
export type GatewayServerType = "auto" | "teamspeak" | "teaspeak";
|
|
|
|
export type GatewayConnectPayload = {
|
|
type: "connect";
|
|
host: string;
|
|
nickname: string;
|
|
serverPassword?: string;
|
|
channelPassword?: string;
|
|
defaultChannel?: string;
|
|
identity?: string;
|
|
privilegeKey?: string;
|
|
serverType?: GatewayServerType;
|
|
};
|
|
|
|
export type GatewayOutboundAction =
|
|
| GatewayConnectPayload
|
|
| { type: "disconnect" }
|
|
| { type: "switchChannel"; channelId: number }
|
|
| { type: "sendChat"; message: string; target?: "channel" | "server" | number }
|
|
| { type: string; [key: string]: unknown };
|
|
|
|
/** Build the connect message sent on the WebSpeak gateway socket. */
|
|
export function buildGatewayConnect(input: {
|
|
host: string;
|
|
nickname: string;
|
|
serverPassword?: string;
|
|
channelPassword?: string;
|
|
defaultChannel?: string;
|
|
identity?: string;
|
|
privilegeKey?: string;
|
|
serverType?: GatewayServerType;
|
|
}): GatewayConnectPayload {
|
|
return {
|
|
type: "connect",
|
|
host: input.host.trim(),
|
|
nickname: input.nickname.trim(),
|
|
serverPassword: input.serverPassword?.trim() || undefined,
|
|
channelPassword: input.channelPassword?.trim() || undefined,
|
|
defaultChannel: input.defaultChannel?.trim() || undefined,
|
|
identity: input.identity || undefined,
|
|
privilegeKey: input.privilegeKey?.trim() || undefined,
|
|
serverType: input.serverType || "auto",
|
|
};
|
|
}
|
|
|
|
export function sendGatewayAction(ws: WebSocket | null, action: GatewayOutboundAction): boolean {
|
|
if (!ws || ws.readyState !== WebSocket.OPEN) return false;
|
|
ws.send(JSON.stringify(action));
|
|
return true;
|
|
}
|