25 lines
851 B
TypeScript
25 lines
851 B
TypeScript
'use client'
|
|
|
|
import AgoraRTC, { AgoraRTCProvider } from 'agora-rtc-react';
|
|
import { Session } from '../../../types/sessions';
|
|
import { Agora } from './Agora';
|
|
|
|
AgoraRTC.setLogLevel(0);
|
|
|
|
export const AgoraClient = ({ session, stopCalling, isCoach }: { session?: Session, stopCalling: () => void, isCoach: boolean }) => {
|
|
const remoteUser = isCoach ? (session?.clients?.length ? session?.clients[0] : undefined) : session?.coach;
|
|
|
|
return session ? (
|
|
<AgoraRTCProvider client={AgoraRTC.createClient({ mode: "rtc", codec: "vp8" })}>
|
|
{session && (
|
|
<Agora
|
|
sessionId={session.id}
|
|
secret={session.secret}
|
|
stopCalling={stopCalling}
|
|
remoteUser={remoteUser}
|
|
/>
|
|
)}
|
|
</AgoraRTCProvider>
|
|
) : null;
|
|
};
|