Better voice chat UI and fix bug
This commit is contained in:
+3
-4
@@ -170,6 +170,8 @@ export default class Enclave<P = Page> {
|
||||
|
||||
if (!server || channel.kind !== "voice") return;
|
||||
|
||||
if (server.voiceChannelId) this.leaveVoice();
|
||||
|
||||
server.voiceJoin = (pin, channelId) => {
|
||||
invoke("connect_to_vc", {
|
||||
hostname: server.hostname,
|
||||
@@ -177,14 +179,12 @@ export default class Enclave<P = Page> {
|
||||
sharedSecret: server.websocket?.sharedSecret,
|
||||
})
|
||||
.then(() => {
|
||||
server.isInVoiceChat = true;
|
||||
server.voiceChannelId = channelId;
|
||||
this.forceRender();
|
||||
})
|
||||
.catch(console.error);
|
||||
};
|
||||
|
||||
server.isInVoiceChat = true;
|
||||
server.voiceChannelId = channel.id;
|
||||
|
||||
server.websocket?.send({ method: "JoinVoice", channel_id: channel.id });
|
||||
@@ -195,12 +195,11 @@ export default class Enclave<P = Page> {
|
||||
public leaveVoice() {
|
||||
const server = this.server;
|
||||
|
||||
if (!server || !server.isInVoiceChat) return;
|
||||
if (!server || !server.voiceChannelId) return;
|
||||
|
||||
server.websocket?.send({ method: "LeaveVoice" });
|
||||
invoke("disconnect_from_vc").catch(console.error);
|
||||
|
||||
server.isInVoiceChat = false;
|
||||
server.voiceChannelId = undefined;
|
||||
server.voiceChatSpeakers = {};
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ export default class EnclaveServer {
|
||||
public voiceJoin?: (pin: bigint, channelId: string) => void;
|
||||
public voiceChatUsers: Record<string, string[]>;
|
||||
public voiceChatSpeakers: Record<string, NodeJS.Timeout>;
|
||||
public isInVoiceChat: boolean;
|
||||
public voiceChannelId?: string;
|
||||
|
||||
public constructor(hostname: string, isSecure: boolean) {
|
||||
@@ -47,7 +46,6 @@ export default class EnclaveServer {
|
||||
this.users = {};
|
||||
this.voiceChatUsers = {};
|
||||
this.voiceChatSpeakers = {};
|
||||
this.isInVoiceChat = false;
|
||||
}
|
||||
|
||||
public disconnect() {
|
||||
|
||||
@@ -17,7 +17,6 @@ export default class EnclaveWebSocket {
|
||||
onOpenQueue: Array<() => void>;
|
||||
|
||||
private sendCounter = 0n;
|
||||
private recvCounter = 0n;
|
||||
public sharedSecret: Uint8Array | null = null;
|
||||
|
||||
private readonly handshakeReady: Promise<void>;
|
||||
@@ -78,14 +77,6 @@ export default class EnclaveWebSocket {
|
||||
return nonce;
|
||||
}
|
||||
|
||||
private nextRecvNonce(): Uint8Array {
|
||||
const nonce = new Uint8Array(12);
|
||||
const view = new DataView(nonce.buffer);
|
||||
view.setBigUint64(0, this.recvCounter, false);
|
||||
this.recvCounter += 1n;
|
||||
return nonce;
|
||||
}
|
||||
|
||||
private encrypt(plaintext: Uint8Array): Uint8Array {
|
||||
if (!this.sharedSecret) throw new Error("Handshake not complete");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user