This commit is contained in:
2026-08-27 14:42:35 +02:00
parent f28c9c0bdf
commit 23e6a2199f
4 changed files with 186 additions and 40 deletions
+11
View File
@@ -210,6 +210,17 @@ export default class Enclave<P = Page> {
case "JoinVoice":
server.voiceJoin && server.voiceJoin(msg.pin, msg.channel_id);
return;
case "UserJoinedVoice":
if (!server.voiceChatUsers[msg.channel_id])
server.voiceChatUsers[msg.channel_id] = [];
server.voiceChatUsers[msg.channel_id].push(msg.pubkey);
return;
case "Speaking":
server.voiceChatSpeaker(msg.pubkey);
return;
}
}
}
+10 -1
View File
@@ -33,7 +33,16 @@ export type ClientMethod =
| {
method: "JoinVoice";
channel_id: string;
pin: number;
pin: bigint;
}
| {
method: "UserJoinedVoice";
channel_id: string;
pubkey: string;
}
| {
method: "Speaking";
pubkey: string;
};
export type ServerMethod =
+14
View File
@@ -29,15 +29,21 @@ export default class EnclaveServer {
public isSecure: boolean;
public websocket?: EnclaveWebSocket;
public meta?: ServerMeta;
public messages: Record<string, Record<string, StoredMessage>>;
public users: Record<string, ClientMeta | null>;
public voiceJoin?: (pin: number, channelId: string) => void;
public voiceChatUsers: Record<string, string[]>;
public voiceChatSpeakers: Record<string, NodeJS.Timeout>;
public constructor(hostname: string, isSecure: boolean) {
this.hostname = hostname;
this.isSecure = isSecure;
this.messages = {};
this.users = {};
this.voiceChatUsers = {};
this.voiceChatSpeakers = {};
}
public disconnect() {
@@ -107,4 +113,12 @@ export default class EnclaveServer {
this.websocket?.send({ method: "GetUsers", pubkeys: filteredPubkeys });
}
public voiceChatSpeaker(pubkey: string) {
clearTimeout(this.voiceChatSpeakers[pubkey]);
this.voiceChatSpeakers[pubkey] = setTimeout(() => {
delete this.voiceChatSpeakers[pubkey];
}, 1000);
}
}