Voice testing

This commit is contained in:
2026-01-05 21:43:05 +01:00
parent 148602f7d9
commit 07dbac50c8
6 changed files with 120 additions and 2 deletions
+21 -1
View File
@@ -4,6 +4,8 @@ import App from "@/types/app";
import React from "react";
import PluginChannel from "./PluginChannel";
import { IndicatorContext } from "@/types/protocol";
import VoiceBox from "./VoiceBox";
import { sendVoice } from "@/lib/audio";
export default function ChannelView({
app,
@@ -41,7 +43,25 @@ export default function ChannelView({
);
case "voice":
return null;
return (
<VoiceBox
app={app}
channelName={app.currentChannel.name}
messages={messages}
sendRequest={(req) => {
while (serverRef.current?.CONNECTING) {}
serverRef.current?.send(JSON.stringify(req));
}}
sendVoice={(data) => {
while (!serverRef.current || serverRef.current?.CONNECTING) {}
sendVoice(serverRef.current, 0, data);
}}
indicators={indicators.filter(
(indicator) =>
indicator.indicator.params.user_id !== app.profile?.id
)}
/>
);
default:
return (
+27
View File
@@ -0,0 +1,27 @@
"use client";
import App from "@/types/app";
import { ClientMessage, IndicatorContext } from "@/types/protocol";
import { Message } from "@/types/types";
import { useEffect } from "react";
import { startMic } from "@/lib/audio";
export default function VoiceBox({
sendVoice,
}: {
app: App;
sendRequest: (req: ClientMessage) => void;
channelName?: string;
channelIcon?: string;
messages: Message[];
indicators: IndicatorContext[];
sendVoice: (data: Int16Array) => void;
}) {
useEffect(() => {
startMic(sendVoice);
}, []);
return (
<div className="h-svh w-full max-h-svh flex flex-col pb-5 pl-5 gap-5" />
);
}