mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
fix: expose server identity and refine KAAK client
This commit is contained in:
1 parent
e8164abafe
commit
17fb27b89a
28 files changed
+1504
-334
No files matched your search
@@ -43,6 +43,11 @@ export interface VoiceState {
|
||||
channelSwitchedChannelId: string;
|
||||
}
|
||||
|
||||
export interface VoiceServerInfo {
|
||||
name: string;
|
||||
icon?: string | null;
|
||||
}
|
||||
|
||||
export interface AudioInputDevice {
|
||||
deviceId: string;
|
||||
label: string;
|
||||
@@ -190,6 +195,7 @@ class CancelledMediaOperation extends Error {
|
||||
|
||||
export function useVoiceWebSocket() {
|
||||
const ws = shallowRef<WebSocket | null>(null);
|
||||
const serverInfo = shallowRef<VoiceServerInfo | null>(null);
|
||||
const state = reactive<VoiceState>({ connected: false, connecting: false, reconnecting: false, reconnectAttempt: 0, reconnectFailed: false, tsClientId: 0, error: "", errorCode: "", microphoneError: "", microphoneErrorCode: "", audioNotice: "", audioNoticeCode: "", channelSwitchedChannelId: "" });
|
||||
const sessionState = createVoiceSessionState({
|
||||
selfId: () => state.tsClientId,
|
||||
@@ -993,6 +999,7 @@ export function useVoiceWebSocket() {
|
||||
}
|
||||
|
||||
function disconnect(preserveConnection = false): void {
|
||||
serverInfo.value = null;
|
||||
const keepRememberedIdentity = lastConnection?.rememberIdentity === true;
|
||||
if (!preserveConnection) lastConnection = null;
|
||||
voiceConnection.stop(() => releaseSessionResources(!preserveConnection));
|
||||
@@ -1036,6 +1043,9 @@ export function useVoiceWebSocket() {
|
||||
const msg = parseServerMessage(raw);
|
||||
if (!msg || screenShare.handleMessage(msg) || sessionState.receive(msg)) return;
|
||||
switch (msg.type) {
|
||||
case "serverInfo":
|
||||
serverInfo.value = { name: msg.name, icon: msg.icon ?? null };
|
||||
break;
|
||||
case "connected":
|
||||
const wasReconnecting = state.reconnecting;
|
||||
state.connected = true;
|
||||
@@ -1401,6 +1411,7 @@ export function useVoiceWebSocket() {
|
||||
...screenShare.api,
|
||||
ws,
|
||||
state,
|
||||
serverInfo,
|
||||
sessionEpoch: sessionState.epoch,
|
||||
memberConversationKey: sessionState.memberConversationKey,
|
||||
members,
|
||||
|
||||
Reference in new issue
Block a user