Skip to content
Merged

56 #90

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 187 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@huggingface/inference": "^3.6.2",
"@mediapipe/tasks-vision": "^0.10.22-rc.20250304",
"@prisma/client": "^6.5.0",
"agora-rtc-sdk-ng": "^4.23.2",
"barqode": "^0.0.2",
"better-auth": "^1.2.5",
"canvas": "^3.1.0",
Expand Down
35 changes: 1 addition & 34 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ datasource db {
}

model User {
id String @id @default(cuid())
id String @id @default(cuid())
name String
email String
emailVerified Boolean
Expand All @@ -20,8 +20,6 @@ model User {
accounts Account[]
Macros Macros[]
Onboarding Onboarding[]
createdRooms Room[] @relation("RoomCreator")
roomsJoined RoomParticipant[]
HeartRate HeartRate[]
Routines Routines[]

Expand Down Expand Up @@ -100,37 +98,6 @@ model Onboarding {
user User @relation(fields: [userId], references: [id])
}

model Room {
id String @id @default(cuid())
name String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
creatorId String
creator User @relation("RoomCreator", fields: [creatorId], references: [id])
participants RoomParticipant[]
status RoomStatus @default(STARTING)

@@map("room")
}

enum RoomStatus {
STARTING
ACTIVE
CLOSED
}

model RoomParticipant {
id String @id @default(cuid())
roomId String
room Room @relation(fields: [roomId], references: [id], onDelete: Cascade)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
joinedAt DateTime @default(now())

@@unique([roomId, userId])
@@map("room_participant")
}

model HeartRate {
id String @id @default(cuid())
user User @relation(fields: [userId], references: [id])
Expand Down
35 changes: 35 additions & 0 deletions src/lib/agora.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import AgoraRTC, { type ICameraVideoTrack, type IMicrophoneAudioTrack } from 'agora-rtc-sdk-ng';

const appId = '989389d78f284ae4bf4524ac7e09e1b3'; // Replace with your Agora app ID

export const agoraClient = AgoraRTC.createClient({
mode: 'rtc',
codec: 'vp8'
});

export async function createLocalTracks(): Promise<{
videoTrack: ICameraVideoTrack;
}> {
const videoTrack = await AgoraRTC.createCameraVideoTrack();
return { videoTrack };
}

export async function joinChannel(channelName: string, uid: number) {
try {
await agoraClient.join(appId, channelName, null, uid);
const { videoTrack } = await createLocalTracks();
await agoraClient.publish([videoTrack]);
return { videoTrack };
} catch (error) {
console.error('Error joining channel:', error);
throw error;
}
}

export async function leaveChannel() {
agoraClient.remoteUsers.forEach((user) => {
const playerContainer = document.getElementById(`player-${user.uid}`);
playerContainer?.remove();
});
await agoraClient.leave();
}
Empty file.
Loading
Loading