mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 12:02:50 +08:00
feat: 浏览器端报错翻译与提示改造
- errors: 新增 TeamSpeak 服务器错误 ID 映射表与不可重连错误码集合,归一化 normalizeTeamSpeakError 按 错误ID/关键词/异常类/传输层特征 分级收敛错误 - voice-bridge: 身份无效/客户端不可用时先发结构化 connectionFailed 帧再关闭, 新增 pendingKickReason 机制在 kicked 事件后优先回放踢出原因;Opus 编码器 不可用时限流上报 AUDIO_ENCODER_UNAVAILABLE - ts-client: 记录本端退出 reasonID,转发 kicked 事件并归一化踢出/封禁原因 - network-probe/teamspeak-probe: 收窄关键字匹配、拒绝原因收敛到既有探测码 - session-manager: 新增 teamSpeak-kicked 拆除原因 - WebClient: 麦克风失败不再假成功,音频状态避免自相矛盾,新增降级横幅与 中/英/德三语提示词表 - useVoiceWebSocket: 导出 ensureMicrophone 供开麦前预检,新增音频诊断状态、 CONNECTION_FAILURE_MESSAGES 总表与网关关闭码映射 - 关键新增逻辑补充中文注释说明改动意图
This commit is contained in:
1 parent
1ba8cd5ee1
commit
4ead174c04
8 files changed
+677
-74
No files matched your search
+19
-1
@@ -14,7 +14,7 @@ import {
|
||||
type TextMessage,
|
||||
} from "@echosixhiya/teamspeak-client";
|
||||
import type { Logger } from "../logger.js";
|
||||
import { describeTeamSpeakError, normalizeTeamSpeakError } from "../errors.js";
|
||||
import { describeTeamSpeakError, normalizeTeamSpeakError, normalizeTeamSpeakKickedReason } from "../errors.js";
|
||||
import { TeamSpeakAdapter, type TeamSpeakProtocol } from "./teamspeak-adapter.js";
|
||||
import type { TeamSpeakTarget } from "../domain/teamspeak-target.js";
|
||||
import { createAccelerationRelayClient, type AccelerationRelayClient, type AccelerationRelayOptions } from "./acceleration-relay.js";
|
||||
@@ -74,6 +74,10 @@ export class TSClient extends EventEmitter {
|
||||
private connected = false;
|
||||
private preferredChannelId = 0n;
|
||||
private accelerationClient: AccelerationRelayClient | null = null;
|
||||
// Reason id of the most recent self leave, kept so the SDK `kicked` event can
|
||||
// tell a plain kick (4) from a kick with ban (5). The SDK only forwards the
|
||||
// reason message to its `kicked` handler, not the reason id.
|
||||
private selfLeaveReasonId: number | null = null;
|
||||
|
||||
constructor(private options: TSClientOptions, logger: Logger) {
|
||||
super();
|
||||
@@ -214,9 +218,23 @@ export class TSClient extends EventEmitter {
|
||||
});
|
||||
|
||||
client.on("clientLeave", (info) => {
|
||||
// 仅记录本客户端的踢出(4)/踢出并封禁(5)退出原因,供 kicked 事件区分普通踢出与封禁
|
||||
if (info.id === this.clientId && (info.reasonID === 4 || info.reasonID === 5)) this.selfLeaveReasonId = info.reasonID;
|
||||
this.emit("clientLeave", info);
|
||||
});
|
||||
|
||||
// 转发 SDK 的 kicked 事件:不转发的话管理员填写的踢出原因会被丢弃,浏览器
|
||||
// 只能看到笼统的「连接失败」。这里把原因连同 reason id 一起归一化后向上抛。
|
||||
// The SDK emits `kicked` only for a self leave with reason 4 (kick) or 5
|
||||
// (kick with ban) and hands over the admin written reason message. Without
|
||||
// this listener the reason was dropped, so the browser degraded to a generic
|
||||
// "connection failed" right after the transport went away.
|
||||
client.on("kicked", (reasonMsg) => {
|
||||
const reasonId = this.selfLeaveReasonId;
|
||||
this.selfLeaveReasonId = null;
|
||||
this.emit("kicked", normalizeTeamSpeakKickedReason(reasonMsg, reasonId));
|
||||
});
|
||||
|
||||
client.on("clientMoved", (info) => {
|
||||
if (info.id === this.clientId && info.targetChannelID !== 0n) this.preferredChannelId = info.targetChannelID;
|
||||
this.emit("clientMoved", info);
|
||||
|
||||
Reference in new issue
Block a user